- 后端新增 y_log 公开只读配置:YLogConfig + AppConfig.y_log + GET /api/public/config/y-log,地址写在 config.yaml(mtime 热重载) - 前端核心 src/core/log/:writeYLog(双门控/异步即发即忘/永不抛错/ 去ip-host/对象序列化裁剪/optResult恒0)+ 配置加载 + token1 隔离存取 - 登录(token)持久化 token1 并报登录、登出先报后清;启动预热配置 - 各 API client 成功路径埋点:敏感词/菜单/按钮/技能地址/轻应用、 会商草稿+任务草稿+后台任务、智能体/定时任务/知识库、Word导出, 以及问答完成钩子(ChatPage/AgentChatPage onFinish) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
/**
|
||
* token1(token 登录用的上游 token,即 URL 参数 ``?authToken=``)的存取。
|
||
*
|
||
* 复用 [[scoped-storage]] 的 ``authStorage*``:嵌入(iframe)态自动落 sessionStorage、
|
||
* 正常态落 localStorage,使 iframe 里登录的用户 token1 与正常标签页**完全隔离**、
|
||
* 互不污染(与其它鉴权键同一隔离语义)。
|
||
*
|
||
* 只有用 token 登录(存在 token1)才上报操作日志;非 token 登录不写 token1,
|
||
* 该会话从此不上报(见 [[y-log]])。
|
||
*/
|
||
|
||
import {
|
||
authStorageGet,
|
||
authStorageRemove,
|
||
authStorageSet,
|
||
} from "@/core/auth/scoped-storage";
|
||
|
||
const Y_LOG_TOKEN_KEY = "ylog.token1";
|
||
|
||
/** 持久化 token1(token 登录成功后调用;空值忽略)。 */
|
||
export function persistYLogToken(token: string | null | undefined): void {
|
||
const t = token?.trim();
|
||
if (t) authStorageSet(Y_LOG_TOKEN_KEY, t);
|
||
}
|
||
|
||
/** 读 token1(无则返回 null → 不上报)。 */
|
||
export function readYLogToken(): string | null {
|
||
return authStorageGet(Y_LOG_TOKEN_KEY);
|
||
}
|
||
|
||
/** 清除 token1(登出时调用)。 */
|
||
export function clearYLogToken(): void {
|
||
authStorageRemove(Y_LOG_TOKEN_KEY);
|
||
}
|