feat(webui): static note / link / account widgets (B2)
Three opt-in static widgets join the GRID_WIDGETS catalogue (hidden by default — enabled from the layout editor), with content stored in block.config: - 便签 (note): pre-wrap plain text, capped at 4000 chars (under the server's 4096-byte config cap). No Markdown. - 链接卡 (link): label + http(s)-only url (javascript:/data: rejected) + an icon from a curated lucide set; renders as a clickable card. - 账号快捷卡 (account): a specified uin's avatar/nickname/online dot, with a datalist of connected accounts in the config form. GridWidgetSpec gains `defaultVisible`, honored by defaultOverviewGrid/Mobile and migrateOverviewBlocks; reconcileLayoutItems gains a `hiddenByDefault` set so the mobile catalogue appends these hidden too. parse* validators keep config total over corrupt input.
This commit is contained in:
4 files changed
+254
-14
No files matched your search
@@ -50,12 +50,14 @@ export const DEFAULT_PAGES: UiPages = defaultPages();
|
||||
/**
|
||||
* Order + visibility for a known catalogue: keep stored items that still exist
|
||||
* (in their stored order + visibility), then append any catalogue entries the
|
||||
* stored layout predates (visible). `pinned` ids are forced visible.
|
||||
* stored layout predates. `pinned` ids are forced visible; ids in
|
||||
* `hiddenByDefault` are appended hidden (opt-in widgets), otherwise visible.
|
||||
*/
|
||||
export function reconcileLayoutItems(
|
||||
stored: UiLayoutItem[] | undefined,
|
||||
known: readonly string[],
|
||||
pinned: readonly string[] = [],
|
||||
hiddenByDefault: ReadonlySet<string> = new Set(),
|
||||
): UiLayoutItem[] {
|
||||
const knownSet = new Set(known);
|
||||
const seen = new Set<string>();
|
||||
@@ -66,7 +68,7 @@ export function reconcileLayoutItems(
|
||||
out.push({ id: item.id, visible: pinned.includes(item.id) ? true : item.visible !== false });
|
||||
}
|
||||
for (const id of known) {
|
||||
if (!seen.has(id)) out.push({ id, visible: true });
|
||||
if (!seen.has(id)) out.push({ id, visible: !hiddenByDefault.has(id) });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user