修复初始化向导开发环境授权流程
Some checks are pending
Security Checks / security (push) Waiting to run

This commit is contained in:
smail 2026-09-01 00:04:12 +08:00
parent 6c58ee3e96
commit 053b71edc8
4 changed files with 28 additions and 2 deletions

View File

@ -59,6 +59,7 @@ const lang = {
"err_admin_pwd_length": "管理员密码长度必须为 8 到 12 个字节",
"admin_pwd_desc": "请输入 8 到 12 个字节的管理员密码",
"setup_failed": "初始化操作失败,请查看终端日志",
"setup_service_unavailable": "初始化服务未启动,请先启动 Smail 后端服务",
"setOther": "其他设置",
"welcome": "欢迎",
"next": "下一步",

View File

@ -53,7 +53,7 @@ function isSetupRequest(config) {
} catch (error) {
path = rawUrl
}
return path === '/api/setup' || path === '/api/v1/setup'
return path === '/api/setup' || path === '/api/v1/setup' || path === '/__smail_setup_bootstrap'
}
http.interceptors.response.use(async (response) => {

View File

@ -14,7 +14,27 @@ import {http} from "@/utils/axios";
import {buildFinalURL as buildSetupFinalURL, probeService} from './SetupNavigation.js'
const setupRequest = (payload) => http.post("/api/v1/setup", payload).then((response) => {
let setupBootstrapPromise = null
const ensureSetupSession = () => {
if (!import.meta.env.DEV) {
return Promise.resolve()
}
if (!setupBootstrapPromise) {
setupBootstrapPromise = http.get("/__smail_setup_bootstrap").catch((error) => {
setupBootstrapPromise = null
if (error?.response?.status === 500 || !error?.response) {
throw new Error(lang.setup_service_unavailable)
}
throw error
})
}
return setupBootstrapPromise
}
const setupRequest = (payload) => ensureSetupSession().then(() => http.post("/api/v1/setup", payload)).then((response) => {
if (!response || typeof response.errorNo !== "number") {
throw new Error(lang.setup_failed)
}

View File

@ -36,6 +36,11 @@ export default defineConfig(({ mode }) => {
"/attachments": {
target: backendUrl,
changeOrigin: false
},
"/__smail_setup_bootstrap": {
target: backendUrl,
changeOrigin: false,
rewrite: () => "/"
}
}
}