桌面侧栏可在 200 到 360 像素之间拖宽,拖到最左收起,宽度记在本机。手机从左边滑出。会话在同一组里拖动排序,顺序写入可空的 sidebar_order,收藏仍置顶。账户菜单、设置、反馈和退出确认改用组件库。顶栏点数只显示图标和数字。启程清单还在。菜单、拖宽、拖动排序和翻页在首屏之后再载入。
自测:tsc 退出码 0;npm run lint 0 error、121 warning;改到的前端测试 205 项全过;npm run build 后首页仍是 static;首屏 gzip 630350,相对 8f7c0f7d 的 621226 为 +1.47%。test:db 92 项里 79 过、13 败,失败名与 Windows 已知清单一致,排序列在通过的 ok 37。没有跑全量 npm test,没有跑 Python 快速门。没有登录态,没有在浏览器里拖侧栏。
Co-Authored-By: Grok (agent loop)
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
"use client";
|
|
|
|
import { useSyncExternalStore } from "react";
|
|
|
|
import type { SortableSessionGroup } from "@/components/sidebar-session-sortable";
|
|
|
|
type SortableModule = {
|
|
SortableSessionGroup: typeof SortableSessionGroup;
|
|
};
|
|
|
|
let loaded: SortableModule | null = null;
|
|
let started = false;
|
|
const listeners = new Set<() => void>();
|
|
|
|
function notify() {
|
|
for (const listener of listeners) listener();
|
|
}
|
|
|
|
function subscribe(listener: () => void) {
|
|
listeners.add(listener);
|
|
if (!started) {
|
|
started = true;
|
|
void import("@/components/sidebar-session-sortable").then((mod) => {
|
|
loaded = { SortableSessionGroup: mod.SortableSessionGroup };
|
|
notify();
|
|
}).catch(() => {
|
|
started = false;
|
|
});
|
|
}
|
|
return () => listeners.delete(listener);
|
|
}
|
|
|
|
function snapshot() {
|
|
return loaded;
|
|
}
|
|
|
|
/** Client-only. The server snapshot stays null so the row list paints before dnd-kit arrives. */
|
|
export function useSortableSessions(): SortableModule | null {
|
|
return useSyncExternalStore(subscribe, snapshot, () => null);
|
|
}
|