fix(client): migrate digital storage keys
This commit is contained in:
@@ -116,7 +116,8 @@ const EVENT_STATUS_FILTERS: Array<{ id: EventStatusFilter; label: string }> = [
|
||||
{ id: 'success', label: '已完成' },
|
||||
{ id: 'danger', label: '异常' },
|
||||
];
|
||||
const WORKDAY_GUIDE_DISMISSED_STORAGE_KEY = 'sgrobot:digital-workday-guide-dismissed-date';
|
||||
const WORKDAY_GUIDE_DISMISSED_STORAGE_KEY = 'qimingclaw:digital-workday-guide-dismissed-date';
|
||||
const LEGACY_WORKDAY_GUIDE_DISMISSED_STORAGE_KEY = 'sgrobot:digital-workday-guide-dismissed-date';
|
||||
const MAIN_RUN_DETAIL_LIMIT = 80;
|
||||
const EVENT_HISTORY_RENDER_LIMIT = 300;
|
||||
const WORKDAY_GUIDE_STEPS = [
|
||||
@@ -778,7 +779,8 @@ function resolveEmployeeVisualState(args: {
|
||||
function readGuideDismissedDate(): string | null {
|
||||
if (typeof window === 'undefined') return null;
|
||||
try {
|
||||
return window.sessionStorage.getItem(WORKDAY_GUIDE_DISMISSED_STORAGE_KEY);
|
||||
return window.sessionStorage.getItem(WORKDAY_GUIDE_DISMISSED_STORAGE_KEY)
|
||||
?? window.sessionStorage.getItem(LEGACY_WORKDAY_GUIDE_DISMISSED_STORAGE_KEY);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
@@ -788,6 +790,7 @@ function rememberGuideDismissedDate(date: string): void {
|
||||
if (typeof window === 'undefined') return;
|
||||
try {
|
||||
window.sessionStorage.setItem(WORKDAY_GUIDE_DISMISSED_STORAGE_KEY, date);
|
||||
window.sessionStorage.removeItem(LEGACY_WORKDAY_GUIDE_DISMISSED_STORAGE_KEY);
|
||||
} catch {
|
||||
// Session storage can be unavailable in restricted browser contexts.
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ const TABS: { id: DigitalTab; label: string }[] = [
|
||||
{ id: 'reports', label: '日报' },
|
||||
{ id: 'settings', label: '设置' },
|
||||
];
|
||||
const DIGITAL_EMPLOYEE_CLOSE_MESSAGE = 'sgrobot:digital-close';
|
||||
const DIGITAL_EMPLOYEE_CLOSE_MESSAGE = 'qimingclaw:digital-close';
|
||||
|
||||
function isDigitalTab(value: string | null): value is DigitalTab {
|
||||
return Boolean(value && TABS.some(tab => tab.id === value));
|
||||
|
||||
@@ -5,7 +5,8 @@ import { useRole, ROLE_PROFILES, type ConsoleRole } from '@/contexts/RoleContext
|
||||
import { t } from '@/lib/i18n';
|
||||
|
||||
const ROLES: ConsoleRole[] = ['sales', 'engineering', 'hr', 'finance', 'executive'];
|
||||
const STORAGE_KEY = 'sgrobot-role-preferences';
|
||||
const STORAGE_KEY = 'qimingclaw:digital-role-preferences';
|
||||
const LEGACY_STORAGE_KEY = 'sgrobot-role-preferences';
|
||||
|
||||
type RolePreferences = {
|
||||
workStart: string;
|
||||
@@ -58,7 +59,7 @@ const inputStyle: CSSProperties = {
|
||||
|
||||
function loadPreferences(): RolePreferences {
|
||||
try {
|
||||
const raw = localStorage.getItem(STORAGE_KEY);
|
||||
const raw = localStorage.getItem(STORAGE_KEY) ?? localStorage.getItem(LEGACY_STORAGE_KEY);
|
||||
if (!raw) return defaultPreferences;
|
||||
return { ...defaultPreferences, ...JSON.parse(raw) };
|
||||
} catch {
|
||||
@@ -84,7 +85,10 @@ export default function OpsSettings() {
|
||||
|
||||
const savePreferences = (next: RolePreferences) => {
|
||||
setPreferences(next);
|
||||
try { localStorage.setItem(STORAGE_KEY, JSON.stringify(next)); } catch { /* localStorage blocked */ }
|
||||
try {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(next));
|
||||
localStorage.removeItem(LEGACY_STORAGE_KEY);
|
||||
} catch { /* localStorage blocked */ }
|
||||
markSaved();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user