fix(admin): 生产环境隐藏并禁用自动化测试

侧栏与路由按服务端 NODE_ENV 控制;可通过 ALLOW_SMOKE_TESTS=true 临时开启。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-11 17:52:07 +08:00
parent e469611138
commit 283252c841
7 changed files with 94 additions and 15 deletions

View File

@@ -0,0 +1,24 @@
import { ref } from 'vue';
import api from '../api';
const allowed = ref<boolean | null>(null);
let loadPromise: Promise<void> | null = null;
export function useSmokeTestsAllowed() {
async function ensureLoaded() {
if (allowed.value !== null) return;
if (!loadPromise) {
loadPromise = (async () => {
try {
const { data } = await api.get('/admin/system/smoke-tests');
allowed.value = !!data.data?.allowed;
} catch {
allowed.value = false;
}
})();
}
await loadPromise;
}
return { allowed, ensureLoaded };
}