Improve license activation and provider tracking
This commit is contained in:
1 parent
3686d6b25c
commit
c4233900a6
6 files changed
+73
-13
No files matched your search
@@ -3,9 +3,12 @@ import { onMounted, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import http, { apiErrorMessage } from '../api/http'
|
||||
|
||||
interface LicenseStatus { machineCode: string; isLicensed: boolean; expiresAt: string | null; type: string | null; isExpired: boolean }
|
||||
interface LicenseStatus { machineCode: string; isLicensed: boolean; expiresAt: string | null; type: string | null; isExpired: boolean; maintenanceOrganization: string | null }
|
||||
const status = ref<LicenseStatus | null>(null)
|
||||
const code = ref('')
|
||||
const maintenanceOrganization = ref('')
|
||||
const years = ref(1)
|
||||
const isAnnual = ref(true)
|
||||
const loading = ref(false)
|
||||
async function load() {
|
||||
const { data } = await http.get<LicenseStatus>('/licenses/status')
|
||||
@@ -24,6 +27,17 @@ async function activate() {
|
||||
ElMessage.success('授权激活成功。')
|
||||
} catch (error) { ElMessage.error(apiErrorMessage(error)) } finally { loading.value = false }
|
||||
}
|
||||
async function onlineActivate() {
|
||||
loading.value = true
|
||||
try {
|
||||
const { data } = await http.post<{ status: LicenseStatus; activationCode: string }>('/licenses/online-activate', {
|
||||
maintenanceOrganization: maintenanceOrganization.value.trim(), years: years.value, isAnnual: isAnnual.value,
|
||||
})
|
||||
status.value = data.status
|
||||
code.value = data.activationCode
|
||||
ElMessage.success('在线授权成功,激活码已显示并保存。')
|
||||
} catch (error) { ElMessage.error(apiErrorMessage(error)) } finally { loading.value = false }
|
||||
}
|
||||
onMounted(() => load().catch(error => ElMessage.error(apiErrorMessage(error))))
|
||||
</script>
|
||||
|
||||
@@ -34,6 +48,17 @@ onMounted(() => load().catch(error => ElMessage.error(apiErrorMessage(error))))
|
||||
<h2>当前授权</h2>
|
||||
<p v-if="status?.isLicensed">{{ status.isExpired ? '已过期' : '有效' }} · 到期时间:{{ new Date(status.expiresAt!).toLocaleString() }}</p>
|
||||
<p v-else>尚未激活有效授权</p>
|
||||
<p v-if="status?.maintenanceOrganization">购买的维护机构:<strong>{{ status.maintenanceOrganization }}</strong></p>
|
||||
</el-card>
|
||||
<el-card>
|
||||
<h2>在线激活</h2>
|
||||
<p>填写购买时对应的维护机构,系统将向已配置的在线授权服务申请并保存激活码。</p>
|
||||
<el-input v-model="maintenanceOrganization" maxlength="200" show-word-limit placeholder="维护机构名称" />
|
||||
<div class="online-options">
|
||||
<el-switch v-model="isAnnual" active-text="年度授权" inactive-text="自定义年限" />
|
||||
<el-input-number v-if="!isAnnual" v-model="years" :min="1" :max="30" />
|
||||
</div>
|
||||
<el-button type="primary" :loading="loading" :disabled="!maintenanceOrganization.trim()" @click="onlineActivate">在线申请并激活</el-button>
|
||||
</el-card>
|
||||
<el-card>
|
||||
<h2>本机机器码</h2>
|
||||
@@ -55,4 +80,5 @@ onMounted(() => load().catch(error => ElMessage.error(apiErrorMessage(error))))
|
||||
h1, h2 { margin-top: 0; }
|
||||
.el-button { margin-top: 12px; }
|
||||
.machine-code { display: inline-block; margin-right: 14px; padding: 10px 12px; border-radius: var(--radius-control); background: #f2f5f7; font-size: 17px; letter-spacing: 1px; }
|
||||
.online-options { display: flex; align-items: center; gap: 16px; margin-top: 12px; }
|
||||
</style>
|
||||
Reference in new issue
Block a user