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:
@@ -1,85 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import type { LicenseDTO } from '#/api/system/license';
|
||||
|
||||
import { reactive, ref } from 'vue';
|
||||
|
||||
import { Button, Form, Input, message } from 'ant-design-vue';
|
||||
|
||||
import { createInitAdminApi } from '#/api/system/license';
|
||||
|
||||
defineOptions({ name: 'InitStepAdmin' });
|
||||
|
||||
const emit = defineEmits<{
|
||||
next: [];
|
||||
}>();
|
||||
|
||||
const submitting = ref(false);
|
||||
|
||||
const formState = reactive<LicenseDTO.InitAdmin>({
|
||||
loginCode: '',
|
||||
phone: '',
|
||||
password: '',
|
||||
realName: '',
|
||||
});
|
||||
|
||||
const rules = {
|
||||
loginCode: [{ required: true, message: '请输入登录账号' }],
|
||||
password: [{ required: true, message: '请输入密码' }],
|
||||
realName: [{ required: true, message: '请输入姓名' }],
|
||||
};
|
||||
|
||||
async function handleSubmit() {
|
||||
submitting.value = true;
|
||||
const hide = message.loading('正在创建超级管理员...', 0);
|
||||
try {
|
||||
await createInitAdminApi({
|
||||
...formState,
|
||||
phone: formState.phone || undefined,
|
||||
});
|
||||
message.success('超级管理员创建成功');
|
||||
emit('next');
|
||||
} finally {
|
||||
hide();
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Form
|
||||
layout="vertical"
|
||||
:model="formState"
|
||||
:rules="rules"
|
||||
@finish="handleSubmit"
|
||||
>
|
||||
<Form.Item label="登录账号" name="loginCode">
|
||||
<Input
|
||||
v-model:value="formState.loginCode"
|
||||
placeholder="超级管理员登录账号"
|
||||
autocomplete="username"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="手机号码" name="phone">
|
||||
<Input
|
||||
v-model:value="formState.phone"
|
||||
placeholder="选填"
|
||||
autocomplete="tel"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="姓名" name="realName">
|
||||
<Input v-model:value="formState.realName" placeholder="管理员姓名" />
|
||||
</Form.Item>
|
||||
<Form.Item label="登录密码" name="password">
|
||||
<Input.Password
|
||||
v-model:value="formState.password"
|
||||
placeholder="设置登录密码"
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Button type="primary" html-type="submit" :loading="submitting" block>
|
||||
下一步
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</template>
|
||||
@@ -1,77 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import type { LicenseDTO } from '#/api/system/license';
|
||||
|
||||
import { reactive, ref } from 'vue';
|
||||
|
||||
import { Button, Form, Input, message } from 'ant-design-vue';
|
||||
|
||||
import { saveInitCompanyApi } from '#/api/system/license';
|
||||
|
||||
defineOptions({ name: 'InitStepCompany' });
|
||||
|
||||
const emit = defineEmits<{
|
||||
back: [];
|
||||
next: [];
|
||||
}>();
|
||||
|
||||
const submitting = ref(false);
|
||||
|
||||
const formState = reactive<LicenseDTO.InitCompany>({
|
||||
companyName: '',
|
||||
contactPhone: '',
|
||||
contactEmail: '',
|
||||
});
|
||||
|
||||
const rules = {
|
||||
companyName: [{ required: true, message: '请输入公司名称' }],
|
||||
};
|
||||
|
||||
async function handleSubmit() {
|
||||
submitting.value = true;
|
||||
const hide = message.loading('正在保存公司信息...', 0);
|
||||
try {
|
||||
await saveInitCompanyApi({
|
||||
...formState,
|
||||
contactPhone: formState.contactPhone || undefined,
|
||||
contactEmail: formState.contactEmail || undefined,
|
||||
});
|
||||
message.success('公司信息保存成功');
|
||||
emit('next');
|
||||
} finally {
|
||||
hide();
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Form
|
||||
layout="vertical"
|
||||
:model="formState"
|
||||
:rules="rules"
|
||||
@finish="handleSubmit"
|
||||
>
|
||||
<Form.Item label="公司名称" name="companyName">
|
||||
<Input v-model:value="formState.companyName" placeholder="公司全称" />
|
||||
</Form.Item>
|
||||
<Form.Item label="联系电话" name="contactPhone">
|
||||
<Input v-model:value="formState.contactPhone" placeholder="选填" />
|
||||
</Form.Item>
|
||||
<Form.Item label="联系邮箱" name="contactEmail">
|
||||
<Input v-model:value="formState.contactEmail" placeholder="选填" />
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<div class="flex gap-3">
|
||||
<Button class="flex-1" @click="emit('back')">上一步</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
html-type="submit"
|
||||
class="flex-1"
|
||||
:loading="submitting"
|
||||
>
|
||||
下一步
|
||||
</Button>
|
||||
</div>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</template>
|
||||
@@ -1,103 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import type { LicenseVO } from '#/api/system/license';
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import { LOGIN_PATH } from '@vben/constants';
|
||||
|
||||
import { Button, Form, Input, message, Typography } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
activateInitLicenseApi,
|
||||
getInitFingerprintApi,
|
||||
} from '#/api/system/license';
|
||||
import { resetInitStatusCache } from '#/router/guard';
|
||||
|
||||
import FingerprintDisplay from './components/FingerprintDisplay.vue';
|
||||
|
||||
defineOptions({ name: 'InitStepLicense' });
|
||||
|
||||
const emit = defineEmits<{
|
||||
back: [];
|
||||
}>();
|
||||
|
||||
const router = useRouter();
|
||||
const submitting = ref(false);
|
||||
const fingerprintLoading = ref(false);
|
||||
const fingerprint = ref<LicenseVO.Fingerprint | null>(null);
|
||||
const licenseKey = ref('');
|
||||
|
||||
async function loadFingerprint() {
|
||||
fingerprintLoading.value = true;
|
||||
try {
|
||||
fingerprint.value = await getInitFingerprintApi();
|
||||
} finally {
|
||||
fingerprintLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleActivate() {
|
||||
if (!licenseKey.value.trim()) {
|
||||
message.warning('请输入 License Key');
|
||||
return;
|
||||
}
|
||||
submitting.value = true;
|
||||
const hide = message.loading('正在激活 License...', 0);
|
||||
try {
|
||||
await activateInitLicenseApi({ licenseKey: licenseKey.value.trim() });
|
||||
resetInitStatusCache();
|
||||
message.success('系统初始化完成,请登录');
|
||||
await router.replace(LOGIN_PATH);
|
||||
} finally {
|
||||
hide();
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadFingerprint();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-4">
|
||||
<Typography.Paragraph type="secondary" class="!mb-0 text-sm">
|
||||
将机器指纹提供给运营方,获取 License Key 后粘贴到下方完成激活。
|
||||
</Typography.Paragraph>
|
||||
|
||||
<div v-if="fingerprintLoading" class="py-6 text-center text-gray-400">
|
||||
正在获取机器指纹...
|
||||
</div>
|
||||
<FingerprintDisplay
|
||||
v-else-if="fingerprint"
|
||||
:fingerprint="fingerprint.fingerprint"
|
||||
:hostname="fingerprint.hostname"
|
||||
:machine-id="fingerprint.machineId"
|
||||
/>
|
||||
|
||||
<Form layout="vertical" @finish="handleActivate">
|
||||
<Form.Item label="License Key" required>
|
||||
<Input.TextArea
|
||||
v-model:value="licenseKey"
|
||||
:rows="4"
|
||||
placeholder="粘贴运营方签发的 License JWT"
|
||||
class="font-mono text-xs"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<div class="flex gap-3">
|
||||
<Button class="flex-1" @click="emit('back')">上一步</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
html-type="submit"
|
||||
class="flex-1"
|
||||
:loading="submitting"
|
||||
>
|
||||
激活并完成
|
||||
</Button>
|
||||
</div>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,91 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import { LOGIN_PATH } from '@vben/constants';
|
||||
import { preferences } from '@vben/preferences';
|
||||
|
||||
import { Card, Spin, Steps, Typography } from 'ant-design-vue';
|
||||
|
||||
import { getInitStatusApi } from '#/api/system/license';
|
||||
|
||||
import InitStepAdmin from './InitStepAdmin.vue';
|
||||
import InitStepCompany from './InitStepCompany.vue';
|
||||
import InitStepLicense from './InitStepLicense.vue';
|
||||
|
||||
defineOptions({ name: 'InitWizard' });
|
||||
|
||||
const router = useRouter();
|
||||
const currentStep = ref(0);
|
||||
const statusLoading = ref(true);
|
||||
|
||||
const stepItems = [
|
||||
{ title: '超级管理员' },
|
||||
{ title: '公司信息' },
|
||||
{ title: 'License 激活' },
|
||||
];
|
||||
|
||||
async function loadStatus() {
|
||||
statusLoading.value = true;
|
||||
try {
|
||||
const status = await getInitStatusApi();
|
||||
if (status.initialized) {
|
||||
await router.replace(LOGIN_PATH);
|
||||
return;
|
||||
}
|
||||
// 根据后端进度定位到对应步骤
|
||||
if (status.licenseActivated || status.currentStep >= 3) {
|
||||
currentStep.value = 2;
|
||||
} else if (status.companySaved || status.currentStep >= 2) {
|
||||
currentStep.value = 2;
|
||||
} else if (status.adminCreated || status.currentStep >= 1) {
|
||||
currentStep.value = 1;
|
||||
} else {
|
||||
currentStep.value = 0;
|
||||
}
|
||||
} finally {
|
||||
statusLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function goNext() {
|
||||
currentStep.value = Math.min(currentStep.value + 1, 2);
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
currentStep.value = Math.max(currentStep.value - 1, 0);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadStatus();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex min-h-screen flex-col items-center justify-center bg-gradient-to-b from-background to-muted/30 px-4 py-10"
|
||||
>
|
||||
<div class="mb-8 text-center">
|
||||
<Typography.Title :level="3" class="!mb-1">
|
||||
{{ preferences.app.name }} 系统初始化
|
||||
</Typography.Title>
|
||||
<Typography.Text type="secondary">
|
||||
首次部署请按步骤完成配置
|
||||
</Typography.Text>
|
||||
</div>
|
||||
|
||||
<Card class="w-full max-w-lg shadow-sm">
|
||||
<Steps :current="currentStep" :items="stepItems" class="mb-8" />
|
||||
|
||||
<Spin :spinning="statusLoading">
|
||||
<InitStepAdmin v-if="currentStep === 0" @next="goNext" />
|
||||
<InitStepCompany
|
||||
v-else-if="currentStep === 1"
|
||||
@back="goBack"
|
||||
@next="goNext"
|
||||
/>
|
||||
<InitStepLicense v-else @back="goBack" />
|
||||
</Spin>
|
||||
</Card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -7,7 +7,7 @@ import { Card, Spin } from 'ant-design-vue';
|
||||
|
||||
import { getSystemFingerprintApi } from '#/api/system/license';
|
||||
|
||||
import FingerprintDisplay from '#/views/init/components/FingerprintDisplay.vue';
|
||||
import FingerprintDisplay from './FingerprintDisplay.vue';
|
||||
|
||||
defineOptions({ name: 'FingerprintInfo' });
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
getSystemFingerprintApi,
|
||||
} from '#/api/system/license';
|
||||
|
||||
import FingerprintDisplay from '#/views/init/components/FingerprintDisplay.vue';
|
||||
import FingerprintDisplay from './FingerprintDisplay.vue';
|
||||
|
||||
defineOptions({ name: 'SystemLicensePage' });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user