This commit is contained in:
parent
6c58ee3e96
commit
053b71edc8
@ -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": "下一步",
|
||||
|
||||
@ -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) => {
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -36,6 +36,11 @@ export default defineConfig(({ mode }) => {
|
||||
"/attachments": {
|
||||
target: backendUrl,
|
||||
changeOrigin: false
|
||||
},
|
||||
"/__smail_setup_bootstrap": {
|
||||
target: backendUrl,
|
||||
changeOrigin: false,
|
||||
rewrite: () => "/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user