feat: 安装成功后进入等待页,重启就绪后自动跳转管理端登录页
- Install.vue 提交成功切到带加载动画的等待页,轮询系统就绪后自动进入后台 - 超时兜底显示手动提示与进入按钮;移除原 success 提示条与 done 文案
This commit is contained in:
@@ -273,6 +273,7 @@
|
||||
- 安装页 `baseUrlHint`(中英):三行换行说明对外访问地址(域名 / IP:端口 / 本地默认);`.hint` 使用 `white-space: pre-line` 渲染 `\n`。
|
||||
- 安装页错误信息穿透(2026-07-09):`InstallService.testConnection/testStorage/install` 内部原先 `throw new Error(...)`,会被全局 `AllExceptionsFilter` 当作未知异常统一替换为「服务器内部错误」……已用直连接口验证。
|
||||
- 安装提交 JSON 解析失败(2026-07-09):根因是安装成功后 `process.exit(0)`(600ms)在本地 dev 环境掐断 HTTP 连接,前端 `res.json()` 收到空 body 报 `Unexpected end of JSON input`。修复:① `ARTVERIS_INSTALL_MODE=1` 本地安装调试不再 `process.exit`,保证 JSON 响应完整返回;生产环境延迟 2.5s 再退出供 PM2/Docker 重启。② `runPrismaMigrate` 失败改为 `BusinessException` 透传「数据库迁移失败:…」。③ `status()` 新增 `needsDevRestart`(本地 .env 已写但进程仍为 InstallAppModule)。④ `Install.vue` 用 `parseApiBody` 安全解析空/非法 JSON。
|
||||
- 安装完成等待页(2026-07-09):`Install.vue` 提交成功后不再用 success alert,而是切到独立「等待页」(`restarting` 状态:大号 `n-spin` + `restartTitle`/`restartHint` 文案),持续 `pollUntilReady()` 轮询直到系统完全重启就绪,再 `goAdmin()` 自动进入管理端登录页;超时(`restartTimedOut`,多为 `--install-mode` 调试)才显示 `doneLocalDev` 手动提示 + 进入按钮。移除了原 `success` ref 与 `done` 文案。
|
||||
- vite dev 访问体验(2026-07-09):① admin/client 的 base 分别为 `/admin/`、`/trace/`,dev 下直接访问 `/admin`(无尾斜杠)或根 `/` 时 vite 只提示 "did you mean /admin/" 不跳转——两个 `vite.config.ts` 各加 `redirectToBase` 插件(`configureServer` 中间件),把 `/` 与不带尾斜杠的 base 302 到带尾斜杠的 base(保留 query)。② admin 代理 `/api` 增加 `configure` 错误处理 `onProxyError`:安装完成自动切换、API 重启的空档里前端仍在轮询 `/api/install/status`,连接被拒时返回 503 让前端静默重试,避免大段 `ECONNREFUSED` 堆栈。(生产单端口由 API `mountSpa` 托管 `/admin`→index,无此问题。)
|
||||
- 本地 dev 进程管理:`--stop` + 安装后自动切换(2026-07-09,明确不引入 PM2):本地 dev 仍是「前台阻塞 + Job Object/控制台事件整树清理」模型,PM2 仅用于生产(build.py 的 `ecosystem.config.cjs`)。新增两点 PM2 式体验:① `python scripts/dev.py --stop`:复用 `kill_project_servers(ports)` 一键停掉 api/admin/client 后退出,零新依赖。② 安装完成自动切正式模式:无 `.env` 进入安装向导后,`dev.py` 用 `wait_for_install_env(ENV_FILE, api_proc)` 持续监听根 `.env` 出现——因后端在迁移+建超管全部成功后**最后一步**才写 `.env`,失败尝试与填写过程都不写,故「文件出现且非空」是安全的完成信号,**天然避开安装中重启**;一旦检测到即 `stop_proc_tree` 安装 API + `free_port(3000)`,保留 admin vite 不断连,以正式模式重启 `dev:api`+`dev:client`(不再迁移/种子,避免覆盖向导设置的管理员),随后 `p.wait()` 阻塞,Ctrl+C 仍整树清理。`--install-mode` 调试模式写临时 `.env.install-dev`、不自动切换(保留手动重run)。前端 `submit()` 相应简化为:成功后统一 `pollUntilReady()`(等 `installed && !needsDevRestart`)就绪跳后台,超时兜底提示 `doneLocalDev`。`dev.py` 导入补 `free_port`/`stop_proc_tree`。验证:api/admin build 通过、`py_compile` 通过。
|
||||
|
||||
|
||||
@@ -230,7 +230,8 @@
|
||||
"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…",
|
||||
"restartTitle": "Starting the system",
|
||||
"restartHint": "Setup is complete. The service is restarting and loading the configuration, please wait. You will be redirected to the admin sign-in page automatically…",
|
||||
"doneLocalDev": "Setup complete. If it does not open the admin automatically, rerun python scripts/dev.py to enter normal mode.",
|
||||
"emptyResponse": "The server returned no valid response. Retry later or check server logs.",
|
||||
"invalidResponse": "The server returned invalid data",
|
||||
|
||||
@@ -230,7 +230,8 @@
|
||||
"cdnBaseUrl": "CDN 地址",
|
||||
"cdnHint": "CDN 加速地址;如不启用可留空(为空则不开启,直接走源站)。",
|
||||
"failed": "安装失败",
|
||||
"done": "初始化完成,服务正在重启,请稍候…",
|
||||
"restartTitle": "正在启动系统",
|
||||
"restartHint": "初始化已完成,服务正在重启并加载配置,请稍候。完成后将自动进入管理端登录页面…",
|
||||
"doneLocalDev": "初始化完成。若未自动进入后台,请重新运行 python scripts/dev.py 进入正式模式。",
|
||||
"emptyResponse": "服务器未返回有效响应,请稍后重试或查看服务端日志",
|
||||
"invalidResponse": "服务器返回了无效数据",
|
||||
|
||||
@@ -13,8 +13,15 @@
|
||||
</div>
|
||||
|
||||
<n-spin :show="loading">
|
||||
<div v-if="restarting" class="waiting">
|
||||
<n-spin size="large" />
|
||||
<h2>{{ tt('restartTitle') }}</h2>
|
||||
<p>{{ restartTimedOut ? tt('doneLocalDev') : tt('restartHint') }}</p>
|
||||
<n-button v-if="restartTimedOut" type="primary" @click="goAdmin">{{ tt('enterAdmin') }}</n-button>
|
||||
</div>
|
||||
|
||||
<n-result
|
||||
v-if="installed"
|
||||
v-else-if="installed"
|
||||
status="success"
|
||||
:title="tt('alreadyInstalled')"
|
||||
:description="tt('gotoAdmin')"
|
||||
@@ -103,7 +110,6 @@
|
||||
</ul>
|
||||
|
||||
<n-alert v-if="error" type="error" class="mt" :title="error" />
|
||||
<n-alert v-if="success" type="success" class="mt" :title="success" />
|
||||
|
||||
<div class="wizard-foot">
|
||||
<n-button v-if="step > 0" :disabled="advancing || submitting" @click="step -= 1">{{ tt('prev') }}</n-button>
|
||||
@@ -181,7 +187,8 @@ const submitting = ref(false);
|
||||
const advancing = ref(false);
|
||||
const installed = ref(false);
|
||||
const error = ref('');
|
||||
const success = ref('');
|
||||
const restarting = ref(false);
|
||||
const restartTimedOut = ref(false);
|
||||
const testingMysql = ref(false);
|
||||
const testingRedis = ref(false);
|
||||
const testingStorage = ref(false);
|
||||
@@ -366,7 +373,6 @@ async function pollUntilReady(): Promise<boolean> {
|
||||
|
||||
async function submit(): Promise<void> {
|
||||
error.value = '';
|
||||
success.value = '';
|
||||
submitting.value = true;
|
||||
try {
|
||||
// 安装前先确认存储可用
|
||||
@@ -383,18 +389,19 @@ async function submit(): Promise<void> {
|
||||
if (body && (!res.ok || body.code !== 0)) {
|
||||
throw new Error(body.message || tt('failed'));
|
||||
}
|
||||
installed.value = true;
|
||||
success.value = tt('done');
|
||||
// 统一轮询等待系统就绪:本地 dev.py 会自动停掉安装 API 并以正式模式重启,
|
||||
// 生产由 PM2/Docker 按重启策略拉起;就绪后进入后台。
|
||||
// 进入等待页:服务正在重启,轮询到完全就绪后自动跳转到管理端登录页
|
||||
restarting.value = true;
|
||||
restartTimedOut.value = false;
|
||||
if (await pollUntilReady()) {
|
||||
installed.value = true;
|
||||
goAdmin();
|
||||
} else {
|
||||
// 超时兜底:多为 --install-mode 调试模式(写临时 .env,不会自动切换)
|
||||
success.value = tt('doneLocalDev');
|
||||
restartTimedOut.value = true;
|
||||
}
|
||||
} catch (e) {
|
||||
error.value = (e as Error).message;
|
||||
restarting.value = false;
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
@@ -445,6 +452,25 @@ async function submit(): Promise<void> {
|
||||
.steps {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.waiting {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 48px 16px 40px;
|
||||
text-align: center;
|
||||
}
|
||||
.waiting h2 {
|
||||
margin: 6px 0 0;
|
||||
font-size: 17px;
|
||||
}
|
||||
.waiting p {
|
||||
margin: 0;
|
||||
max-width: 420px;
|
||||
font-size: 13px;
|
||||
line-height: 1.7;
|
||||
color: var(--n-text-color-3, #6a7687);
|
||||
}
|
||||
.box {
|
||||
border: 1px solid var(--border, #e1e7f0);
|
||||
border-radius: 10px;
|
||||
|
||||
Reference in New Issue
Block a user