@bit-sun/business-component 2.4.28 → 2.4.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -94,18 +94,35 @@ export function getCurrentTargetBgId() {
94
94
  return localStorage.getItem('target_bg_id');
95
95
  }
96
96
 
97
- // 菜单按钮权限 存储/获取key 函数
98
- export const getMenuAuthDataKey = (channel?: string) => {
97
+ /******* 公用localstorage存取 开始 *****/
98
+
99
+ // 获取存储的最终key--加前缀是为了解决命名空间重复覆盖问题 【适用:主应用、子应用单独使用】
100
+ export const getLastKey = (prefix: any,key: string) => {
101
+ return prefix ? `${prefix}:${key}` : `${key}`;
102
+ }
103
+
104
+ // 存储/获取key 函数---如果没有channel,则使用主应用所属的业务应用编码作为前缀 【适用:主应用、子应用结合使用】
105
+ export const getLocalStorageSaveKey = (key: string,channel?: string) => {
99
106
  let prefix = channel
100
107
 
101
108
  // 传入channel 则使用传入的channel 作为前缀,一般存储key使用
102
109
  // 否则使用下面页面路径处理后的变量为前缀,一般获取key使用
103
110
  if(!channel) {
104
- const channelPlat: string = window.location.pathname
105
- const defaultPrefix = 'CONFIG_PC';
106
- const mapping: any = ENUM.MAIN_AUTH_MAPPING;
107
- prefix = mapping?.[channelPlat] || defaultPrefix
111
+ // @ts-ignore
112
+ prefix = window?.channelPrefix; // 兼容旧版本,只有主应用传了才会加前缀
108
113
  }
109
114
 
110
- return `${prefix}:${ENUM.BROWSER_CACHE.MAIN_AUTH_CODES}`
115
+ // 兼容旧版本
116
+ return getLastKey(prefix,key);
117
+ }
118
+
119
+ // 按钮资源权限集合 存储/获取key 函数
120
+ export const getMenuAuthDataKey = (channel?: string) => {
121
+ return getLocalStorageSaveKey(ENUM.BROWSER_CACHE.MAIN_AUTH_CODES, channel)
122
+ }
123
+
124
+ // 权限过滤后的菜单数据 存储/获取key 函数
125
+ export const getLimitMenuDataKey = (channel?: string) => {
126
+ return getLocalStorageSaveKey(ENUM.BROWSER_CACHE.LIMIT_MENU_DATA, channel)
111
127
  }
128
+ /******* 公用localstorage结束 *****/
package/src/utils/auth.ts CHANGED
@@ -17,7 +17,7 @@ export const handleJudgeAuthButtons = (buttonCodeArray: any[]) => {
17
17
  : [];
18
18
  buttonCodeArray.forEach((item: any, index: number) => {
19
19
  if (
20
- !authButton.filter((itemInner: any) => item.indexOf(itemInner) >= 0)
20
+ !authButton.filter((itemInner: any) => item?.indexOf?.(itemInner) >= 0)
21
21
  .length
22
22
  ) {
23
23
  if (buttonCodeArray.length > 1) {