记录店务端规划刷新目标
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user