refactor(desktop): organize lib modules by domain

This commit is contained in:
t8y2 committed 2026-07-04 13:53:52 +08:00
1 parent 90f0594e93
commit 7e7c4944e9
700 files changed
+1292 -1264

No files matched your search

@@ -0,0 +1,30 @@
export function expandNestedJsonStringsForCopy(value: unknown): unknown {
if (typeof value === "string") {
return parseNestedJsonString(value) ?? value;
}
if (Array.isArray(value)) {
return value.map(expandNestedJsonStringsForCopy);
}
if (isPlainObject(value)) {
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, expandNestedJsonStringsForCopy(item)]));
}
return value;
}
function parseNestedJsonString(value: string): unknown | undefined {
const trimmed = value.trim();
if (!trimmed || (trimmed[0] !== "{" && trimmed[0] !== "[")) return undefined;
try {
return expandNestedJsonStringsForCopy(JSON.parse(trimmed));
} catch {
return undefined;
}
}
function isPlainObject(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value);
}