@@ -15,7 +15,7 @@ import { OptionItem, OptionLines, OptionTooltip } from '../../components'
1515import type { CategoryInstance } from '../types'
1616import AutoInput from "./AutoInput"
1717import Footer from "./Footer"
18- import { useOptionState } from "./state "
18+ import { useBackup } from "./useBackup "
1919
2020const ALL_TYPES : timer . backup . Type [ ] = [
2121 'none' ,
@@ -35,58 +35,49 @@ const LONG_INPUT_WIDTH = 'min(400px, calc(100vw - 80px))'
3535
3636const _default = defineComponent ( ( _ , ctx ) => {
3737 const {
38- backupType, clientName, reset,
39- autoBackUp, autoBackUpInterval,
40- auth, account, password,
38+ option, auth, account, password, reset,
4139 ext, setExtField,
42- } = useOptionState ( )
40+ } = useBackup ( )
4341
44- const isNotNone = computed ( ( ) => backupType . value && backupType . value !== 'none' )
42+ const isNotNone = computed ( ( ) => option . backupType !== 'none' )
4543
4644 ctx . expose ( { reset } satisfies CategoryInstance )
4745
4846 return ( ) => < OptionLines >
4947 < OptionItem label = { msg => msg . option . backup . type } defaultValue = { TYPE_NAMES [ 'none' ] } >
5048 < ElSelect
51- modelValue = { backupType . value }
49+ modelValue = { option . backupType }
5250 size = "small"
53- onChange = { ( val : timer . backup . Type ) => backupType . value = val }
51+ onChange = { ( val : timer . backup . Type ) => option . backupType = val }
5452 options = { ALL_TYPES . map ( value => ( { value, label : TYPE_NAMES [ value ] } ) ) }
5553 />
5654 </ OptionItem >
55+ < OptionItem v-show = { isNotNone . value } label = "{input}" defaultValue = { false } >
56+ < AutoInput
57+ autoBackup = { option . autoBackUp }
58+ interval = { option . autoBackUpInterval }
59+ onAutoBackupChange = { val => option . autoBackUp = val }
60+ onIntervalChange = { val => val !== undefined && ( option . autoBackUpInterval = val ) }
61+ />
62+ </ OptionItem >
5763 < OptionItem
58- v-show = { isNotNone . value }
59- label = { _ => "{input}" }
60- defaultValue = { t ( msg => msg . option . no ) }
64+ v-show = { option . backupType === 'gist' }
65+ label = "Personal Access Token {info} {input}"
66+ v-slots = { {
67+ info : ( ) => < OptionTooltip > { t ( msg => msg . option . backup . meta . gist . authInfo ) } </ OptionTooltip >
68+ } }
6169 >
62- < AutoInput
63- autoBackup = { autoBackUp . value }
64- interval = { autoBackUpInterval . value }
65- onAutoBackupChange = { val => autoBackUp . value = val }
66- onIntervalChange = { val => autoBackUpInterval . value = val }
70+ < ElInput
71+ modelValue = { auth . value }
72+ size = "small"
73+ type = "password"
74+ showPassword
75+ style = { { width : LONG_INPUT_WIDTH } }
76+ onInput = { val => auth . value = val ?. trim ?.( ) || '' }
6777 />
6878 </ OptionItem >
69- { backupType . value === 'gist' && < >
70- < OptionItem
71- key = "gist-token"
72- label = { _ => 'Personal Access Token {info} {input}' }
73- v-slots = { {
74- info : ( ) => < OptionTooltip > { t ( msg => msg . option . backup . meta . gist . authInfo ) } </ OptionTooltip >
75- } }
76- >
77- < ElInput
78- modelValue = { auth . value }
79- size = "small"
80- type = "password"
81- showPassword
82- style = { { width : LONG_INPUT_WIDTH } }
83- onInput = { val => auth . value = val ?. trim ?.( ) || '' }
84- />
85- </ OptionItem >
86- </ > }
87- { backupType . value === 'obsidian_local_rest_api' && < >
79+ { option . backupType === 'obsidian_local_rest_api' && < >
8880 < OptionItem
89- key = "obsidian-endpoint"
9081 label = { msg => msg . option . backup . label . endpoint }
9182 v-slots = { {
9283 info : ( ) => < OptionTooltip > { t ( msg => msg . option . backup . meta . obsidian_local_rest_api . endpointInfo ) } </ OptionTooltip >
@@ -100,7 +91,7 @@ const _default = defineComponent((_, ctx) => {
10091 onInput = { val => setExtField ( 'endpoint' , val ) }
10192 />
10293 </ OptionItem >
103- < OptionItem key = "obsidian-vault" label = { _ => "Vault Name {input}" } >
94+ < OptionItem label = "Vault Name {input}" >
10495 < ElInput
10596 placeholder = { DEFAULT_OBSIDIAN_BUCKET }
10697 modelValue = { ext . value ?. bucket }
@@ -109,15 +100,15 @@ const _default = defineComponent((_, ctx) => {
109100 onInput = { val => setExtField ( 'bucket' , val ) }
110101 />
111102 </ OptionItem >
112- < OptionItem key = "obsidian-path" label = { msg => msg . option . backup . label . path } required >
103+ < OptionItem label = { msg => msg . option . backup . label . path } required >
113104 < ElInput
114105 modelValue = { ext . value ?. dirPath }
115106 size = "small"
116107 style = { { width : LONG_INPUT_WIDTH } }
117108 onInput = { val => setExtField ( 'dirPath' , val ) }
118109 />
119110 </ OptionItem >
120- < OptionItem key = "obsidian-auth" label = { _ => "Authorization {input}" } required >
111+ < OptionItem label = "Authorization {input}" required >
121112 < ElInput
122113 modelValue = { auth . value }
123114 size = "small"
@@ -128,9 +119,8 @@ const _default = defineComponent((_, ctx) => {
128119 />
129120 </ OptionItem >
130121 </ > }
131- { backupType . value === 'web_dav' && < >
122+ { option . backupType === 'web_dav' && < >
132123 < OptionItem
133- key = "web-dav-endpoint"
134124 label = { msg => msg . option . backup . label . endpoint }
135125 v-slots = { { info : ( ) => '' } }
136126 required
@@ -143,7 +133,7 @@ const _default = defineComponent((_, ctx) => {
143133 onInput = { val => setExtField ( 'endpoint' , val ) }
144134 />
145135 </ OptionItem >
146- < OptionItem key = 'web-dav-path' label = { msg => msg . option . backup . label . path } required >
136+ < OptionItem label = { msg => msg . option . backup . label . path } required >
147137 < ElInput
148138 modelValue = { ext . value ?. dirPath }
149139 placeholder = "/for/example"
@@ -152,15 +142,15 @@ const _default = defineComponent((_, ctx) => {
152142 onInput = { val => setExtField ( 'dirPath' , val ) }
153143 />
154144 </ OptionItem >
155- < OptionItem key = 'web-dav-acc' label = { msg => msg . option . backup . label . account } required >
145+ < OptionItem label = { msg => msg . option . backup . label . account } required >
156146 < ElInput
157147 modelValue = { account . value }
158148 size = "small"
159149 style = { { width : "200px" } }
160150 onInput = { val => account . value = val ?. trim ?.( ) }
161151 />
162152 </ OptionItem >
163- < OptionItem key = 'web-dav-psw' label = { msg => msg . option . backup . label . password } required >
153+ < OptionItem label = { msg => msg . option . backup . label . password } required >
164154 < ElInput
165155 modelValue = { password . value }
166156 size = "small"
@@ -172,13 +162,13 @@ const _default = defineComponent((_, ctx) => {
172162 </ > }
173163 < OptionItem v-show = { isNotNone . value } label = { msg => msg . option . backup . client } >
174164 < ElInput
175- modelValue = { clientName . value }
165+ modelValue = { option . clientName }
176166 size = "small"
177167 style = { { width : "120px" } }
178- onInput = { val => clientName . value = val ?. trim ?.( ) || '' }
168+ onInput = { val => option . clientName = val ?. trim ?.( ) ?? '' }
179169 />
180170 </ OptionItem >
181- { isNotNone . value && < Footer type = { backupType . value } /> }
171+ { isNotNone . value && < Footer type = { option . backupType } /> }
182172 </ OptionLines >
183173} )
184174
0 commit comments