Skip to content

Commit

Permalink
refactor: windows activate component
Browse files Browse the repository at this point in the history
  • Loading branch information
ikxin committed Aug 22, 2024
1 parent 07c6815 commit 0f91b07
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 132 deletions.
102 changes: 102 additions & 0 deletions src/assets/gvlks/windows.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
[
{
"version": "Windows 11",
"edition": [
["W269N-WFGWX-YVC9B-4J6C9-T83GX", "Windows 11 Pro"],
["MH37W-N47XK-V7XM9-C7227-GCQG9", "Windows 11 Pro N"],
["NRG8B-VKK3Q-CXVCJ-9G2XF-6Q84J", "Windows 11 Pro for Workstations"],
["9FNHH-K3HBT-3W4TD-6383H-6XYWF", "Windows 11 Pro for Workstations N"],
["6TP4R-GNPTD-KYYHQ-7B7DP-J447Y", "Windows 11 Pro Education"],
["YVWGF-BXNMC-HTQYQ-CPQ99-66QFC", "Windows 11 Pro Education N"],
["NW6C2-QMPVW-D7KKK-3GKT6-VCFB2", "Windows 11 Education"],
["2WH4N-8QGBV-H22JP-CT43Q-MDWWJ", "Windows 11 Education N"],
["NPPR9-FWDCX-D2C8J-H872K-2YT43", "Windows 11 Enterprise"],
["DPH2V-TTNVB-4X9Q3-TJR4H-KHJW4", "Windows 11 Enterprise N"],
["YYVX9-NTFWV-6MDM3-9PT4T-4M68B", "Windows 11 Enterprise G"],
["44RPN-FTY23-9VTTB-MP9BX-T84FV", "Windows 11 Enterprise G N"]
]
},
{
"version": "Windows 10",
"edition": [
["W269N-WFGWX-YVC9B-4J6C9-T83GX", "Windows 10 Pro"],
["MH37W-N47XK-V7XM9-C7227-GCQG9", "Windows 10 Pro N"],
["NRG8B-VKK3Q-CXVCJ-9G2XF-6Q84J", "Windows 10 Pro for Workstations"],
["9FNHH-K3HBT-3W4TD-6383H-6XYWF", "Windows 10 Pro for Workstations N"],
["6TP4R-GNPTD-KYYHQ-7B7DP-J447Y", "Windows 10 Pro Education"],
["YVWGF-BXNMC-HTQYQ-CPQ99-66QFC", "Windows 10 Pro Education N"],
["NW6C2-QMPVW-D7KKK-3GKT6-VCFB2", "Windows 10 Education"],
["2WH4N-8QGBV-H22JP-CT43Q-MDWWJ", "Windows 10 Education N"],
["NPPR9-FWDCX-D2C8J-H872K-2YT43", "Windows 10 Enterprise"],
["DPH2V-TTNVB-4X9Q3-TJR4H-KHJW4", "Windows 10 Enterprise N"],
["YYVX9-NTFWV-6MDM3-9PT4T-4M68B", "Windows 10 Enterprise G"],
["44RPN-FTY23-9VTTB-MP9BX-T84FV", "Windows 10 Enterprise G N"]
]
},
{
"version": "Windows 10 LTSC 2021",
"edition": [
["M7XTQ-FN8P6-TTKYV-9D4CC-J462D", "Windows 10 Enterprise LTSC 2021"],
["92NFX-8DJQP-P6BBQ-THF9C-7CG2H", "Windows 10 Enterprise N LTSC 2021"]
]
},
{
"version": "Windows 10 LTSC 2019",
"edition": [
["M7XTQ-FN8P6-TTKYV-9D4CC-J462D", "Windows 10 Enterprise LTSC 2019"],
["92NFX-8DJQP-P6BBQ-THF9C-7CG2H", "Windows 10 Enterprise N LTSC 2019"]
]
},
{
"version": "Windows 10 LTSB 2016",
"edition": [
["DCPHK-NFMTC-H88MJ-PFHPY-QJ4BJ", "Windows 10 Enterprise LTSB 2016"],
["QFFDN-GRT3P-VKWWX-X7T3R-8B639", "Windows 10 Enterprise N LTSB 2016"]
]
},
{
"version": "Windows 10 LTSB 2015",
"edition": [
["WNMTR-4C88C-JK8YV-HQ7T2-76DF9", "Windows 10 Enterprise 2015 LTSB"],
["2F77B-TNFGY-69QQF-B8YKP-D69TJ", "Windows 10 Enterprise 2015 LTSB N"]
]
},
{
"version": "Windows 8.1",
"edition": [
["GCRJD-8NW9H-F2CDX-CCM8D-9D6T9", "Windows 8.1 Pro"],
["HMCNV-VVBFX-7HMBH-CTY9B-B4FXY", "Windows 8.1 Pro N"],
["MHF9N-XY6XB-WVXMC-BTDCT-MKKG7", "Windows 8.1 Enterprise"],
["TT4HM-HN7YT-62K67-RGRQJ-JFFXW", "Windows 8.1 Enterprise N"]
]
},
{
"version": "Windows 8",
"edition": [
["NG4HW-VH26C-733KW-K6F98-J8CK4", "Windows 8 Pro"],
["XCVCF-2NXM9-723PB-MHCB7-2RYQQ", "Windows 8 Pro N"],
["32JNW-9KQ84-P47T8-D8GGY-CWCK7", "Windows 8 Enterprise"],
["JMNMF-RHW7P-DMY6X-RF3DR-X2BQT", "Windows 8 Enterprise N"]
]
},
{
"version": "Windows 7",
"edition": [
["FJ82H-XT6CR-J8D7P-XQJJ2-GPDD4", "Windows 7 Professional"],
["MRPKT-YTG23-K7D7T-X2JMM-QY7MG", "Windows 7 Professional N"],
["W82YF-2Q76Y-63HXB-FGJG9-GF7QX", "Windows 7 Professional E"],
["33PXH-7Y6KF-2VJC9-XBBR8-HVTHH", "Windows 7 Enterprise"],
["YDRBP-3D83W-TY26F-D46B2-XCKRJ", "Windows 7 Enterprise N"],
["C29WB-22CC8-VJ326-GHFJW-H9DH4", "Windows 7 Enterprise E"]
]
},
{
"version": "Windows Vista",
"edition": [
["YFKBB-PQJJV-G996G-VWGXY-2V3X8", "Windows Vista Business"],
["HMBQG-8H2RH-C77VX-27R82-VMQBT", "Windows Vista Business N"],
["VKK3X-68KWM-X2YGT-QR4M6-4BWMV", "Windows Vista Enterprise"],
["VTC42-BM838-43QHV-84HX6-XJXKV", "Windows Vista Enterprise N"]
]
}
]
104 changes: 104 additions & 0 deletions src/components/common-activate.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<script lang="ts" setup>
import { useMonitorStore } from '@/store/monitor'
const props = defineProps<{
editionData: EditionItem[]
title: string
generateScript: (host: string, license: string, arch?: string) => string
}>()
const { t } = useI18n()
const { title, editionData } = props
const monitorStore = useMonitorStore()
const { monitors } = monitorStore
const formData = ref({
edition: editionData[0].edition[0][1],
arch: '',
host: monitors[0].host,
gvlk: '',
})
watchEffect(() => {
for (const item of editionData) {
for (const [token, name] of item.edition) {
if (name === formData.value.edition) {
formData.value.gvlk = token
}
}
}
})
const content = computed(() => {
return props.generateScript(formData.value.host, formData.value.gvlk)
})
const file = computed(() => {
return new File([content.value], 'kms.bat', { type: 'application/txt' })
})
const fileUrl = useObjectUrl(file)
const { copy, copied } = useClipboard({
source: content,
legacy: true,
})
</script>

<template>
<div class="flex flex-col gap-4">
<ACard>
<template #title>
<div class="flex items-center gap-2">
<i :class="`i-icons:${title.toLowerCase()}`" />
<span>{{ title }}</span>
</div>
</template>
<AForm :model="formData" auto-label-width>
<AFormItem :label="t('label.version')" field="edition" required>
<ASelect v-model="formData.edition">
<template v-for="item in editionData" :key="item.version">
<AOptgroup :label="item.version">
<template v-for="edition in item.edition" :key="edition[1]">
<AOption :label="edition[1]" />
</template>
</AOptgroup>
</template>
</ASelect>
</AFormItem>
<AFormItem :label="t('label.service')" field="host" required>
<ASelect v-model="formData.host">
<template v-for="item in monitors" :key="item.id">
<AOption :label="item.host" />
</template>
</ASelect>
</AFormItem>
<AFormItem :label="t('label.license')" field="gvlk" required>
<AInput v-model="formData.gvlk" disabled />
</AFormItem>
<AFormItem label="CMD Script">
<ATextarea v-model="content" auto-size />
</AFormItem>
<AFormItem>
<ASpace size="small">
<a :href="fileUrl" :download="file.name">
<AButton type="primary">
{{ t('button.download-script') }}
</AButton>
</a>
<AButton
type="secondary"
:status="copied ? 'success' : 'normal'"
@click="copy()"
>
{{ copied ? t('button.copy-script') : t('button.copy-script') }}
</AButton>
</ASpace>
</AFormItem>
</AForm>
</ACard>
</div>
</template>
2 changes: 1 addition & 1 deletion src/store/monitor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fetch from '@/utils/fetch'

export const useMonitorStore = defineStore('monitor', () => {
const monitors = useStorage('monitors', [])
const monitors = useStorage<RecordItem[]>('monitors', [])

const getMonitors = async () => {
try {
Expand Down
2 changes: 2 additions & 0 deletions src/typings/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ declare module 'vue' {
ALink: typeof import('@arco-design/web-vue')['Link']
AMenu: typeof import('@arco-design/web-vue')['Menu']
AMenuItem: typeof import('@arco-design/web-vue')['MenuItem']
AOptgroup: typeof import('@arco-design/web-vue')['Optgroup']
AOption: typeof import('@arco-design/web-vue')['Option']
ARadio: typeof import('@arco-design/web-vue')['Radio']
ARadioGroup: typeof import('@arco-design/web-vue')['RadioGroup']
Expand All @@ -32,6 +33,7 @@ declare module 'vue' {
ASubMenu: typeof import('@arco-design/web-vue')['SubMenu']
ATable: typeof import('@arco-design/web-vue')['Table']
ATextarea: typeof import('@arco-design/web-vue')['Textarea']
CommonActivate: typeof import('./../components/common-activate.vue')['default']
CustomFooter: typeof import('./../components/custom-footer.vue')['default']
CustomHeader: typeof import('./../components/custom-header.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
Expand Down
18 changes: 18 additions & 0 deletions src/typings/custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,21 @@ interface LocaleItem {
icon?: string
value: LocaleValue
}

interface EditionItem {
version: string
edition: string[][]
}

interface RecordItem {
id: number
host: string
port: number
total: number
success: number
fail: number
delay: number
rate: number
updatedAt: Date
createdAt: Date
}
Loading

0 comments on commit 0f91b07

Please sign in to comment.