From d2143a0c2ea351d8e8269054edd77f16d1162195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E7=BA=B8=E5=BF=98=E5=BF=A7?= Date: Wed, 9 Aug 2023 21:31:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .prettierrc.json | 3 +- src/components/custom-header.vue | 44 ++++----------------- src/locales/en/activate.ts | 42 ++++++++++++++++++++ src/locales/en/main.ts | 12 ++---- src/views/activation.vue | 4 +- src/views/activation/office.vue | 52 +++++++++++-------------- src/views/activation/windows-server.vue | 40 ++++++++----------- src/views/activation/windows.vue | 40 ++++++++----------- 8 files changed, 113 insertions(+), 124 deletions(-) create mode 100644 src/locales/en/activate.ts diff --git a/.prettierrc.json b/.prettierrc.json index b46cbc8c..004eaa81 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -2,6 +2,5 @@ "arrowParens": "avoid", "printWidth": 120, "semi": false, - "singleQuote": true, - "trailingComma": "none" + "singleQuote": true } diff --git a/src/components/custom-header.vue b/src/components/custom-header.vue index 718070cf..01a6ad05 100644 --- a/src/components/custom-header.vue +++ b/src/components/custom-header.vue @@ -5,96 +5,66 @@ const { t } = useI18n() const appStore = useAppStore() -/** 导航选项 */ const navItems = computed(() => [ - { - name: 'home', - label: t('app.nav.home'), - icon: 'i-mdi:home' - }, { name: 'activation', - label: t('app.nav.activate'), + label: t('main.module.activate'), icon: 'i-mdi:microsoft-windows' }, { name: 'detection', - label: t('app.nav.check'), + label: t('main.module.tools'), icon: 'i-mdi:check-network' - }, - { - name: 'download', - label: t('app.nav.download'), - icon: 'i-mdi:folder-download' - }, - { - name: 'guide', - label: t('app.nav.guide'), - icon: 'i-mdi:document' - }, - { - name: 'monitor', - label: t('app.nav.monitor'), - icon: 'i-mdi:monitor-dashboard' } ]) -/** 路由 */ const router = useRouter() -/** 跳转页面 */ const redirectPage = (name: string) => { router.push({ path: name === 'home' ? '/' : '/' + name }) } -/** 路径解析 */ const pathName = location.pathname.match(/\b\w+\b/g) -/** 导航选中项 */ const navSelected = ref([!pathName?.[0] ? 'home' : pathName?.[0]]) -/** 主题选项 */ const themeItems = computed(() => [ { - lable: t('app.theme.auto'), + lable: t('main.theme.auto'), value: 'auto', icon: 'i-ic:round-brightness-auto' }, { - lable: t('app.theme.dark'), + lable: t('main.theme.dark'), value: 'dark', icon: 'i-ic:round-dark-mode' }, { - lable: t('app.theme.light'), + lable: t('main.theme.light'), value: 'light', icon: 'i-ic:round-light-mode' } ]) -/** 主题图标 */ const themeIcon = computed(() => { return themeItems.value.find(item => item.value === appStore.theme)?.icon }) -/** 切换主题 */ const themeChange = val => (appStore.theme = val) -/** 语言选项 */ const languagesItems = computed(() => [ { - lable: t('app.languages.zh-cn'), + lable: t('main.languages.zh-cn'), value: 'zh-cn', icon: 'i-flag:cn-4x3' }, { - lable: t('app.languages.en-us'), + lable: t('main.languages.en-us'), value: 'en-us', icon: 'i-flag:us-4x3' } ]) -/** 切换语言 */ const languagesChange = val => (appStore.languages = val) diff --git a/src/locales/en/activate.ts b/src/locales/en/activate.ts new file mode 100644 index 00000000..1c181b86 --- /dev/null +++ b/src/locales/en/activate.ts @@ -0,0 +1,42 @@ +export default { + button: { + copy: 'Copy Script', + create: 'Create Script', + download: 'Download Script', + }, + form: { + label: { + edition: 'Edition', + cpuarch: 'CPU Arch', + license: 'License Key', + product: 'Product', + service: 'KMS Server', + version: 'Version', + }, + placeholder: { + edition: 'Please select edition', + product: 'Please select product', + service: 'Please select kms server', + version: 'Please select version', + }, + }, + message: { + error: 'Copy Failed', + success: 'Copy Success', + }, + radio: { + x64: 'x64', + x86: 'x86', + }, + sider: { + system: 'System', + software: 'Software', + }, + table: { + columns: { + edition: 'Edition', + license: 'License Key', + product: 'Product', + }, + }, +} diff --git a/src/locales/en/main.ts b/src/locales/en/main.ts index 1ed921ba..a2f2f2af 100644 --- a/src/locales/en/main.ts +++ b/src/locales/en/main.ts @@ -1,12 +1,8 @@ export default { author: 'ikxin', - nav: { + module: { activate: 'Activate', - check: 'Check', - download: 'Download', - guide: 'Guide', - home: 'Home', - monitor: 'Monitor' + tools: 'Tools' }, theme: { auto: 'Auto Mode', @@ -14,7 +10,7 @@ export default { light: 'Light Mode' }, languages: { - 'en-us': 'English', - 'zh-cn': 'Simplified Chinese' + en: 'English', + zhCn: 'Simplified Chinese' } } diff --git a/src/views/activation.vue b/src/views/activation.vue index 47b84270..146e9335 100644 --- a/src/views/activation.vue +++ b/src/views/activation.vue @@ -21,7 +21,7 @@ const selectedKeys = ref(pathName) - + Windows @@ -36,7 +36,7 @@ const selectedKeys = ref(pathName) - + Office diff --git a/src/views/activation/office.vue b/src/views/activation/office.vue index 1f9550c4..7d1c71d1 100644 --- a/src/views/activation/office.vue +++ b/src/views/activation/office.vue @@ -5,38 +5,35 @@ import { useScript } from '@/composables/useScript' const { t } = useI18n() -/** 表单数据 */ const formData = reactive({ version: '', product: '', - is64bus: false, + cpuarch: false, service: 'kms.moeclub.org', - license: '' + license: '', }) watchEffect(() => (formData.license = formData.product)) -/** 表单校验规则 */ const formRules = computed((): Record => { return { version: { required: true, - message: t('activate.office.form-item.version.placeholder') + message: t('activate.form.placeholder.version'), }, product: { required: true, - message: t('activate.office.form-item.product.placeholder') + message: t('activate.form.placeholder.product'), }, service: { required: true, - message: t('activate.office.form-item.service.placeholder') - } + message: t('activate.form.placeholder.service'), + }, } }) -/** 激活脚本 */ const activateScript = computed(() => { - const path = formData.is64bus + const path = formData.cpuarch ? 'cd C:\\Program Files\\Microsoft Office\\Office16' : 'cd C:\\Program Files (x86)\\Microsoft Office\\Office16' const fix = `cscript ospp.vbs /inpkey:${formData.license}` @@ -44,17 +41,14 @@ const activateScript = computed(() => { return `${path}\r\n${fix}\r\n${activate}` }) -/** 激活脚本显示 */ const activateScriptVisible = ref(false) -/** 表单提交 */ const handleSubmit = data => { if (data.errors === undefined) { activateScriptVisible.value = true } } -/** 表格数据 */ const tableData = computed(() => { if (!gvlks[formData.version]) return [] return gvlks[formData.version]?.product.map(item => { @@ -64,9 +58,9 @@ const tableData = computed(() => { const tableColumns = computed( (): Array => [ - { title: t('activate.office.table.columns.product'), dataIndex: 'product' }, - { title: t('activate.office.table.columns.license'), dataIndex: 'license' } - ] + { title: t('activate.table.columns.product'), dataIndex: 'product' }, + { title: t('activate.table.columns.license'), dataIndex: 'license' }, + ], ) const { useScriptDownload, useScriptCopy } = useScript() @@ -80,13 +74,13 @@ const copyScript = () => useScriptCopy(activateScript.value)
- - + + - - + + useScriptCopy(activateScript.value) /> - - - {{ t('activate.office.form-item.is64bus.radio.x86') }} - {{ t('activate.office.form-item.is64bus.radio.x64') }} + + + {{ t('activate.radio.x86') }} + {{ t('activate.radio.x64') }} - + - + - {{ t('activate.button.create-script') }} + {{ t('activate.button.create') }} diff --git a/src/views/activation/windows-server.vue b/src/views/activation/windows-server.vue index b0cb3357..dc6a3c1f 100644 --- a/src/views/activation/windows-server.vue +++ b/src/views/activation/windows-server.vue @@ -5,50 +5,44 @@ import { useScript } from '@/composables/useScript' const { t } = useI18n() -/** 表单数据 */ const formData = reactive({ version: '', edition: '', service: 'kms.moeclub.org', - license: '' + license: '', }) watchEffect(() => (formData.license = formData.edition)) -/** 表单校验规则 */ const formRules = computed((): Record => { return { version: { required: true, - message: t('activate.windows.form-item.version.placeholder') + message: t('activate.form.placeholder.version'), }, edition: { required: true, - message: t('activate.windows.form-item.edition.placeholder') + message: t('activate.form.placeholder.edition'), }, service: { required: true, - message: t('activate.windows.form-item.service.placeholder') - } + message: t('activate.form.placeholder.service'), + }, } }) -/** 激活脚本 */ const activateScript = computed(() => { return `@echo off\r\nslmgr /skms ${formData.service}\r\nslmgr /ipk ${formData.license}\r\nslmgr /ato\r\nslmgr /xpr` }) -/** 激活脚本显示 */ const activateScriptVisible = ref(false) -/** 表单提交 */ const handleSubmit = data => { if (data.errors === undefined) { activateScriptVisible.value = true } } -/** 表格数据 */ const tableData = computed(() => { if (!gvlks[formData.version]) return [] return gvlks[formData.version]?.edition.map(item => { @@ -58,9 +52,9 @@ const tableData = computed(() => { const tableColumns = computed( (): Array => [ - { title: t('activate.windows.table.columns.edition'), dataIndex: 'edition' }, - { title: t('activate.windows.table.columns.license'), dataIndex: 'license' } - ] + { title: t('activate.table.columns.edition'), dataIndex: 'edition' }, + { title: t('activate.table.columns.license'), dataIndex: 'license' }, + ], ) const { useScriptDownload, useScriptCopy } = useScript() @@ -74,13 +68,13 @@ const copyScript = () => useScriptCopy(activateScript.value)
- - + + - - + + useScriptCopy(activateScript.value) /> - + - + - {{ t('activate.button.create-script') }} + {{ t('activate.button.create') }} diff --git a/src/views/activation/windows.vue b/src/views/activation/windows.vue index d40d0fe4..83fca198 100644 --- a/src/views/activation/windows.vue +++ b/src/views/activation/windows.vue @@ -5,50 +5,44 @@ import { useScript } from '@/composables/useScript' const { t } = useI18n() -/** 表单数据 */ const formData = reactive({ version: '', edition: '', service: 'kms.moeclub.org', - license: '' + license: '', }) watchEffect(() => (formData.license = formData.edition)) -/** 表单校验规则 */ const formRules = computed((): Record => { return { version: { required: true, - message: t('activate.windows.form-item.version.placeholder') + message: t('activate.form.placeholder.version'), }, edition: { required: true, - message: t('activate.windows.form-item.edition.placeholder') + message: t('activate.form.placeholder.edition'), }, service: { required: true, - message: t('activate.windows.form-item.service.placeholder') - } + message: t('activate.form.placeholder.service'), + }, } }) -/** 激活脚本 */ const activateScript = computed(() => { return `@echo off\r\nslmgr /skms ${formData.service}\r\nslmgr /ipk ${formData.license}\r\nslmgr /ato\r\nslmgr /xpr` }) -/** 激活脚本显示 */ const activateScriptVisible = ref(false) -/** 表单提交 */ const handleSubmit = data => { if (data.errors === undefined) { activateScriptVisible.value = true } } -/** 表格数据 */ const tableData = computed(() => { if (!gvlks[formData.version]) return [] return gvlks[formData.version]?.edition.map(item => { @@ -58,9 +52,9 @@ const tableData = computed(() => { const tableColumns = computed( (): Array => [ - { title: t('activate.windows.table.columns.edition'), dataIndex: 'edition' }, - { title: t('activate.windows.table.columns.license'), dataIndex: 'license' } - ] + { title: t('activate.table.columns.edition'), dataIndex: 'edition' }, + { title: t('activate.table.columns.license'), dataIndex: 'license' }, + ], ) const { useScriptDownload, useScriptCopy } = useScript() @@ -74,13 +68,13 @@ const copyScript = () => useScriptCopy(activateScript.value)
- - + + - - + + useScriptCopy(activateScript.value) /> - + - + - {{ t('activate.button.create-script') }} + {{ t('activate.button.create') }}