Skip to content

Commit 5ce83d9

Browse files
committed
feat: semi
1 parent cee91ff commit 5ce83d9

File tree

10 files changed

+207
-349
lines changed

10 files changed

+207
-349
lines changed

src/i18n/message/app/option-resource.json

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -114,26 +114,6 @@
114114
"title": "无障碍功能",
115115
"chartDecal": "{input} 是否显示图表的贴花图案"
116116
},
117-
"notification": {
118-
"title": "通知",
119-
"method": "通知方式 {input}",
120-
"cycle": {
121-
"label": "发送周期 {input}",
122-
"none": "关闭",
123-
"daily": "每天",
124-
"weekly": "每周",
125-
"time": "时间",
126-
"weekday": "周几"
127-
},
128-
"meta": {
129-
"browser": "浏览器",
130-
"callback": {
131-
"label": "HTTP 回调",
132-
"endpoint": "自定义 endpoint",
133-
"authToken": "Auth Token(可选)"
134-
}
135-
}
136-
},
137117
"resetButton": "恢复默认",
138118
"resetSuccess": "成功重置为默认值",
139119
"exportButton": "导出设置",
@@ -256,26 +236,6 @@
256236
"title": "無障礙設定",
257237
"chartDecal": "{input} 是否顯示圖表裝飾"
258238
},
259-
"notification": {
260-
"title": "通知",
261-
"method": "通知方式 {input}",
262-
"cycle": {
263-
"label": "發送週期 {input}",
264-
"none": "關閉",
265-
"daily": "每天",
266-
"weekly": "每週",
267-
"time": "時間",
268-
"weekday": "週幾"
269-
},
270-
"meta": {
271-
"browser": "瀏覽器",
272-
"callback": {
273-
"label": "HTTP 回調",
274-
"endpoint": "自定義 endpoint",
275-
"authToken": "Auth Token(可選)"
276-
}
277-
}
278-
},
279239
"resetButton": "重設",
280240
"resetSuccess": "已恢復預設值!",
281241
"exportButton": "匯出設定",
@@ -406,21 +366,17 @@
406366
},
407367
"notification": {
408368
"title": "Notification",
409-
"method": "Notification method {input}",
410369
"cycle": {
411370
"label": "Notification cycle {input}",
412-
"none": "Off",
413371
"daily": "Daily",
414-
"weekly": "Weekly",
415-
"time": "Time",
416-
"weekday": "Weekday"
372+
"weekly": "Weekly"
417373
},
418-
"meta": {
374+
"method": {
375+
"label": "Notification method {input}",
419376
"browser": "Browser",
420377
"callback": {
421378
"label": "HTTP Callback",
422-
"endpoint": "Endpoint",
423-
"authToken": "Auth Token (Optional)"
379+
"url": "Callback URL {input}"
424380
}
425381
}
426382
},

src/i18n/message/app/option.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,17 @@ export type OptionMessage = {
122122
}
123123
notification: {
124124
title: string
125-
method: string
126125
cycle: {
127126
label: string
128-
none: string
129127
daily: string
130128
weekly: string
131-
time: string
132-
weekday: string
133129
}
134-
meta: {
130+
method: {
131+
label: string
135132
browser: string
136133
callback: {
137134
label: string
138-
endpoint: string
139-
authToken: string
135+
url: string
140136
}
141137
}
142138
}

src/pages/app/components/Option/categories/Backup/index.tsx

Lines changed: 37 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { OptionItem, OptionLines, OptionTooltip } from '../../components'
1515
import type { CategoryInstance } from '../types'
1616
import AutoInput from "./AutoInput"
1717
import Footer from "./Footer"
18-
import { useOptionState } from "./state"
18+
import { useBackup } from "./useBackup"
1919

2020
const ALL_TYPES: timer.backup.Type[] = [
2121
'none',
@@ -35,58 +35,49 @@ const LONG_INPUT_WIDTH = 'min(400px, calc(100vw - 80px))'
3535

3636
const _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

src/pages/app/components/Option/categories/Backup/state.ts

Lines changed: 0 additions & 118 deletions
This file was deleted.

0 commit comments

Comments
 (0)