Skip to content

Commit

Permalink
添加config页面
Browse files Browse the repository at this point in the history
  • Loading branch information
hanaTsuk1 committed Apr 16, 2023
1 parent a7628d8 commit bcd76b2
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"fullscreen": false,
"resizable": true,
"title": "shion",
"width": 800,
"height": 600
"width": 960,
"height": 540
}
]
}
Expand Down
7 changes: 7 additions & 0 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ export {}

declare module '@vue/runtime-core' {
export interface GlobalComponents {
AButton: typeof import('ant-design-vue/es')['Button']
ACheckbox: typeof import('ant-design-vue/es')['Checkbox']
AForm: typeof import('ant-design-vue/es')['Form']
AFormItem: typeof import('ant-design-vue/es')['FormItem']
AInput: typeof import('ant-design-vue/es')['Input']
AInputPassword: typeof import('ant-design-vue/es')['InputPassword']
ALayout: typeof import('ant-design-vue/es')['Layout']
ALayoutSider: typeof import('ant-design-vue/es')['LayoutSider']
AMenu: typeof import('ant-design-vue/es')['Menu']
AMenuItem: typeof import('ant-design-vue/es')['MenuItem']
ASelect: typeof import('ant-design-vue/es')['Select']
NavDrawer: typeof import('./components/NavDrawer.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
Expand Down
9 changes: 7 additions & 2 deletions src/components/NavDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const { t } = useI18n()
const route = useRoute()
const menu = [{
const menu = computed(() => [{
icon: 'i-mdi:view-grid',
key: 'index',
tip: t('nav.plan'),
Expand All @@ -12,12 +12,17 @@ const menu = [{
key: 'time',
tip: t('nav.time'),
to: '/time',
}, {
icon: 'i-mdi:label',
key: 'label',
tip: t('nav.label'),
to: '/label',
}, {
icon: 'i-mdi:cog',
key: 'config',
tip: t('nav.config'),
to: '/config',
}]
}])
const name = computed(() => route.name as string)
</script>
Expand Down
5 changes: 2 additions & 3 deletions src/hooks/useConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ export function useConfig() {

async function init() {
const len = await store.length()
if (len != 0)
return
if (len == 0)
await create()

await create()
await read()
}

Expand Down
9 changes: 6 additions & 3 deletions src/locales/en-US.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
nav:
plan: plan
time: time
config: config
plan: Plan
time: Time
label: Label
config: Config
config:
locale: Language
3 changes: 3 additions & 0 deletions src/locales/zh-CN.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
nav:
plan: 计划
time: 计时
label: 标签
config: 设置
config:
locale: 语言
34 changes: 33 additions & 1 deletion src/pages/config.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
<script setup lang="ts">
import type { SelectProps } from 'ant-design-vue'
const { locale } = useI18n()
const config = useConfig()
watch(() => config.value.locale, v => locale.value = v)
const localeOptions: SelectProps['options'] = [
{
label: '简体中文',
value: 'zh-CN',
},
{
label: 'English (United States)',
value: 'en-US',
},
]
</script>

<template>
config
<a-form
:model="config"
layout="vertical"
>
<a-form-item
:label="$t('config.locale')"
>
<a-select
v-model:value="config.locale"
:options="localeOptions"
/>
</a-form-item>
</a-form>
</template>
3 changes: 3 additions & 0 deletions src/pages/label.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
label
</template>

0 comments on commit bcd76b2

Please sign in to comment.