feat: 重构安装向导页(管理员并入基础、存储测试、必填标记、主题语言切换)
管理员账号/密码/姓名并入基础卡片并移除独立管理员卡片; 移除 MySQL 建库管理员字段,库不存在自动建库、无权限给出清晰错误提示; 新增存储测试(本地目录可写 / OSS-S3 真实读写校验)后端 /api/install/test-storage; CDN 增加留空即不启用说明;必填项加红色 * 标记; 头部加入与后台一致的主题/语言切换按钮;清理页面冗余注释。
This commit is contained in:
@@ -198,16 +198,16 @@
|
||||
"database": "Database",
|
||||
"username": "Username",
|
||||
"password": "Password",
|
||||
"adminUser": "DB admin user (optional)",
|
||||
"adminPass": "DB admin password (optional)",
|
||||
"mysqlAdminHint": "Only needed if the business account cannot create databases; the database, tables and data are created automatically.",
|
||||
"admin": "Admin",
|
||||
"adminAccount": "Admin Account",
|
||||
"adminPwd": "Admin Password",
|
||||
"realName": "Name",
|
||||
"storage": "Storage",
|
||||
"driver": "Driver",
|
||||
"local": "Local",
|
||||
"localDir": "Local Directory",
|
||||
"cdnBaseUrl": "CDN URL",
|
||||
"cdnHint": "CDN acceleration URL; leave empty to disable (empty = serve from origin directly).",
|
||||
"failed": "Installation failed",
|
||||
"done": "Initialized. The service is restarting, please wait…",
|
||||
"loadFailed": "Failed to read installation status",
|
||||
|
||||
@@ -198,16 +198,16 @@
|
||||
"database": "数据库",
|
||||
"username": "账号",
|
||||
"password": "密码",
|
||||
"adminUser": "建库管理员账号(可选)",
|
||||
"adminPass": "建库管理员密码(可选)",
|
||||
"mysqlAdminHint": "仅当业务账号无建库权限时填写;系统会自动创建数据库并初始化表结构与数据。",
|
||||
"admin": "管理员",
|
||||
"adminAccount": "管理员账号",
|
||||
"adminPwd": "管理员密码",
|
||||
"realName": "姓名",
|
||||
"storage": "存储",
|
||||
"driver": "方式",
|
||||
"local": "本地",
|
||||
"localDir": "本地目录",
|
||||
"cdnBaseUrl": "CDN 地址",
|
||||
"cdnHint": "CDN 加速地址;如不启用可留空(为空则不开启,直接走源站)。",
|
||||
"failed": "安装失败",
|
||||
"done": "初始化完成,服务正在重启,请稍候…",
|
||||
"loadFailed": "读取安装状态失败",
|
||||
|
||||
@@ -6,9 +6,13 @@
|
||||
<h1>{{ form.appName || 'Artveris' }}</h1>
|
||||
<p>{{ tt('subtitle') }}</p>
|
||||
</div>
|
||||
<n-button v-if="!installed" type="primary" size="large" :loading="submitting" @click="submit">
|
||||
{{ submitting ? tt('installing') : tt('start') }}
|
||||
</n-button>
|
||||
<div class="head-actions">
|
||||
<lang-switch />
|
||||
<theme-switch />
|
||||
<n-button v-if="!installed" type="primary" size="large" :loading="submitting" @click="submit">
|
||||
{{ submitting ? tt('installing') : tt('start') }}
|
||||
</n-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<n-spin :show="loading">
|
||||
@@ -27,9 +31,14 @@
|
||||
<div class="grid">
|
||||
<section class="box">
|
||||
<h2>{{ tt('base') }}</h2>
|
||||
<label><span>{{ tt('appName') }}</span><n-input v-model:value="form.appName" /></label>
|
||||
<label><span>{{ tt('baseUrl') }}</span><n-input v-model:value="form.baseUrl" placeholder="https://example.com" /></label>
|
||||
<label><span>{{ tt('appName') }}<i class="req">*</i></span><n-input v-model:value="form.appName" /></label>
|
||||
<label><span>{{ tt('baseUrl') }}<i class="req">*</i></span><n-input v-model:value="form.baseUrl" placeholder="https://example.com" /></label>
|
||||
<p class="hint">{{ tt('baseUrlHint') }}</p>
|
||||
|
||||
<div class="sub">{{ tt('admin') }}</div>
|
||||
<label><span>{{ tt('adminAccount') }}<i class="req">*</i></span><n-input v-model:value="form.admin.username" /></label>
|
||||
<label><span>{{ tt('adminPwd') }}<i class="req">*</i></span><n-input v-model:value="form.admin.password" type="password" show-password-on="click" /></label>
|
||||
<label><span>{{ tt('realName') }}</span><n-input v-model:value="form.admin.realName" /></label>
|
||||
</section>
|
||||
|
||||
<section class="box">
|
||||
@@ -37,15 +46,12 @@
|
||||
<h2>MySQL</h2>
|
||||
<n-button size="tiny" :loading="testingMysql" @click="testMysql">{{ tt('testConnection') }}</n-button>
|
||||
</div>
|
||||
<label><span>{{ tt('host') }}</span><n-input v-model:value="form.mysql.host" /></label>
|
||||
<label><span>{{ tt('port') }}</span><n-input-number v-model:value="form.mysql.port" :min="1" :show-button="false" class="full" /></label>
|
||||
<label><span>{{ tt('database') }}</span><n-input v-model:value="form.mysql.database" /></label>
|
||||
<label><span>{{ tt('username') }}</span><n-input v-model:value="form.mysql.username" /></label>
|
||||
<label><span>{{ tt('host') }}<i class="req">*</i></span><n-input v-model:value="form.mysql.host" /></label>
|
||||
<label><span>{{ tt('port') }}<i class="req">*</i></span><n-input-number v-model:value="form.mysql.port" :min="1" :show-button="false" class="full" /></label>
|
||||
<label><span>{{ tt('database') }}<i class="req">*</i></span><n-input v-model:value="form.mysql.database" /></label>
|
||||
<label><span>{{ tt('username') }}<i class="req">*</i></span><n-input v-model:value="form.mysql.username" /></label>
|
||||
<label><span>{{ tt('password') }}</span><n-input v-model:value="form.mysql.password" type="password" show-password-on="click" /></label>
|
||||
<label><span>{{ tt('adminUser') }}</span><n-input v-model:value="form.mysql.adminUsername" /></label>
|
||||
<label><span>{{ tt('adminPass') }}</span><n-input v-model:value="form.mysql.adminPassword" type="password" show-password-on="click" /></label>
|
||||
<p v-if="mysqlTest" class="test-result" :class="mysqlTest.ok ? 'ok' : 'fail'">{{ mysqlTest.msg }}</p>
|
||||
<p class="hint">{{ tt('mysqlAdminHint') }}</p>
|
||||
</section>
|
||||
|
||||
<section class="box">
|
||||
@@ -53,34 +59,34 @@
|
||||
<h2>Redis</h2>
|
||||
<n-button size="tiny" :loading="testingRedis" @click="testRedis">{{ tt('testConnection') }}</n-button>
|
||||
</div>
|
||||
<label><span>{{ tt('host') }}</span><n-input v-model:value="form.redis.host" /></label>
|
||||
<label><span>{{ tt('port') }}</span><n-input-number v-model:value="form.redis.port" :min="1" :show-button="false" class="full" /></label>
|
||||
<label><span>{{ tt('host') }}<i class="req">*</i></span><n-input v-model:value="form.redis.host" /></label>
|
||||
<label><span>{{ tt('port') }}<i class="req">*</i></span><n-input-number v-model:value="form.redis.port" :min="1" :show-button="false" class="full" /></label>
|
||||
<label><span>{{ tt('password') }}</span><n-input v-model:value="form.redis.password" type="password" show-password-on="click" /></label>
|
||||
<p v-if="redisTest" class="test-result" :class="redisTest.ok ? 'ok' : 'fail'">{{ redisTest.msg }}</p>
|
||||
</section>
|
||||
|
||||
<section class="box">
|
||||
<h2>{{ tt('admin') }}</h2>
|
||||
<label><span>{{ tt('username') }}</span><n-input v-model:value="form.admin.username" /></label>
|
||||
<label><span>{{ tt('password') }}</span><n-input v-model:value="form.admin.password" type="password" show-password-on="click" /></label>
|
||||
<label><span>{{ tt('realName') }}</span><n-input v-model:value="form.admin.realName" /></label>
|
||||
</section>
|
||||
|
||||
<section class="box">
|
||||
<h2>{{ tt('storage') }}</h2>
|
||||
<div class="box-head">
|
||||
<h2>{{ tt('storage') }}</h2>
|
||||
<n-button size="tiny" :loading="testingStorage" @click="testStorage">{{ tt('testConnection') }}</n-button>
|
||||
</div>
|
||||
<label>
|
||||
<span>{{ tt('driver') }}</span>
|
||||
<span>{{ tt('driver') }}<i class="req">*</i></span>
|
||||
<n-select v-model:value="form.storage.driver" :options="driverOptions" class="full" />
|
||||
</label>
|
||||
<label><span>{{ tt('localDir') }}</span><n-input v-model:value="form.storage.localDir" /></label>
|
||||
<label><span>{{ tt('cdnBaseUrl') }}</span><n-input v-model:value="form.storage.cdnBaseUrl" /></label>
|
||||
<template v-if="form.storage.driver === 'oss'">
|
||||
<label><span>Endpoint</span><n-input v-model:value="form.storage.ossEndpoint" /></label>
|
||||
<label><span>Region</span><n-input v-model:value="form.storage.ossRegion" /></label>
|
||||
<label><span>Bucket</span><n-input v-model:value="form.storage.ossBucket" /></label>
|
||||
<label><span>AccessKey ID</span><n-input v-model:value="form.storage.ossAccessKeyId" /></label>
|
||||
<label><span>AccessKey Secret</span><n-input v-model:value="form.storage.ossAccessKeySecret" type="password" show-password-on="click" /></label>
|
||||
<template v-if="form.storage.driver === 'local'">
|
||||
<label><span>{{ tt('localDir') }}<i class="req">*</i></span><n-input v-model:value="form.storage.localDir" /></label>
|
||||
</template>
|
||||
<template v-else>
|
||||
<label><span>Endpoint<i class="req">*</i></span><n-input v-model:value="form.storage.ossEndpoint" /></label>
|
||||
<label><span>Region</span><n-input v-model:value="form.storage.ossRegion" /></label>
|
||||
<label><span>Bucket<i class="req">*</i></span><n-input v-model:value="form.storage.ossBucket" /></label>
|
||||
<label><span>AccessKey ID<i class="req">*</i></span><n-input v-model:value="form.storage.ossAccessKeyId" /></label>
|
||||
<label><span>AccessKey Secret<i class="req">*</i></span><n-input v-model:value="form.storage.ossAccessKeySecret" type="password" show-password-on="click" /></label>
|
||||
</template>
|
||||
<label><span>CDN</span><n-input v-model:value="form.storage.cdnBaseUrl" placeholder="https://cdn.example.com" /></label>
|
||||
<p class="hint">{{ tt('cdnHint') }}</p>
|
||||
<p v-if="storageTest" class="test-result" :class="storageTest.ok ? 'ok' : 'fail'">{{ storageTest.msg }}</p>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@@ -95,19 +101,13 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import ThemeSwitch from '@/components/ThemeSwitch.vue';
|
||||
import LangSwitch from '@/components/LangSwitch.vue';
|
||||
|
||||
interface InstallForm {
|
||||
appName: string;
|
||||
baseUrl: string;
|
||||
mysql: {
|
||||
host: string;
|
||||
port: number;
|
||||
database: string;
|
||||
username: string;
|
||||
password: string;
|
||||
adminUsername: string;
|
||||
adminPassword: string;
|
||||
};
|
||||
mysql: { host: string; port: number; database: string; username: string; password: string };
|
||||
redis: { host: string; port: number; password: string };
|
||||
admin: { username: string; password: string; realName: string };
|
||||
storage: {
|
||||
@@ -123,7 +123,6 @@ interface InstallForm {
|
||||
}
|
||||
|
||||
const { t } = useI18n();
|
||||
// 安装向导文案统一走全局 locale(pages.install.*),保持与后台其它页面一致
|
||||
function tt(key: string): string {
|
||||
return t(`pages.install.${key}`);
|
||||
}
|
||||
@@ -136,15 +135,7 @@ const driverOptions = computed(() => [
|
||||
const form = reactive<InstallForm>({
|
||||
appName: tt('defaultAppName'),
|
||||
baseUrl: location.origin,
|
||||
mysql: {
|
||||
host: '127.0.0.1',
|
||||
port: 3306,
|
||||
database: 'artveris',
|
||||
username: 'artveris',
|
||||
password: '',
|
||||
adminUsername: '',
|
||||
adminPassword: '',
|
||||
},
|
||||
mysql: { host: '127.0.0.1', port: 3306, database: 'artveris', username: 'artveris', password: '' },
|
||||
redis: { host: '127.0.0.1', port: 6379, password: '' },
|
||||
admin: { username: 'admin', password: '', realName: tt('defaultAdminName') },
|
||||
storage: {
|
||||
@@ -166,16 +157,18 @@ const error = ref('');
|
||||
const success = ref('');
|
||||
const testingMysql = ref(false);
|
||||
const testingRedis = ref(false);
|
||||
const testingStorage = ref(false);
|
||||
const mysqlTest = ref<{ ok: boolean; msg: string } | null>(null);
|
||||
const redisTest = ref<{ ok: boolean; msg: string } | null>(null);
|
||||
const storageTest = ref<{ ok: boolean; msg: string } | null>(null);
|
||||
|
||||
function goAdmin(): void {
|
||||
location.href = '/admin';
|
||||
}
|
||||
|
||||
async function testConnection(payload: Record<string, unknown>): Promise<{ ok: boolean; msg: string }> {
|
||||
async function post(path: string, payload: Record<string, unknown>): Promise<{ ok: boolean; msg: string }> {
|
||||
try {
|
||||
const res = await fetch('/api/install/test-connection', {
|
||||
const res = await fetch(path, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload),
|
||||
@@ -191,7 +184,7 @@ async function testConnection(payload: Record<string, unknown>): Promise<{ ok: b
|
||||
async function testMysql(): Promise<void> {
|
||||
testingMysql.value = true;
|
||||
mysqlTest.value = null;
|
||||
mysqlTest.value = await testConnection({
|
||||
mysqlTest.value = await post('/api/install/test-connection', {
|
||||
target: 'mysql',
|
||||
host: form.mysql.host,
|
||||
port: form.mysql.port,
|
||||
@@ -205,7 +198,7 @@ async function testMysql(): Promise<void> {
|
||||
async function testRedis(): Promise<void> {
|
||||
testingRedis.value = true;
|
||||
redisTest.value = null;
|
||||
redisTest.value = await testConnection({
|
||||
redisTest.value = await post('/api/install/test-connection', {
|
||||
target: 'redis',
|
||||
host: form.redis.host,
|
||||
port: form.redis.port,
|
||||
@@ -214,6 +207,13 @@ async function testRedis(): Promise<void> {
|
||||
testingRedis.value = false;
|
||||
}
|
||||
|
||||
async function testStorage(): Promise<void> {
|
||||
testingStorage.value = true;
|
||||
storageTest.value = null;
|
||||
storageTest.value = await post('/api/install/test-storage', { ...form.storage });
|
||||
testingStorage.value = false;
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const res = await fetch('/api/install/status');
|
||||
@@ -243,7 +243,7 @@ async function pollUntilReady(): Promise<void> {
|
||||
const body = await res.json();
|
||||
if (body.data?.installed) break;
|
||||
} catch {
|
||||
// 服务重启期间请求失败属正常,继续轮询
|
||||
// 服务重启期间请求失败属正常
|
||||
}
|
||||
}
|
||||
goAdmin();
|
||||
@@ -273,7 +273,6 @@ async function submit(): Promise<void> {
|
||||
|
||||
<style scoped>
|
||||
.install-page {
|
||||
/* 全局 #app 为 overflow-y:hidden,安装页是独立满屏路由,需自身承载纵向滚动 */
|
||||
height: 100vh;
|
||||
overflow-y: auto;
|
||||
padding: 24px;
|
||||
@@ -299,6 +298,11 @@ async function submit(): Promise<void> {
|
||||
padding-bottom: 14px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.head-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.brand h1 {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
@@ -337,17 +341,11 @@ async function submit(): Promise<void> {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
.test-result {
|
||||
margin: 2px 0 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
word-break: break-all;
|
||||
}
|
||||
.test-result.ok {
|
||||
color: #18a058;
|
||||
}
|
||||
.test-result.fail {
|
||||
color: #d03050;
|
||||
.sub {
|
||||
margin: 14px 0 10px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--n-text-color-2, #526070);
|
||||
}
|
||||
.box label {
|
||||
display: grid;
|
||||
@@ -360,6 +358,11 @@ async function submit(): Promise<void> {
|
||||
font-size: 13px;
|
||||
color: var(--n-text-color-2, #526070);
|
||||
}
|
||||
.req {
|
||||
color: #d03050;
|
||||
font-style: normal;
|
||||
margin-left: 2px;
|
||||
}
|
||||
.full {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -369,6 +372,18 @@ async function submit(): Promise<void> {
|
||||
line-height: 1.5;
|
||||
color: var(--n-text-color-3, #6a7687);
|
||||
}
|
||||
.test-result {
|
||||
margin: 6px 0 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
word-break: break-all;
|
||||
}
|
||||
.test-result.ok {
|
||||
color: #18a058;
|
||||
}
|
||||
.test-result.fail {
|
||||
color: #d03050;
|
||||
}
|
||||
.mt {
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user