forked from xiongyuxing/tiku-backend.net
fix: update runtime configuration and improve backend status messages for demo mode
This commit is contained in:
@@ -343,13 +343,13 @@ function saveData() {
|
||||
}
|
||||
}
|
||||
function backendStatusLabel() {
|
||||
if (!platformApi?.isEnabled()) return '静态演示数据';
|
||||
if (!platformApi?.isEnabled()) return '演示模式可用';
|
||||
if (state.apiConnection === 'connecting') return '正在连接后端';
|
||||
if (state.apiConnection === 'connected') {
|
||||
const partial = state.apiFailedOperations ? ` · ${state.apiFailedOperations} 项无权限/失败` : '';
|
||||
return `后端已连接${partial}`;
|
||||
}
|
||||
return '后端不可用 · 已保留静态演示';
|
||||
return '演示模式可用';
|
||||
}
|
||||
function backendErrorText(error, fallback = '平台接口请求失败') {
|
||||
if (!error) return fallback;
|
||||
@@ -427,7 +427,7 @@ async function hydrateFromBackend({ silent = false } = {}) {
|
||||
state.apiConnection = 'degraded';
|
||||
state.apiFailedOperations = 1;
|
||||
render();
|
||||
if (!silent) showToast(`${backendErrorText(error, '后端连接失败')} · 已保留静态演示`, 'error');
|
||||
if (!silent) showToast(`${backendErrorText(error, '后端连接失败')} · 已切换至演示模式`, 'error');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
<link rel="icon" href="./assets/logo.png" />
|
||||
<link rel="stylesheet" href="./styles.css?v=20260728-api2" />
|
||||
<script src="https://unpkg.com/lucide@0.468.0/dist/umd/lucide.min.js" defer onerror="document.documentElement.classList.add('icons-unavailable')"></script>
|
||||
<script src="./runtime-config.js?v=20260730-question-bank1" defer></script>
|
||||
<script src="./runtime-config.js?v=20260730-demo1" defer></script>
|
||||
<script src="./platform-auth.js?v=20260730-question-bank1" defer></script>
|
||||
<script src="./spec-contract.js?v=20260730-question-bank1" defer></script>
|
||||
<script src="./platform-api.js?v=20260730-question-bank1" defer></script>
|
||||
<script src="./app.js?v=20260730-question-bank1" defer></script>
|
||||
<script src="./app.js?v=20260730-demo1" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="platformAuthGate" class="platform-auth-gate" hidden></div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* 平台端公开运行时配置。
|
||||
*
|
||||
* 默认连接同源后端。其他部署环境可在本文件之前注入同名对象,
|
||||
* 默认使用可交互演示数据。其他部署环境可在本文件之前注入同名对象,
|
||||
* 或在部署时替换本文件。不要把 access token、service role key 或任何服务端密钥
|
||||
* 写入静态文件;getAccessToken 应从当前平台登录会话中按需读取短期 JWT。
|
||||
*
|
||||
@@ -16,9 +16,9 @@
|
||||
* };
|
||||
*/
|
||||
window.GONGXUE_PLATFORM_RUNTIME_CONFIG = window.GONGXUE_PLATFORM_RUNTIME_CONFIG || {
|
||||
mode: 'api',
|
||||
mode: 'mock',
|
||||
apiBaseUrl: '',
|
||||
fallbackToMock: false,
|
||||
fallbackToMock: true,
|
||||
timeoutMs: 10000,
|
||||
getAccessToken: async () => window.GongxuePlatformAuth?.getAccessToken() || '',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user