feat(admin): 管理后台 - 统一桌面端信息架构与视觉规范
This commit is contained in:
1 parent
08937417ec
commit
90da7298b6
32 files changed
+17069
-1859
No files matched your search
@@ -0,0 +1,56 @@
|
||||
const ANNOUNCEMENT_REVIEW_STORAGE_KEY = "yingce.admin.announcements.pending-review";
|
||||
|
||||
export type AnnouncementPendingReview = {
|
||||
operation: "create" | "update" | "close";
|
||||
targetId?: string;
|
||||
previousTitle?: string;
|
||||
title: string;
|
||||
content: string;
|
||||
level: "info" | "success" | "warning" | "critical";
|
||||
notice: string;
|
||||
requestedAt: string;
|
||||
};
|
||||
|
||||
export function readAnnouncementPendingReview(): AnnouncementPendingReview | null {
|
||||
if (typeof window === "undefined") return null;
|
||||
try {
|
||||
const value = window.sessionStorage.getItem(ANNOUNCEMENT_REVIEW_STORAGE_KEY);
|
||||
if (!value) return null;
|
||||
const parsed = JSON.parse(value) as Partial<AnnouncementPendingReview>;
|
||||
if (
|
||||
(parsed.operation !== "create" && parsed.operation !== "update" && parsed.operation !== "close") ||
|
||||
typeof parsed.title !== "string" ||
|
||||
typeof parsed.content !== "string" ||
|
||||
(parsed.level !== "info" && parsed.level !== "success" && parsed.level !== "warning" && parsed.level !== "critical") ||
|
||||
typeof parsed.notice !== "string" ||
|
||||
!parsed.notice ||
|
||||
typeof parsed.requestedAt !== "string" ||
|
||||
Number.isNaN(new Date(parsed.requestedAt).getTime()) ||
|
||||
(parsed.targetId !== undefined && (typeof parsed.targetId !== "string" || !parsed.targetId)) ||
|
||||
(parsed.previousTitle !== undefined && typeof parsed.previousTitle !== "string") ||
|
||||
(parsed.operation !== "create" && (typeof parsed.targetId !== "string" || !parsed.targetId))
|
||||
)
|
||||
return null;
|
||||
return parsed as AnnouncementPendingReview;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function writeAnnouncementPendingReview(review: AnnouncementPendingReview) {
|
||||
if (typeof window === "undefined") return;
|
||||
try {
|
||||
window.sessionStorage.setItem(ANNOUNCEMENT_REVIEW_STORAGE_KEY, JSON.stringify(review));
|
||||
} catch {
|
||||
// sessionStorage 可能被浏览器策略禁用;页内锁定仍然保持生效。
|
||||
}
|
||||
}
|
||||
|
||||
export function clearAnnouncementPendingReview() {
|
||||
if (typeof window === "undefined") return;
|
||||
try {
|
||||
window.sessionStorage.removeItem(ANNOUNCEMENT_REVIEW_STORAGE_KEY);
|
||||
} catch {
|
||||
// 同上,不让存储策略影响已确认的界面操作。
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user