i18n: 参数管理新增多语言配置

This commit is contained in:
xlsea 2025-05-12 21:43:55 +08:00 committed by 马铃薯头
parent e7af01f084
commit 88467844be
6 changed files with 257 additions and 31 deletions

View File

@ -337,6 +337,87 @@ const local: App.I18n.Schema = {
},
addClient: 'Add Client',
editClient: 'Edit Client'
},
config: {
title: 'Config List',
configName: 'Config Name',
configKey: 'Config Key',
configValue: 'Config Value',
configType: 'Built-in',
remark: 'Remark',
createTime: 'Create Time',
refreshCache: 'Refresh Cache',
refreshCacheSuccess: 'Refresh cache successfully',
form: {
configId: {
required: 'Please enter Config ID',
invalid: 'Config ID cannot be empty'
},
configName: {
required: 'Please enter Config Name',
invalid: 'Config Name cannot be empty'
},
configKey: {
required: 'Please enter Config Key',
invalid: 'Config Key cannot be empty'
},
configValue: {
required: 'Please enter Config Value',
invalid: 'Config Value cannot be empty'
},
configType: {
required: 'Please select Built-in status',
invalid: 'Built-in status cannot be empty'
},
remark: {
required: 'Please enter Remark',
invalid: 'Remark cannot be empty'
}
},
addConfig: 'Add Config',
editConfig: 'Edit Config'
},
dept: {
title: 'Department List',
deptName: 'Department Name',
leader: 'Leader',
phone: 'Phone',
email: 'Email',
status: 'Status',
sort: 'Sort',
createTime: 'Create Time',
form: {
parentId: {
required: 'Please select Parent Department',
invalid: 'Parent Department cannot be empty'
},
deptName: {
required: 'Please enter Department Name',
invalid: 'Department Name cannot be empty'
},
leader: {
required: 'Please enter Leader',
invalid: 'Leader cannot be empty'
},
phone: {
required: 'Please enter Phone',
invalid: 'Phone cannot be empty'
},
email: {
required: 'Please enter Email',
invalid: 'Email cannot be empty'
},
status: {
required: 'Please select Status',
invalid: 'Status cannot be empty'
},
sort: {
required: 'Please enter Sort',
invalid: 'Sort cannot be empty'
}
},
addDept: 'Add Department',
editDept: 'Edit Department'
}
}
},

View File

@ -337,6 +337,87 @@ const local: App.I18n.Schema = {
},
addClient: '新增客户端',
editClient: '编辑客户端'
},
config: {
title: '参数配置列表',
configName: '参数名称',
configKey: '参数键名',
configValue: '参数键值',
configType: '是否内置',
remark: '备注',
createTime: '创建时间',
refreshCache: '刷新缓存',
refreshCacheSuccess: '刷新缓存成功',
form: {
configId: {
required: '请输入参数主键',
invalid: '参数主键不能为空'
},
configName: {
required: '请输入参数名称',
invalid: '参数名称不能为空'
},
configKey: {
required: '请输入参数键名',
invalid: '参数键名不能为空'
},
configValue: {
required: '请输入参数键值',
invalid: '参数键值不能为空'
},
configType: {
required: '请选择是否内置',
invalid: '是否内置不能为空'
},
remark: {
required: '请输入备注',
invalid: '备注不能为空'
}
},
addConfig: '新增参数配置',
editConfig: '编辑参数配置'
},
dept: {
title: '部门列表',
deptName: '部门名称',
leader: '负责人',
phone: '联系电话',
email: '邮箱',
status: '状态',
sort: '排序',
createTime: '创建时间',
form: {
parentId: {
required: '请选择上级部门',
invalid: '上级部门不能为空'
},
deptName: {
required: '请输入部门名称',
invalid: '部门名称不能为空'
},
leader: {
required: '请输入负责人',
invalid: '负责人不能为空'
},
phone: {
required: '请输入联系电话',
invalid: '联系电话不能为空'
},
email: {
required: '请输入邮箱',
invalid: '邮箱不能为空'
},
status: {
required: '请选择状态',
invalid: '状态不能为空'
},
sort: {
required: '请输入排序',
invalid: '排序不能为空'
}
},
addDept: '新增部门',
editDept: '编辑部门'
}
}
},

42
src/typings/app.d.ts vendored
View File

@ -532,6 +532,48 @@ declare namespace App {
addClient: string;
editClient: string;
};
config: {
title: string;
configName: string;
configKey: string;
configValue: string;
configType: string;
remark: string;
createTime: string;
refreshCache: string;
refreshCacheSuccess: string;
form: {
configId: FormMsg;
configName: FormMsg;
configKey: FormMsg;
configValue: FormMsg;
configType: FormMsg;
remark: FormMsg;
};
addConfig: string;
editConfig: string;
};
dept: {
title: string;
deptName: string;
leader: string;
phone: string;
email: string;
status: string;
sort: string;
createTime: string;
form: {
parentId: FormMsg;
deptName: FormMsg;
leader: FormMsg;
phone: FormMsg;
email: FormMsg;
status: FormMsg;
sort: FormMsg;
};
addDept: string;
editDept: string;
};
};
};
form: {

View File

@ -58,25 +58,25 @@ const {
},
{
key: 'configName',
title: '参数名称',
title: $t('page.system.config.configName'),
align: 'center',
minWidth: 120
},
{
key: 'configKey',
title: '参数键名',
title: $t('page.system.config.configKey'),
align: 'center',
minWidth: 120
},
{
key: 'configValue',
title: '参数键值',
title: $t('page.system.config.configValue'),
align: 'center',
minWidth: 120
},
{
key: 'configType',
title: '是否内置',
title: $t('page.system.config.configType'),
align: 'center',
minWidth: 120,
render(row) {
@ -85,7 +85,7 @@ const {
},
{
key: 'remark',
title: '备注',
title: $t('page.system.config.remark'),
align: 'center',
minWidth: 120,
ellipsis: {
@ -94,7 +94,7 @@ const {
},
{
key: 'createTime',
title: '创建时间',
title: $t('page.system.config.createTime'),
align: 'center',
minWidth: 120,
ellipsis: {
@ -185,7 +185,7 @@ async function handleExport() {
async function handleRefreshCache() {
const { error } = await fetchRefreshCache();
if (error) return;
window.$message?.success('刷新缓存成功');
window.$message?.success($t('page.system.config.refreshCacheSuccess'));
await getData();
}
</script>
@ -193,7 +193,7 @@ async function handleRefreshCache() {
<template>
<div class="min-h-500px flex-col-stretch gap-16px overflow-hidden lt-sm:overflow-auto">
<ConfigSearch v-model:model="searchParams" @reset="resetSearchParams" @search="getDataByPage" />
<NCard title="参数配置列表" :bordered="false" size="small" class="sm:flex-1-hidden card-wrapper">
<NCard :title="$t('page.system.config.title')" :bordered="false" size="small" class="sm:flex-1-hidden card-wrapper">
<template #header-extra>
<TableHeaderOperation
v-model:columns="columnChecks"
@ -212,7 +212,7 @@ async function handleRefreshCache() {
<template #icon>
<icon-material-symbols:sync-outline />
</template>
刷新缓存
{{ $t('page.system.config.refreshCache') }}
</NButton>
</template>
</TableHeaderOperation>

View File

@ -32,8 +32,8 @@ const { createRequiredRule } = useFormRules();
const title = computed(() => {
const titles: Record<NaiveUI.TableOperateType, string> = {
add: '新增参数配置',
edit: '编辑参数配置'
add: $t('page.system.config.addConfig'),
edit: $t('page.system.config.editConfig')
};
return titles[props.operateType];
});
@ -55,11 +55,11 @@ function createDefaultModel(): Model {
type RuleKey = Extract<keyof Model, 'configId' | 'configName' | 'configKey' | 'configValue' | 'configType'>;
const rules: Record<RuleKey, App.Global.FormRule> = {
configId: createRequiredRule('参数主键不能为空'),
configName: createRequiredRule('参数名称不能为空'),
configKey: createRequiredRule('参数键名不能为空'),
configValue: createRequiredRule('参数键值不能为空'),
configType: createRequiredRule('是否内置不能为空')
configId: createRequiredRule($t('page.system.config.form.configId.required')),
configName: createRequiredRule($t('page.system.config.form.configName.required')),
configKey: createRequiredRule($t('page.system.config.form.configKey.required')),
configValue: createRequiredRule($t('page.system.config.form.configValue.required')),
configType: createRequiredRule($t('page.system.config.form.configType.required'))
};
function handleUpdateModelWhenEdit() {
@ -110,20 +110,29 @@ watch(visible, () => {
<NDrawer v-model:show="visible" :title="title" display-directive="show" :width="800" class="max-w-90%">
<NDrawerContent :title="title" :native-scrollbar="false" closable>
<NForm ref="formRef" :model="model" :rules="rules">
<NFormItem label="参数名称" path="configName">
<NInput v-model:value="model.configName" placeholder="请输入参数名称" />
<NFormItem :label="$t('page.system.config.configName')" path="configName">
<NInput v-model:value="model.configName" :placeholder="$t('page.system.config.form.configName.required')" />
</NFormItem>
<NFormItem label="参数键名" path="configKey">
<NInput v-model:value="model.configKey" placeholder="请输入参数键名" />
<NFormItem :label="$t('page.system.config.configKey')" path="configKey">
<NInput v-model:value="model.configKey" :placeholder="$t('page.system.config.form.configKey.required')" />
</NFormItem>
<NFormItem label="参数键值" path="configValue">
<NInput v-model:value="model.configValue" :rows="3" placeholder="请输入参数键值" />
<NFormItem :label="$t('page.system.config.configValue')" path="configValue">
<NInput
v-model:value="model.configValue"
:rows="3"
:placeholder="$t('page.system.config.form.configValue.required')"
/>
</NFormItem>
<NFormItem label="是否内置" path="configType">
<NFormItem :label="$t('page.system.config.configType')" path="configType">
<DictRadio v-model:value="model.configType" dict-code="sys_yes_no" />
</NFormItem>
<NFormItem label="备注" path="remark">
<NInput v-model:value="model.remark" :rows="3" type="textarea" placeholder="请输入备注" />
<NFormItem :label="$t('page.system.config.remark')" path="remark">
<NInput
v-model:value="model.remark"
:rows="3"
type="textarea"
:placeholder="$t('page.system.config.form.remark.required')"
/>
</NFormItem>
</NForm>
<template #footer>

View File

@ -34,16 +34,29 @@ async function search() {
<NCollapseItem :title="$t('common.search')" name="user-search">
<NForm ref="formRef" :model="model" label-placement="left" :label-width="80">
<NGrid responsive="screen" item-responsive>
<NFormItemGi span="6 s:12 m:6" label="参数名称" path="configName" class="pr-24px">
<NInput v-model:value="model.configName" placeholder="请输入参数名称" />
<NFormItemGi
span="6 s:12 m:6"
:label="$t('page.system.config.configName')"
path="configName"
class="pr-24px"
>
<NInput
v-model:value="model.configName"
:placeholder="$t('page.system.config.form.configName.required')"
/>
</NFormItemGi>
<NFormItemGi span="6 s:12 m:6" label="参数键名" path="configKey" class="pr-24px">
<NInput v-model:value="model.configKey" placeholder="请输入参数键名" />
<NFormItemGi span="6 s:12 m:6" :label="$t('page.system.config.configKey')" path="configKey" class="pr-24px">
<NInput v-model:value="model.configKey" :placeholder="$t('page.system.config.form.configKey.required')" />
</NFormItemGi>
<NFormItemGi span="6 s:12 m:6" label="是否内置" path="configType" class="pr-24px">
<NFormItemGi
span="6 s:12 m:6"
:label="$t('page.system.config.configType')"
path="configType"
class="pr-24px"
>
<DictSelect
v-model:value="model.configType"
placeholder="请选择是否内置"
:placeholder="$t('page.system.config.form.configType.required')"
dict-code="sys_yes_no"
clearable
/>