aps-agent/apps/web/src/features/devtools.ts

26 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ============================================================
// 开发者/运维入口可见性(moduleId: web-feature-devtools)
// 计划员界面默认不出现开发入口:多智能体编排 / 重生中心 / 算法异步任务与
// MCP 插件登记 / 微观审计回放 / 开发者工具菜单。
// 排查时用带 ?devtools=1 的地址打开一次即可记住,或控制台执行
// localStorage.setItem('aps.devtools', '1') 后刷新;?devtools=0 关闭。
// ============================================================
const KEY = 'aps.devtools';
let cached: boolean | null = null;
export function devToolsEnabled(): boolean {
if (cached != null) return cached;
if (typeof window === 'undefined') return false;
try {
const q = new URLSearchParams(window.location.search).get('devtools');
if (q === '1') localStorage.setItem(KEY, '1');
else if (q === '0') localStorage.removeItem(KEY);
cached = localStorage.getItem(KEY) === '1';
} catch {
cached = false;
}
return cached;
}