diff --git a/web/src/i18n/pages/system/common/en.ts b/web/src/i18n/pages/system/common/en.ts new file mode 100644 index 0000000..bd9361f --- /dev/null +++ b/web/src/i18n/pages/system/common/en.ts @@ -0,0 +1,18 @@ +// Define content +export default { + message: { + pages: { + system: { + common: { + createTime: 'Created At', + updateTime: 'Updated At', + startTime: 'Start Time', + endTime: 'End Time', + lastWeek: 'Last Week', + lastMonth: 'Last Month', + lastThreeMonths: 'Last 3 Months', + }, + }, + }, + }, +}; diff --git a/web/src/i18n/pages/system/common/zh-cn.ts b/web/src/i18n/pages/system/common/zh-cn.ts new file mode 100644 index 0000000..cba10c4 --- /dev/null +++ b/web/src/i18n/pages/system/common/zh-cn.ts @@ -0,0 +1,18 @@ +// 定义内容 +export default { + message: { + pages: { + system: { + common: { + createTime: '创建时间', + updateTime: '更新时间', + startTime: '开始时间', + endTime: '结束时间', + lastWeek: '最近一周', + lastMonth: '最近一个月', + lastThreeMonths: '最近三个月', + }, + }, + }, + }, +}; diff --git a/web/src/i18n/pages/system/common/zh-tw.ts b/web/src/i18n/pages/system/common/zh-tw.ts new file mode 100644 index 0000000..c14245b --- /dev/null +++ b/web/src/i18n/pages/system/common/zh-tw.ts @@ -0,0 +1,18 @@ +// 定義內容 +export default { + message: { + pages: { + system: { + common: { + createTime: '創建時間', + updateTime: '更新時間', + startTime: '開始時間', + endTime: '結束時間', + lastWeek: '最近一週', + lastMonth: '最近一個月', + lastThreeMonths: '最近三個月', + }, + }, + }, + }, +}; diff --git a/web/src/utils/commonCrud.ts b/web/src/utils/commonCrud.ts index 9a3817b..492388b 100644 --- a/web/src/utils/commonCrud.ts +++ b/web/src/utils/commonCrud.ts @@ -48,8 +48,9 @@ function mergeOptions(baseOptions: Required, userOptions: CrudOptio /** * 最终暴露的 commonCrudConfig * @param options 用户自定义配置(可传可不传,不传就用默认) + * @param t i18n t 函数(用于翻译占位符和快捷选项文本) */ -export const commonCrudConfig = (options: CrudOptions = {}) => { +export const commonCrudConfig = (options: CrudOptions = {}, t?: (key: string) => string) => { // ① 合并 const merged = mergeOptions(defaultOptions, options); @@ -152,7 +153,7 @@ export const commonCrudConfig = (options: CrudOptions = {}) => { }, update_datetime: { - title: '更新时间', + title: t ? t('message.pages.system.common.updateTime') : '更新时间', type: 'datetime', search: { show: merged.update_datetime.search, @@ -160,13 +161,13 @@ export const commonCrudConfig = (options: CrudOptions = {}) => { component: { type: 'datetimerange', props: { - 'start-placeholder': '开始时间', - 'end-placeholder': '结束时间', + 'start-placeholder': t ? t('message.pages.system.common.startTime') : '开始时间', + 'end-placeholder': t ? t('message.pages.system.common.endTime') : '结束时间', 'value-format': 'YYYY-MM-DD HH:mm:ss', 'picker-options': { shortcuts: [ { - text: '最近一周', + text: t ? t('message.pages.system.common.lastWeek') : '最近一周', onClick(picker: any) { const end = new Date(); const start = new Date(); @@ -175,7 +176,7 @@ export const commonCrudConfig = (options: CrudOptions = {}) => { }, }, { - text: '最近一个月', + text: t ? t('message.pages.system.common.lastMonth') : '最近一个月', onClick(picker: any) { const end = new Date(); const start = new Date(); @@ -184,7 +185,7 @@ export const commonCrudConfig = (options: CrudOptions = {}) => { }, }, { - text: '最近三个月', + text: t ? t('message.pages.system.common.lastThreeMonths') : '最近三个月', onClick(picker: any) { const end = new Date(); const start = new Date(); @@ -218,7 +219,7 @@ export const commonCrudConfig = (options: CrudOptions = {}) => { }, create_datetime: { - title: '创建时间', + title: t ? t('message.pages.system.common.createTime') : '创建时间', type: 'datetime', search: { show: merged.create_datetime.search, @@ -226,13 +227,13 @@ export const commonCrudConfig = (options: CrudOptions = {}) => { component: { type: 'datetimerange', props: { - 'start-placeholder': '开始时间', - 'end-placeholder': '结束时间', + 'start-placeholder': t ? t('message.pages.system.common.startTime') : '开始时间', + 'end-placeholder': t ? t('message.pages.system.common.endTime') : '结束时间', 'value-format': 'YYYY-MM-DD HH:mm:ss', 'picker-options': { shortcuts: [ { - text: '最近一周', + text: t ? t('message.pages.system.common.lastWeek') : '最近一周', onClick(picker: any) { const end = new Date(); const start = new Date(); @@ -241,7 +242,7 @@ export const commonCrudConfig = (options: CrudOptions = {}) => { }, }, { - text: '最近一个月', + text: t ? t('message.pages.system.common.lastMonth') : '最近一个月', onClick(picker: any) { const end = new Date(); const start = new Date(); @@ -250,7 +251,7 @@ export const commonCrudConfig = (options: CrudOptions = {}) => { }, }, { - text: '最近三个月', + text: t ? t('message.pages.system.common.lastThreeMonths') : '最近三个月', onClick(picker: any) { const end = new Date(); const start = new Date(); diff --git a/web/src/views/system/log/loginLog/crud.tsx b/web/src/views/system/log/loginLog/crud.tsx index a3fd92c..437af15 100644 --- a/web/src/views/system/log/loginLog/crud.tsx +++ b/web/src/views/system/log/loginLog/crud.tsx @@ -1,8 +1,10 @@ import * as api from './api'; import { UserPageQuery, AddReq, DelReq, EditReq, CreateCrudOptionsProps, CreateCrudOptionsRet, dict } from '@fast-crud/fast-crud'; +import { useI18n } from 'vue-i18n'; import {commonCrudConfig} from "/@/utils/commonCrud"; export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet { + const { t } = useI18n() const pageRequest = async (query: UserPageQuery) => { return await api.GetList(query); }; @@ -48,7 +50,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, columns: { _index: { - title: '序号', + title: t('message.pages.loginLog.table.columns.index'), form: { show: false }, column: { //type: 'index', @@ -64,7 +66,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, }, search: { - title: '关键词', + title: t('message.pages.loginLog.table.columns.keyword'), column: { show: false, }, @@ -74,7 +76,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp props: { clearable: true, }, - placeholder: '请输入关键词', + placeholder: t('message.pages.loginLog.form.keywordPlaceholder'), }, }, form: { @@ -87,7 +89,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, }, username: { - title: '登录用户名', + title: t('message.pages.loginLog.table.columns.username'), search: { disabled: false, }, @@ -98,12 +100,12 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp form: { disabled: true, component: { - placeholder: '请输入登录用户名', + placeholder: t('message.pages.loginLog.form.usernamePlaceholder'), }, }, }, ip: { - title: '登录ip', + title: t('message.pages.loginLog.table.columns.ip'), search: { disabled: false, }, @@ -114,12 +116,12 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp form: { disabled: true, component: { - placeholder: '请输入登录ip', + placeholder: t('message.pages.loginLog.form.ipPlaceholder'), }, }, }, isp: { - title: '运营商', + title: t('message.pages.loginLog.table.columns.isp'), search: { disabled: true, }, @@ -130,12 +132,12 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, form: { component: { - placeholder: '请输入运营商', + placeholder: t('message.pages.loginLog.form.ispPlaceholder'), }, }, }, continent: { - title: '大州', + title: t('message.pages.loginLog.table.columns.continent'), type: 'input', column:{ minWidth: 90, @@ -143,52 +145,52 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp form: { disabled: true, component: { - placeholder: '请输入大州', + placeholder: t('message.pages.loginLog.form.continentPlaceholder'), }, }, component: { props: { color: 'auto' } }, // 自动染色 }, country: { - title: '国家', + title: t('message.pages.loginLog.table.columns.country'), type: 'input', column:{ minWidth: 90, }, form: { component: { - placeholder: '请输入国家', + placeholder: t('message.pages.loginLog.form.countryPlaceholder'), }, }, component: { props: { color: 'auto' } }, // 自动染色 }, province: { - title: '省份', + title: t('message.pages.loginLog.table.columns.province'), type: 'input', column:{ minWidth: 80, }, form: { component: { - placeholder: '请输入省份', + placeholder: t('message.pages.loginLog.form.provincePlaceholder'), }, }, component: { props: { color: 'auto' } }, // 自动染色 }, city: { - title: '城市', + title: t('message.pages.loginLog.table.columns.city'), type: 'input', column:{ minWidth: 80, }, form: { component: { - placeholder: '请输入城市', + placeholder: t('message.pages.loginLog.form.cityPlaceholder'), }, }, component: { props: { color: 'auto' } }, // 自动染色 }, district: { - title: '县区', + title: t('message.pages.loginLog.table.columns.district'), key: '', type: 'input', column:{ @@ -196,52 +198,52 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, form: { component: { - placeholder: '请输入县区', + placeholder: t('message.pages.loginLog.form.districtPlaceholder'), }, }, component: { props: { color: 'auto' } }, // 自动染色 }, area_code: { - title: '区域代码', + title: t('message.pages.loginLog.table.columns.areaCode'), type: 'input', column:{ minWidth: 90, }, form: { component: { - placeholder: '请输入区域代码', + placeholder: t('message.pages.loginLog.form.areaCodePlaceholder'), }, }, component: { props: { color: 'auto' } }, // 自动染色 }, country_english: { - title: '英文全称', + title: t('message.pages.loginLog.table.columns.countryEnglish'), type: 'input', column:{ minWidth: 120, }, form: { component: { - placeholder: '请输入英文全称', + placeholder: t('message.pages.loginLog.form.countryEnglishPlaceholder'), }, }, component: { props: { color: 'auto' } }, // 自动染色 }, country_code: { - title: '简称', + title: t('message.pages.loginLog.table.columns.countryCode'), type: 'input', column:{ minWidth: 100, }, form: { component: { - placeholder: '请输入简称', + placeholder: t('message.pages.loginLog.form.countryCodePlaceholder'), }, }, component: { props: { color: 'auto' } }, // 自动染色 }, longitude: { - title: '经度', + title: t('message.pages.loginLog.table.columns.longitude'), type: 'input', disabled: true, column:{ @@ -249,13 +251,13 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, form: { component: { - placeholder: '请输入经度', + placeholder: t('message.pages.loginLog.form.longitudePlaceholder'), }, }, component: { props: { color: 'auto' } }, // 自动染色 }, latitude: { - title: '纬度', + title: t('message.pages.loginLog.table.columns.latitude'), type: 'input', disabled: true, column:{ @@ -263,21 +265,21 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, form: { component: { - placeholder: '请输入纬度', + placeholder: t('message.pages.loginLog.form.latitudePlaceholder'), }, }, component: { props: { color: 'auto' } }, // 自动染色 }, login_type: { - title: '登录类型', + title: t('message.pages.loginLog.table.columns.loginType'), type: 'dict-select', search: { disabled: false, }, dict: dict({ data: [ - { label: '普通登录', value: 1 }, - { label: '微信扫码登录', value: 2 }, + { label: t('message.pages.loginLog.loginType.normal'), value: 1 }, + { label: t('message.pages.loginLog.loginType.wechat'), value: 2 }, ], }), column:{ @@ -285,36 +287,36 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, form: { component: { - placeholder: '请选择登录类型', + placeholder: t('message.pages.loginLog.form.loginTypePlaceholder'), }, }, }, os: { - title: '操作系统', + title: t('message.pages.loginLog.table.columns.os'), type: 'input', column:{ minWidth: 120, }, form: { component: { - placeholder: '请输入操作系统', + placeholder: t('message.pages.loginLog.form.osPlaceholder'), }, }, }, browser: { - title: '浏览器名', + title: t('message.pages.loginLog.table.columns.browser'), type: 'input', column:{ minWidth: 120, }, form: { component: { - placeholder: '请输入浏览器名', + placeholder: t('message.pages.loginLog.form.browserPlaceholder'), }, }, }, agent: { - title: 'agent信息', + title: t('message.pages.loginLog.table.columns.agent'), disabled: true, type: 'input', column:{ @@ -322,7 +324,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp }, form: { component: { - placeholder: '请输入agent信息', + placeholder: t('message.pages.loginLog.form.agentPlaceholder'), }, }, }, @@ -330,7 +332,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp create_datetime: { search: true } - }) + }, t) }, }, };