From bf29b04345ce1e9b081246ecfb008eda01632e2e Mon Sep 17 00:00:00 2001 From: xiaowang <2161656029@qq.com> Date: Mon, 13 Jul 2026 15:21:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=BA=97=E5=8A=A1=E7=AB=AF?= =?UTF-8?q?=E8=A7=84=E5=88=92=E5=88=B7=E6=96=B0=E7=9B=AE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JY-Salon-Front/src/utils/storage.ts | 34 +++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/JY-Salon-Front/src/utils/storage.ts b/JY-Salon-Front/src/utils/storage.ts index c61b0755..20546800 100644 --- a/JY-Salon-Front/src/utils/storage.ts +++ b/JY-Salon-Front/src/utils/storage.ts @@ -17,14 +17,34 @@ export const removeStorage = (key: string): void => { const PLANNING_REFRESH_KEY = 'planningNeedRefresh' -export const markPlanningRefresh = (): void => { - window.localStorage.setItem(PLANNING_REFRESH_KEY, '1') +export interface PlanningRefreshTarget { + date?: string + artistId?: string } -export const consumePlanningRefresh = (): boolean => { - const marked = window.localStorage.getItem(PLANNING_REFRESH_KEY) === '1' - if (marked) { - window.localStorage.removeItem(PLANNING_REFRESH_KEY) +export const markPlanningRefresh = (target?: PlanningRefreshTarget): void => { + const payload = { + date: target?.date || '', + artistId: target?.artistId || '' + } + window.localStorage.setItem(PLANNING_REFRESH_KEY, JSON.stringify(payload)) +} + +export const consumePlanningRefresh = (): PlanningRefreshTarget | null => { + const raw = window.localStorage.getItem(PLANNING_REFRESH_KEY) + if (!raw) { + return null + } + window.localStorage.removeItem(PLANNING_REFRESH_KEY) + if (raw === '1') { + return {} + } + const parsed = JSON.parse(raw) as PlanningRefreshTarget + if (parsed === null || typeof parsed !== 'object') { + throw new Error('规划刷新标记格式不正确,无法读取 planningNeedRefresh') + } + return { + date: typeof parsed.date === 'string' ? parsed.date : '', + artistId: typeof parsed.artistId === 'string' ? parsed.artistId : '' } - return marked }