* feat: 偏好设置按钮支持显示在用户下拉窗中的特性 * feat: 时区设置功能支持在偏好设置列表进行配置 * feat: 偏好设置按钮支持显示在用户下拉窗中的特性 - 完善示例代码 * feat: 时区设置功能支持在偏好设置列表进行配置 * feat: 时区设置功能支持在偏好设置列表进行配置-单元测试报错问题 * feat: 时区设置功能支持在偏好设置列表进行配置-修改代码QC问题 --------- Co-authored-by: PanFu <panfu@zhihuaai.com>
78 lines
2.2 KiB
Vue
78 lines
2.2 KiB
Vue
<script setup lang="ts">
|
||
import { onMounted, ref, unref } from 'vue';
|
||
|
||
import { SUPPORT_LANGUAGES } from '@vben/constants';
|
||
import { $t } from '@vben/locales';
|
||
import { useTimezoneStore } from '@vben/stores';
|
||
|
||
import InputItem from '../input-item.vue';
|
||
import SelectItem from '../select-item.vue';
|
||
import SwitchItem from '../switch-item.vue';
|
||
|
||
defineOptions({
|
||
name: 'PreferenceGeneralConfig',
|
||
});
|
||
|
||
const appLocale = defineModel<string>('appLocale');
|
||
const appTimezone = defineModel<string>('appTimezone');
|
||
const appDynamicTitle = defineModel<boolean>('appDynamicTitle');
|
||
const appWatermark = defineModel<boolean>('appWatermark');
|
||
const appWatermarkContent = defineModel<string>('appWatermarkContent');
|
||
const appEnableCheckUpdates = defineModel<boolean>('appEnableCheckUpdates');
|
||
const appEnableCopyPreferences = defineModel<boolean>(
|
||
'appEnableCopyPreferences',
|
||
);
|
||
const timezoneStore = useTimezoneStore();
|
||
|
||
const timezoneOptionsRef = ref<
|
||
{
|
||
label: string;
|
||
value: string;
|
||
}[]
|
||
>([]);
|
||
|
||
onMounted(async () => {
|
||
timezoneOptionsRef.value = await timezoneStore.getTimezoneOptions();
|
||
// 获取当前时区,例如:Asia/Shanghai
|
||
const timezoneValue = unref(timezoneStore.timezone);
|
||
if (timezoneValue) {
|
||
appTimezone.value = timezoneValue;
|
||
}
|
||
});
|
||
</script>
|
||
|
||
<template>
|
||
<SelectItem v-model="appLocale" :items="SUPPORT_LANGUAGES">
|
||
{{ $t('preferences.language') }}
|
||
</SelectItem>
|
||
<SelectItem v-model="appTimezone" :items="timezoneOptionsRef">
|
||
{{ $t('preferences.timezone') }}
|
||
</SelectItem>
|
||
<SwitchItem v-model="appDynamicTitle">
|
||
{{ $t('preferences.dynamicTitle') }}
|
||
</SwitchItem>
|
||
<SwitchItem
|
||
v-model="appWatermark"
|
||
@update:model-value="
|
||
(val) => {
|
||
if (!val) appWatermarkContent = '';
|
||
}
|
||
"
|
||
>
|
||
{{ $t('preferences.watermark') }}
|
||
</SwitchItem>
|
||
<InputItem
|
||
v-if="appWatermark"
|
||
v-model="appWatermarkContent"
|
||
:placeholder="$t('preferences.watermarkContent')"
|
||
>
|
||
{{ $t('preferences.watermarkContent') }}
|
||
</InputItem>
|
||
<SwitchItem v-model="appEnableCheckUpdates">
|
||
{{ $t('preferences.checkUpdates') }}
|
||
</SwitchItem>
|
||
<SwitchItem v-model="appEnableCopyPreferences">
|
||
{{ $t('preferences.enableCopyPreferences') }}
|
||
</SwitchItem>
|
||
</template>
|