1、后台系统设置settings页面增加一个开启关闭网站的按钮
2、如果网站关闭,前台页面所有请求暂时跳转单独的页如果网站关闭,前台页面所有请求暂时跳转单独的页面,页面内容 系统正在升级相关信息 3、要提供一个开发人员可以查看真实网站内容的入口
This commit is contained in:
@@ -66,6 +66,12 @@ export async function apiRequest<T>(path: string, options: RequestOptions = {}):
|
||||
if (token) headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
|
||||
// 开发者访问令牌(网站关闭时用于绕过限制)
|
||||
const devAccessToken = localStorage.getItem('dev_access_token');
|
||||
if (devAccessToken) {
|
||||
headers['X-Dev-Access'] = devAccessToken;
|
||||
}
|
||||
|
||||
let bodyStr: string | undefined;
|
||||
if (body !== undefined) {
|
||||
const json = JSON.stringify(body);
|
||||
@@ -110,6 +116,13 @@ export async function apiRequest<T>(path: string, options: RequestOptions = {}):
|
||||
|
||||
// Handle error responses
|
||||
if (!res.ok) {
|
||||
// 网站关闭 → 跳转到维护页面
|
||||
if (res.status === 503 && parsed?.detail?.code === 'SITE_CLOSED') {
|
||||
if (!window.location.pathname.startsWith('/maintenance')) {
|
||||
window.location.href = '/maintenance';
|
||||
}
|
||||
throw new Error(parsed?.detail?.message || '系统正在升级维护');
|
||||
}
|
||||
let msg = parsed?.detail?.message || parsed?.message || `请求失败 (${res.status})`;
|
||||
if (typeof parsed?.detail === 'string') {
|
||||
msg = parsed.detail;
|
||||
|
||||
Reference in New Issue
Block a user