diff --git a/public/personListTemplate-en.xlsx b/public/personListTemplate-en.xlsx new file mode 100644 index 0000000..3f45427 Binary files /dev/null and b/public/personListTemplate-en.xlsx differ diff --git a/public/readme-zh-cn.md b/public/readme-zhCn.md similarity index 100% rename from public/readme-zh-cn.md rename to public/readme-zhCn.md diff --git a/public/人口登记表-en.xlsx b/public/人口登记表-en.xlsx deleted file mode 100644 index 7e88377..0000000 Binary files a/public/人口登记表-en.xlsx and /dev/null differ diff --git a/src/components/DaiysuiTable/index.vue b/src/components/DaiysuiTable/index.vue index bbf3377..8d6f3ba 100644 --- a/src/components/DaiysuiTable/index.vue +++ b/src/components/DaiysuiTable/index.vue @@ -35,7 +35,7 @@ const actionsColumns = computed(() => { {{ item.label }} - 操作 + {{ $t('table.operation') }} @@ -56,7 +56,7 @@ const actionsColumns = computed(() => { - 暂无数据 + {{ $t('table.noneData') }} diff --git a/src/components/NumberSeparate/EditSeparateDialog.vue b/src/components/NumberSeparate/EditSeparateDialog.vue index 1791d6a..5da4b18 100644 --- a/src/components/NumberSeparate/EditSeparateDialog.vue +++ b/src/components/NumberSeparate/EditSeparateDialog.vue @@ -74,12 +74,12 @@ onMounted(() => { diff --git a/src/locales/en.ts b/src/locales/en.ts index 9ae88ef..67e7a15 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -51,9 +51,11 @@ export default { identity:'Identity', isLucky:'Is Lucky', operation:'Operation', + setLuckyNumber:'Set Lucky Number', luckyPeopleNumber:'Lucky People Number', detail:'Detail', + noneData:'No Data', // prize configuration fullParticipation:'FullParticipation', numberParticipants:'NumberParticipants', @@ -75,6 +77,7 @@ export default { highlightColor:'HighLight Color', patternSetting:'Pattern Setting', alwaysDisplay:'Always Display Prize List', + selectPicture:'Select a Picture' }, dialog:{ titleTip:'Tip!', @@ -103,7 +106,42 @@ export default { edit:'Edit', delete:'Delete' }, - + error:{ + require:'required field', + requireNumber:'please enter a number', + minNumber1:'the minimum is 1', + maxNumber100:'the maximum is 100', + uploadSuccess:'Upload Success', + uploadFail:'Upload Failed', + notImage:'Not Image', + personIsAllDone:'All Person Is Done', + personNotEnough:'Person Is Not Enough', + noInfoAndImport:'No Info and import it', + useDefault:'Use Default Data', + completeInformation:'Please provide complete information' + }, + placeHolder:{ + enterTitle:'Enter Title', + name:'Name', + winnerCount:'Lucky Person Count', + }, + data:{ + yes:'Yes', + no:'No', + number:'Number', + isWin:'isWin', + department:'Department', + name:'Name', + identity:'Identity', + prizeName:'Prize Name', + prizeTime:'Prize Time', + operation:'Operation', + delete:'Delete', + removePerson:'Remove the Person', + defaultTitle:'The Prelude to the Six Ministries of the Ming Dynasty Cabinet', + xlsxName:'personListTemplate-en.xlsx', + readmeName:'readme-en.md' + }, footer:{ 'self-reflection':'Turn inward and examine yourself when you encounter difficulties in life.', 'thiefEasy':'Thief difficult mountain thief easily, breaking heart.' diff --git a/src/locales/i18n.ts b/src/locales/i18n.ts index 101c8a1..7659795 100644 --- a/src/locales/i18n.ts +++ b/src/locales/i18n.ts @@ -7,18 +7,21 @@ export type Language='en'|'zhCn' export const languageList=[ { key:'zhCn', - name:'中文' + name:'中文', + flag:'zh-cn' }, { key:'en', - name:'English' + name:'English', + flag:'en-us' } ] +export const browserLanguage=navigator.language.toLowerCase().indexOf('zh')>=0?'zhCn':'en'; +const globalConfig=JSON.parse(localStorage.getItem('globalConfig')||'{}').globalConfig||{} // 创建i18n const i18n = createI18n({ - locale: JSON.parse(localStorage.getItem("globalConfig")?localStorage.getItem("globalConfig") as string:"{globalConfig:{language:'zhCn'}}").globalConfig.language || "zhCn", // 语言标识 + locale: globalConfig.language||browserLanguage, globalInjection: true, // 全局注入,可以直接使用$t - // 处理报错: Uncaught (in promise) SyntaxError: Not available in legacy mode (at message-compiler.esm-bundler.js:54:19) legacy:false, messages: { zhCn, diff --git a/src/locales/zhCn.ts b/src/locales/zhCn.ts index 7a31787..e5006ca 100644 --- a/src/locales/zhCn.ts +++ b/src/locales/zhCn.ts @@ -22,7 +22,9 @@ export default { reset: '重置', play: '播放', setLayout:'重设布局', - close:'关闭' + close:'关闭', + noInfoAndImport:'暂无人员信息,前往导入', + useDefault:'使用默认数据' }, sidebar:{ personConfiguration:'人员配置', @@ -51,9 +53,11 @@ export default { identity:'身份', isLucky:'是否中奖', operation:'操作', + setLuckyNumber:'设置中奖人数', luckyPeopleNumber:'中奖人数', detail:'详细信息', + noneData:'暂无数据', // prize configuration fullParticipation:'全员参加', numberParticipants:'抽奖人数', @@ -75,6 +79,7 @@ export default { highlightColor:'高亮颜色', patternSetting:'图案设置', alwaysDisplay:'常显奖项列表', + selectPicture:'选择一张图片' }, dialog:{ titleTip:'提示!', @@ -103,7 +108,41 @@ export default { edit:'编辑', delete:'删除' }, - + error:{ + require:'必填项', + requireNumber:'请输入数字', + minNumber1:'最小为1', + maxNumber100:'最大为100', + uploadSuccess:'上传成功', + uploadFail:'上传失败', + notImage:'不是图片', + personIsAllDone:'抽奖抽完了', + personNotEnough:'抽奖人数不足', + startDraw:'现在抽取{count}{leftover}人', + completeInformation:'请填写完整信息' + }, + placeHolder:{ + enterTitle:'输入标题', + name:'名称', + winnerCount:'中奖人数', + }, + data:{ + yes:'是', + no:'否', + number:'编号', + isWin:'是否中奖', + department:'部门', + name:'姓名', + identity:'身份', + prizeName:'获奖', + prizeTime:'获奖时间', + operation:'操作', + delete:'删除', + removePerson:'移入未中奖名单', + defaultTitle:'大明内阁六部御前奏对', + xlsxName:'人口登记表-zhCn.xlsx', + readmeName:'readme-zhCn.md' + }, footer:{ 'self-reflection':'行有不得,反求诸己', 'thiefEasy':'破山中贼易,破心中贼难' diff --git a/src/store/globalConfig.ts b/src/store/globalConfig.ts index 9a953e3..b6bcfe2 100644 --- a/src/store/globalConfig.ts +++ b/src/store/globalConfig.ts @@ -1,7 +1,7 @@ import { defineStore } from 'pinia'; import { defaultMusicList, defaultImageList, defaultPatternList } from './data' import { IMusic, IImage } from '@/types/storeType'; -import i18n,{Language} from '@/locales/i18n' +import i18n,{browserLanguage} from '@/locales/i18n' // import { IPrizeConfig } from '@/types/storeType'; export const useGlobalConfig = defineStore('global', { state() { @@ -9,8 +9,8 @@ export const useGlobalConfig = defineStore('global', { globalConfig: { rowCount: 17, isSHowPrizeList: true, - topTitle: '大明内阁六部御前奏对', - language:'zhCn', + topTitle: i18n.global.t('data.defaultTitle'), + language:browserLanguage, theme: { name: 'dracula', detail: { primary: '#0f5fd3' }, @@ -223,8 +223,8 @@ export const useGlobalConfig = defineStore('global', { this.globalConfig = { rowCount: 17, isSHowPrizeList: true, - topTitle: '大明内阁六部御前奏对', - language: 'zhCn', + topTitle: i18n.global.t('data.defaultTitle'), + language: browserLanguage, theme: { name: 'dracula', detail: { primary: '#0f5fd3' }, diff --git a/src/views/Config/Global/FaceConfig.vue b/src/views/Config/Global/FaceConfig.vue index 6e0f5da..e20336f 100644 --- a/src/views/Config/Global/FaceConfig.vue +++ b/src/views/Config/Global/FaceConfig.vue @@ -10,7 +10,7 @@ import 'vue3-colorpicker/style.css'; import { isRgbOrRgba, isHex } from '@/utils/color' import PatternSetting from './components/PatternSetting.vue' import {languageList} from '@/locales/i18n' -import {Language} from '@/locales/i18n' +import i18n from '@/locales/i18n' const globalConfig = useStore().globalConfig const personConfig = useStore().personConfig const prizeConfig= useStore().prizeConfig @@ -44,11 +44,11 @@ const formErr = ref({ const schema = zod.object({ rowCount: zod.number({ - required_error: '必填项', - invalid_type_error: '必须填入数字', + required_error: i18n.global.t('error.require'), + invalid_type_error: i18n.global.t('error.requireNumber'), }) - .min(1, '最小为1') - .max(100, '最大为100') + .min(1, i18n.global.t('error.minNumber1')) + .max(100, i18n.global.t('error.maxNumber100')) // 格式化 @@ -169,7 +169,7 @@ onMounted(() => {
-

全局配置

+

{{$t('viewTitle.globalSetting')}}

@@ -178,7 +178,7 @@ onMounted(() => {
{{$t('table.title')}}
-
diff --git a/src/views/Config/Global/ImageConfig.vue b/src/views/Config/Global/ImageConfig.vue index 968efa4..4674e17 100644 --- a/src/views/Config/Global/ImageConfig.vue +++ b/src/views/Config/Global/ImageConfig.vue @@ -69,13 +69,13 @@ watch(() => imgUploadToast.value, (val) => {