export const GLOBAL_DEPT_USER_TREE_DISPLAY_ITEM = 'global-dept-user-tree-display-item' export const GLOBAL_SUPER_GRID_SETTING = 'global-super-grid-setting' export const GLOBAL_COMPONENT_SETTING_LOAD_STATE = 'global-component-setting-load-state' export const GLOBAL_FORM_SETTING = 'global-form-setting' export const GLOBAL_WORKFLOW_HISTORY_LIST_SETTING = 'global-workflow-history-list-setting' export const globalComponentCacheKeyMap = { DEPT_USER_TREE: GLOBAL_DEPT_USER_TREE_DISPLAY_ITEM, SUPER_GRID: GLOBAL_SUPER_GRID_SETTING, FORM: GLOBAL_FORM_SETTING, WF_HISTORY_LIST: GLOBAL_WORKFLOW_HISTORY_LIST_SETTING } as const export function getCacheKeyByType(type: keyof typeof globalComponentCacheKeyMap) { return globalComponentCacheKeyMap[type] ?? type } export function getClobalComponentSuperGridSetting() { const cacaheSetting = localStorage.getItem(GLOBAL_SUPER_GRID_SETTING) if (cacaheSetting) { try { return JSON.parse(cacaheSetting) } catch (error) { console.error('Failed to parse global super grid setting from localStorage:', error) return null } } } export function removeAllComponentGlobalCache() { localStorage.removeItem(GLOBAL_DEPT_USER_TREE_DISPLAY_ITEM) } export function getClobalComponentSettingByType(cacheKey: string) { const cacaheSetting = localStorage.getItem(cacheKey) if (cacaheSetting) { try { return JSON.parse(cacaheSetting) } catch (error) { console.error(`Failed to parse global setting from localStorage for key ${cacheKey}:`, error) return null } } } /** * 获取「文本流转历史列表」的全局组件设置 * 缓存写入时是 JSON.stringify(settingJson),而 settingJson 本身也是字符串,所以可能需要解析两次 */ export function getWorkflowHistoryListSetting(): any { let setting: any = getClobalComponentSettingByType(getCacheKeyByType('WF_HISTORY_LIST')) if (typeof setting === 'string') { try { setting = JSON.parse(setting) } catch (error) { console.error('Failed to parse global workflow history list setting:', error) return null } } return setting || null }