mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 03:49:19 +08:00
refactor: 调整页面组件位置
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, Input, message, Space, Typography } from 'ant-design-vue';
|
||||
|
||||
defineOptions({ name: 'FingerprintDisplay' });
|
||||
|
||||
const props = defineProps<{
|
||||
fingerprint: string;
|
||||
hostname?: string;
|
||||
machineId?: string;
|
||||
}>();
|
||||
|
||||
const CopyIcon = createIconifyIcon('lucide:copy');
|
||||
|
||||
const copying = ref(false);
|
||||
|
||||
async function copyFingerprint() {
|
||||
if (!props.fingerprint) return;
|
||||
copying.value = true;
|
||||
try {
|
||||
await navigator.clipboard.writeText(props.fingerprint);
|
||||
message.success('机器指纹已复制');
|
||||
} catch {
|
||||
message.error('复制失败,请手动选择复制');
|
||||
} finally {
|
||||
copying.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="rounded-lg border border-dashed border-primary/30 bg-primary/5 p-4">
|
||||
<Typography.Text type="secondary" class="mb-2 block text-sm">
|
||||
请将以下机器指纹发送给运营方签发 License
|
||||
</Typography.Text>
|
||||
<Input :value="fingerprint" readonly class="font-mono text-xs" />
|
||||
<Space class="mt-3" wrap>
|
||||
<Button
|
||||
type="primary"
|
||||
ghost
|
||||
size="small"
|
||||
:loading="copying"
|
||||
@click="copyFingerprint"
|
||||
>
|
||||
<CopyIcon class="mr-1 size-4" />
|
||||
复制指纹
|
||||
</Button>
|
||||
<Typography.Text v-if="hostname" type="secondary" class="text-xs">
|
||||
主机名:{{ hostname }}
|
||||
</Typography.Text>
|
||||
</Space>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,46 @@
|
||||
<script setup lang="ts">
|
||||
import type { LicenseVO } from '#/api/system/license';
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
import { Card, Spin } from 'ant-design-vue';
|
||||
|
||||
import { getSystemFingerprintApi } from '#/api/system/license';
|
||||
|
||||
import FingerprintDisplay from './FingerprintDisplay.vue';
|
||||
|
||||
defineOptions({ name: 'FingerprintInfo' });
|
||||
|
||||
const loading = ref(false);
|
||||
const fingerprint = ref<LicenseVO.Fingerprint | null>(null);
|
||||
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
try {
|
||||
fingerprint.value = await getSystemFingerprintApi();
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
load();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Card title="机器指纹" :bordered="false">
|
||||
<Spin :spinning="loading">
|
||||
<FingerprintDisplay
|
||||
v-if="fingerprint"
|
||||
:fingerprint="fingerprint.fingerprint"
|
||||
:hostname="fingerprint.hostname"
|
||||
:machine-id="fingerprint.machineId"
|
||||
/>
|
||||
<div v-else-if="!loading" class="text-gray-400">暂无指纹信息</div>
|
||||
</Spin>
|
||||
<p class="mt-4 text-sm text-gray-500">
|
||||
迁机或重新签发 License 时,请将新环境的机器指纹提供给运营方。
|
||||
</p>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -0,0 +1,160 @@
|
||||
<script setup lang="ts">
|
||||
import type { LicenseVO } from '#/api/system/license';
|
||||
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Descriptions,
|
||||
Form,
|
||||
Input,
|
||||
message,
|
||||
Space,
|
||||
Tag,
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import {
|
||||
getLicenseInfoApi,
|
||||
updateLicenseApi,
|
||||
} from '#/api/system/license';
|
||||
|
||||
import FingerprintInfo from './FingerprintInfo.vue';
|
||||
|
||||
defineOptions({ name: 'LicenseInfo' });
|
||||
|
||||
const loading = ref(false);
|
||||
const updating = ref(false);
|
||||
const license = ref<LicenseVO.LicenseSummary | null>(null);
|
||||
const renewKey = ref('');
|
||||
|
||||
const statusTag = computed(() => {
|
||||
const status = license.value?.status;
|
||||
if (status === 'active') return { color: 'success', text: '有效' };
|
||||
if (status === 'expiring') return { color: 'warning', text: '即将过期' };
|
||||
if (status === 'expired') return { color: 'error', text: '已过期' };
|
||||
if (status === 'dev-disabled') return { color: 'default', text: '开发模式' };
|
||||
return { color: 'default', text: status || '未知' };
|
||||
});
|
||||
|
||||
const editionLabel: Record<string, string> = {
|
||||
trial: '试用版',
|
||||
enterprise: '企业版',
|
||||
unlimited: '无限版',
|
||||
};
|
||||
|
||||
async function loadLicense() {
|
||||
loading.value = true;
|
||||
try {
|
||||
license.value = await getLicenseInfoApi();
|
||||
} catch (error: any) {
|
||||
license.value = null;
|
||||
if (!error?.message?.includes('无有效')) {
|
||||
message.error(error?.message || '获取 License 信息失败');
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleRenew() {
|
||||
if (!renewKey.value.trim()) {
|
||||
message.warning('请输入新的 License Key');
|
||||
return;
|
||||
}
|
||||
updating.value = true;
|
||||
const hide = message.loading('正在更新 License...', 0);
|
||||
try {
|
||||
license.value = await updateLicenseApi({ licenseKey: renewKey.value.trim() });
|
||||
renewKey.value = '';
|
||||
message.success('License 更新成功');
|
||||
} finally {
|
||||
hide();
|
||||
updating.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function formatDate(value?: string) {
|
||||
return value ? dayjs(value).format('YYYY-MM-DD HH:mm') : '-';
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadLicense();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="License 管理" description="查看授权信息与续期更新">
|
||||
<div class="grid gap-4 lg:grid-cols-2">
|
||||
<Card title="授权信息" :loading="loading">
|
||||
<template v-if="license">
|
||||
<Descriptions :column="1" bordered size="small">
|
||||
<Descriptions.Item label="状态">
|
||||
<Tag :color="statusTag.color">{{ statusTag.text }}</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="授权公司">
|
||||
{{ license.companyName || '-' }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="版本">
|
||||
{{ editionLabel[license.edition || ''] || license.edition || '-' }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="机器指纹">
|
||||
<Typography.Text code class="text-xs break-all">
|
||||
{{ license.machineFingerprint || '-' }}
|
||||
</Typography.Text>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="授权功能">
|
||||
<Space wrap>
|
||||
<Tag v-for="f in license.features" :key="f">{{ f }}</Tag>
|
||||
<span v-if="!license.features?.length">-</span>
|
||||
</Space>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="签发时间">
|
||||
{{ formatDate(license.issuedAt) }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="过期时间">
|
||||
{{ formatDate(license.expiresAt) }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item
|
||||
v-if="license.daysRemaining != null"
|
||||
label="剩余天数"
|
||||
>
|
||||
{{ license.daysRemaining }} 天
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</template>
|
||||
<Typography.Text v-else type="secondary">
|
||||
暂无有效 License(本地开发可能未启用校验)
|
||||
</Typography.Text>
|
||||
<Button class="mt-4" size="small" @click="loadLicense">刷新</Button>
|
||||
</Card>
|
||||
|
||||
<Card title="续期 / 更新 License">
|
||||
<Typography.Paragraph type="secondary" class="text-sm">
|
||||
运营方签发新 License 后,将完整 JWT 粘贴到下方并提交。
|
||||
</Typography.Paragraph>
|
||||
<Form layout="vertical" @finish="handleRenew">
|
||||
<Form.Item label="新 License Key" required>
|
||||
<Input.TextArea
|
||||
v-model:value="renewKey"
|
||||
:rows="5"
|
||||
placeholder="粘贴新的 License JWT"
|
||||
class="font-mono text-xs"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Button type="primary" html-type="submit" :loading="updating">
|
||||
更新 License
|
||||
</Button>
|
||||
</Form>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<FingerprintInfo />
|
||||
</div>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,201 @@
|
||||
<script setup lang="ts">
|
||||
import type { LicenseVO } from '#/api/system/license';
|
||||
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Descriptions,
|
||||
Form,
|
||||
Input,
|
||||
message,
|
||||
Space,
|
||||
Tag,
|
||||
Typography,
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import {
|
||||
activateLicenseApi,
|
||||
getLicenseInfoApi,
|
||||
getSystemFingerprintApi,
|
||||
} from '#/api/system/license';
|
||||
|
||||
import FingerprintDisplay from './FingerprintDisplay.vue';
|
||||
|
||||
defineOptions({ name: 'SystemLicensePage' });
|
||||
|
||||
const loading = ref(false);
|
||||
const fingerprintLoading = ref(false);
|
||||
const submitting = ref(false);
|
||||
const license = ref<LicenseVO.LicenseSummary | null>(null);
|
||||
const fingerprint = ref<LicenseVO.Fingerprint | null>(null);
|
||||
const licenseKey = ref('');
|
||||
|
||||
const statusTag = computed(() => {
|
||||
const status = license.value?.status;
|
||||
if (status === 'active') return { color: 'success', text: '有效' };
|
||||
if (status === 'expiring') return { color: 'warning', text: '即将过期' };
|
||||
if (status === 'expired') return { color: 'error', text: '已过期' };
|
||||
if (status === 'dev-disabled') return { color: 'default', text: '开发模式(未强制校验)' };
|
||||
if (status === 'inactive') return { color: 'default', text: '未激活' };
|
||||
return { color: 'default', text: status || '未知' };
|
||||
});
|
||||
|
||||
const editionLabel: Record<string, string> = {
|
||||
trial: '试用版',
|
||||
enterprise: '企业版',
|
||||
unlimited: '无限版',
|
||||
};
|
||||
|
||||
const hasLicense = computed(() =>
|
||||
Boolean(license.value?.companyName || license.value?.edition),
|
||||
);
|
||||
|
||||
async function loadLicense() {
|
||||
loading.value = true;
|
||||
try {
|
||||
license.value = await getLicenseInfoApi();
|
||||
} catch (error: any) {
|
||||
license.value = { status: 'inactive', features: [] };
|
||||
message.error(error?.message || '获取授权信息失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadFingerprint() {
|
||||
fingerprintLoading.value = true;
|
||||
try {
|
||||
fingerprint.value = await getSystemFingerprintApi();
|
||||
} catch (error: any) {
|
||||
fingerprint.value = null;
|
||||
message.error(error?.message || '获取机器指纹失败');
|
||||
} finally {
|
||||
fingerprintLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleActivate() {
|
||||
if (!licenseKey.value.trim()) {
|
||||
message.warning('请输入 License Key');
|
||||
return;
|
||||
}
|
||||
submitting.value = true;
|
||||
const hide = message.loading('正在提交授权...', 0);
|
||||
try {
|
||||
license.value = await activateLicenseApi({
|
||||
licenseKey: licenseKey.value.trim(),
|
||||
});
|
||||
licenseKey.value = '';
|
||||
message.success('授权提交成功');
|
||||
} finally {
|
||||
hide();
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function formatDate(value?: string) {
|
||||
return value ? dayjs(value).format('YYYY-MM-DD HH:mm') : '-';
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadLicense();
|
||||
loadFingerprint();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="授权管理" description="查看机器指纹,激活或更新 License">
|
||||
<div class="grid gap-4 lg:grid-cols-2">
|
||||
<Card title="机器指纹" :loading="fingerprintLoading">
|
||||
<FingerprintDisplay
|
||||
v-if="fingerprint"
|
||||
:fingerprint="fingerprint.fingerprint"
|
||||
:hostname="fingerprint.hostname"
|
||||
:machine-id="fingerprint.machineId"
|
||||
/>
|
||||
<Typography.Text v-else type="secondary">
|
||||
暂无指纹信息
|
||||
</Typography.Text>
|
||||
<Button class="mt-4" size="small" @click="loadFingerprint">
|
||||
刷新指纹
|
||||
</Button>
|
||||
</Card>
|
||||
|
||||
<Card :title="hasLicense ? '更新授权' : '激活授权'">
|
||||
<Typography.Paragraph type="secondary" class="text-sm">
|
||||
将上方机器指纹提供给运营方,获取 License 后粘贴到下方完成激活或续期。
|
||||
</Typography.Paragraph>
|
||||
<Form layout="vertical" @finish="handleActivate">
|
||||
<Form.Item label="License Key" required>
|
||||
<Input.TextArea
|
||||
v-model:value="licenseKey"
|
||||
:rows="6"
|
||||
placeholder="粘贴运营方签发的 License JWT"
|
||||
class="font-mono text-xs"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Button type="primary" html-type="submit" :loading="submitting">
|
||||
{{ hasLicense ? '更新 License' : '激活 License' }}
|
||||
</Button>
|
||||
</Form>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<Card class="mt-4" title="当前授权信息" :loading="loading">
|
||||
<template v-if="hasLicense">
|
||||
<Descriptions :column="2" bordered size="small">
|
||||
<Descriptions.Item label="状态">
|
||||
<Tag :color="statusTag.color">{{ statusTag.text }}</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="授权公司">
|
||||
{{ license?.companyName || '-' }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="版本">
|
||||
{{
|
||||
editionLabel[license?.edition || ''] || license?.edition || '-'
|
||||
}}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="公司上限">
|
||||
{{ license?.maxCompanies ?? '-' }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="授权指纹" :span="2">
|
||||
<Typography.Text code class="text-xs break-all">
|
||||
{{ license?.machineFingerprint || '-' }}
|
||||
</Typography.Text>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="授权功能" :span="2">
|
||||
<Space wrap>
|
||||
<Tag v-for="f in license?.features" :key="f">{{ f }}</Tag>
|
||||
<span v-if="!license?.features?.length">-</span>
|
||||
</Space>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="签发时间">
|
||||
{{ formatDate(license?.issuedAt) }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="过期时间">
|
||||
{{ formatDate(license?.expiresAt) }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item
|
||||
v-if="license?.daysRemaining != null"
|
||||
label="剩余天数"
|
||||
>
|
||||
{{ license.daysRemaining }} 天
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</template>
|
||||
<Typography.Text v-else type="secondary">
|
||||
{{
|
||||
license?.status === 'dev-disabled'
|
||||
? '当前为开发模式,尚未强制校验 License。仍可在此激活以便生产切换。'
|
||||
: '尚未激活 License,请先获取机器指纹并完成授权。'
|
||||
}}
|
||||
</Typography.Text>
|
||||
<Button class="mt-4" size="small" @click="loadLicense">刷新</Button>
|
||||
</Card>
|
||||
</Page>
|
||||
</template>
|
||||
Reference in New Issue
Block a user