refactor: release v1.0.5 安全精简与网站发布
web-platform-ci / Standalone decision service (no cloud credentials) (push) Has been cancelled
web-platform-ci / TypeScript, lint, unit, build (push) Has been cancelled
web-platform-ci / Playwright E2E (push) Has been cancelled
lekiwi-compatibility / cpu-compatibility (push) Has been cancelled

This commit is contained in:
2026-09-29 09:55:08 +08:00
parent 7ebe9092ba
commit 26bb5634bd
64 changed files with 9048 additions and 3688 deletions
@@ -0,0 +1,34 @@
import { useCallback, useRef, useState } from 'react';
import type { AppDiagnostic } from '../../stores/useAppStore';
import type { WorkbenchNotification } from '../components/NotificationCenter';
export function diagnostic(
category: AppDiagnostic['category'],
error: unknown,
path?: string,
): AppDiagnostic {
const detail = error instanceof Error ? error.message : String(error);
return { category, summary: `${category}失败`, detail, path, at: Date.now() };
}
/** 通知状态唯一所有者;发布函数稳定,供加载事务与用户动作共享。 */
export function useWorkbenchFeedback() {
const notificationId = useRef(0);
const [notifications, setNotifications] = useState<WorkbenchNotification[]>([]);
const [toast, setToast] = useState<WorkbenchNotification>();
const publishNotice = useCallback((input: Omit<WorkbenchNotification, 'id' | 'at'>) => {
const notice: WorkbenchNotification = {
id: ++notificationId.current,
...input,
at: Date.now(),
};
setNotifications((items) => [notice, ...items].slice(0, 20));
setToast(notice);
}, []);
const notify = useCallback(
(title: string, detail: string, tone: WorkbenchNotification['tone'] = 'success') =>
publishNotice({ title, detail, tone }),
[publishNotice],
);
return { notifications, setNotifications, toast, setToast, publishNotice, notify };
}