- 集成 tauri-plugin-opener:Cargo/lib.rs/capabilities/npm 四处接线,新增 src/openExternal.ts(桌面走 opener,浏览器回退 window.open,相对路径绝对化) - 关于页 4 个链接、活动栏官网菜单、代理错误横幅 2 处健康检查链接全部改走 openExternal,桌面端可正常跳转 - 设置→外观 主题顺序调整为 深色/浅色/跟随系统 - release 二进制重编并验证(浏览器实测关于页链接可开文档页) - 附带工作区中未提交的扁平化重构现状(另一会话进行中) - homepage 落地页与文档终检通过(8787 / 与 /docs 双 200)
43 lines
1.9 KiB
TypeScript
43 lines
1.9 KiB
TypeScript
export type JsonLine = {
|
|
path: string;
|
|
depth: number;
|
|
key?: string;
|
|
kind: "open" | "close" | "value";
|
|
text: string;
|
|
tone?: "string" | "number" | "boolean" | "null";
|
|
foldable?: boolean;
|
|
expanded?: boolean;
|
|
};
|
|
|
|
/** Pretty JSON lines retain separators and paths, including after collapsing branches. */
|
|
export function jsonLines(value: unknown, collapsed: ReadonlySet<string> = new Set()): JsonLine[] {
|
|
const lines: JsonLine[] = [];
|
|
function visit(current: unknown, path: string, depth: number, key: string | undefined, last: boolean) {
|
|
const comma = last ? "" : ",";
|
|
if (current !== null && typeof current === "object") {
|
|
const array = Array.isArray(current);
|
|
const entries: [string, unknown][] = array
|
|
? current.map((item, index) => [String(index), item])
|
|
: Object.entries(current);
|
|
const open = array ? "[" : "{";
|
|
const close = array ? "]" : "}";
|
|
if (entries.length === 0) {
|
|
lines.push({ path, depth, key, kind: "value", text: `${open}${close}${comma}` });
|
|
} else if (collapsed.has(path)) {
|
|
lines.push({ path, depth, key, kind: "open", text: `${open}…${close}${comma}`, foldable: true, expanded: false });
|
|
} else {
|
|
lines.push({ path, depth, key, kind: "open", text: open, foldable: true, expanded: true });
|
|
entries.forEach(([childKey, childValue], index) => {
|
|
visit(childValue, `${path}/${childKey.replace(/~/g, "~0").replace(/\//g, "~1")}`, depth + 1, array ? undefined : childKey, index === entries.length - 1);
|
|
});
|
|
lines.push({ path, depth, kind: "close", text: `${close}${comma}` });
|
|
}
|
|
return;
|
|
}
|
|
const tone = current === null ? "null" : typeof current as "string" | "number" | "boolean";
|
|
lines.push({ path, depth, key, kind: "value", tone, text: `${JSON.stringify(current)}${comma}` });
|
|
}
|
|
visit(value, "$", 0, undefined, true);
|
|
return lines;
|
|
}
|