Files
Volcano-Engine-TTS-UI/router/admin-login.html
T
sun 5113941f44 feat(router): v0.2.4 阶段二 管理入口迁移与前端同步
管理入口从 /admin 迁至 /dashboard:
- /dashboard、/dashboard/voices、/dashboard/settings 为新入口
- 原挂在 /dashboard 上的服务状态预览页(health.html)迁至 /dashboard/status,
  侧边栏新增「观测 → 详细状态」入口
- /admin 及子路径 301 永久重定向到对应新路径(页面用 301 是正确的)
- 静态资源同时注册 /dashboard/ 与 /admin/ 两套路径,
  避免过渡期出现"页面能开但丢样式"

前端同步:
- admin-shell.js:侧边栏导航、登出、登录跳转改指 /dashboard/*
- admin.html / admin-login.html / admin-voices.html / admin-settings.html:
  静态资源引用与登录跳转改指 /dashboard/*
- health.html:改用 admin-shell 的 http 实例并改调 /admin/health、/admin/metrics
  (该实例自动附加 Authorization: Bearer;原实现用裸 axios,不带凭证),
  并加登录校验与「返回控制台」入口
- setup.html:安装完成跳转目标改为 /dashboard,页面内 /admin 文案同步更新
- 各页面的 API 调用路径无需修改:axios baseURL 为 /api,
  故 /voices、/admin/overview 等自动落成 /api/admin/*

controller/setup.go:安装成功响应的 redirect 字段由 /admin 改为 /dashboard。

验证:go build / go vet / go test ./... -count=1 全绿;
另用真实服务器端到端验证:旧入口 301 全部正确、静态资源新旧路径均 200、
管理页面内容协商(html 200 / 非 html 401)、登录页公开、
各页面引用的静态资源均为新路径且无残留旧路径。
2026-10-04 01:17:26 +08:00

57 lines
2.0 KiB
HTML

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>管理后台 · 登录</title>
<script src="https://cdn.bootcdn.net/ajax/libs/vue/3.4.21/vue.global.prod.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/1.6.7/axios.min.js"></script>
<link rel="stylesheet" href="/dashboard/admin.css">
</head>
<body>
<div id="app">
<div class="login-screen">
<div class="login-card">
<div class="login-logo">TTS</div>
<h1>管理后台</h1>
<div class="sub">输入 OPENAI_TTS_API_KEY 登录</div>
<input v-model="keyInput" type="password" placeholder="API Key" @keyup.enter="onLogin" autofocus class="login-input">
<button class="btn btn-primary btn-lg" @click="onLogin" :disabled="!keyInput" style="width: 100%;">登 录</button>
<div v-if="loginErr" class="login-err">⚠ {{ loginErr }}</div>
</div>
</div>
</div>
<script src="/dashboard/admin-shell.js"></script>
<script>
const { createApp, ref } = Vue;
const { http, setKey, clearKey, getKey } = window.admin;
createApp({
setup() {
const keyInput = ref('');
const loginErr = ref('');
// 已登录则直接跳 dashboard
if (getKey()) {
http.get('/admin/overview').then(() => {
location.href = '/dashboard';
}).catch(() => { clearKey(); });
}
const onLogin = async () => {
loginErr.value = '';
try {
await window.admin.login(keyInput.value);
location.href = '/dashboard';
} catch (e) {
loginErr.value = '鉴权失败: ' + (e.response?.data?.error?.message || e.message);
}
};
return { keyInput, loginErr, onLogin };
},
}).mount('#app');
</script>
</body>
</html>