@mu-cabin/opms-permission 0.9.11 → 0.9.12
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.
- package/dist/index.cjs +5 -0
- package/dist/index.d.mts +51 -50
- package/dist/index.d.ts +51 -50
- package/dist/index.mjs +5 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -702,8 +702,13 @@ var Permission = class {
|
|
702
702
|
async getUserInfo() {
|
703
703
|
const data = await getUserInfo(this.baseUrl);
|
704
704
|
const { obj, success, msg, code } = data;
|
705
|
+
this.storage.setItem(USER_INFO_KEY, obj);
|
705
706
|
return obj;
|
706
707
|
}
|
708
|
+
isSameUser(account) {
|
709
|
+
const userInfo = this.storage.getItem(USER_INFO_KEY);
|
710
|
+
return userInfo?.account === account;
|
711
|
+
}
|
707
712
|
/**
|
708
713
|
* Get resources and process to menuList, menuMap, widgetMap (matches app store logic)
|
709
714
|
*/
|
package/dist/index.d.mts
CHANGED
@@ -1,3 +1,53 @@
|
|
1
|
+
declare class Storage {
|
2
|
+
private systemId?;
|
3
|
+
private currentVersion;
|
4
|
+
setSystemId(systemId: number | string): void;
|
5
|
+
/**
|
6
|
+
* Set the current version for new data
|
7
|
+
* If version changes, all existing data for this systemId will be cleared
|
8
|
+
*/
|
9
|
+
setVersion(version: string): void;
|
10
|
+
/**
|
11
|
+
* Get the current version
|
12
|
+
*/
|
13
|
+
getVersion(): string;
|
14
|
+
private prefixKey;
|
15
|
+
/**
|
16
|
+
* Set an item in localStorage, with optional expiration in minutes
|
17
|
+
*/
|
18
|
+
setItem<T>(key: string, value: T, expireMinutes?: number): void;
|
19
|
+
/**
|
20
|
+
* Get an item from localStorage, returns undefined if expired or not found
|
21
|
+
* Automatically expires data if version is different
|
22
|
+
*/
|
23
|
+
getItem<T>(key: string): T | undefined;
|
24
|
+
/**
|
25
|
+
* Remove an item from localStorage
|
26
|
+
*/
|
27
|
+
removeItem(key: string): void;
|
28
|
+
/**
|
29
|
+
* Clear all data for the current systemId
|
30
|
+
*/
|
31
|
+
clear(): void;
|
32
|
+
/**
|
33
|
+
* Get all keys for the current systemId
|
34
|
+
*/
|
35
|
+
getKeys(): string[];
|
36
|
+
/**
|
37
|
+
* Check if a key exists
|
38
|
+
*/
|
39
|
+
hasKey(key: string): boolean;
|
40
|
+
/**
|
41
|
+
* Get storage info for debugging
|
42
|
+
*/
|
43
|
+
getStorageInfo(): {
|
44
|
+
systemId: number | string | undefined;
|
45
|
+
currentVersion: string;
|
46
|
+
totalKeys: number;
|
47
|
+
systemKeys: number;
|
48
|
+
};
|
49
|
+
}
|
50
|
+
|
1
51
|
interface ApiResponse<T> {
|
2
52
|
obj: T;
|
3
53
|
success: boolean;
|
@@ -136,56 +186,6 @@ interface QueryOrgCustomParams {
|
|
136
186
|
*/
|
137
187
|
declare function queryOrgCustom(baseUrl: string, params: QueryOrgCustomParams): Promise<ApiResponse<OrgRecord$1[]>>;
|
138
188
|
|
139
|
-
declare class Storage {
|
140
|
-
private systemId?;
|
141
|
-
private currentVersion;
|
142
|
-
setSystemId(systemId: number | string): void;
|
143
|
-
/**
|
144
|
-
* Set the current version for new data
|
145
|
-
* If version changes, all existing data for this systemId will be cleared
|
146
|
-
*/
|
147
|
-
setVersion(version: string): void;
|
148
|
-
/**
|
149
|
-
* Get the current version
|
150
|
-
*/
|
151
|
-
getVersion(): string;
|
152
|
-
private prefixKey;
|
153
|
-
/**
|
154
|
-
* Set an item in localStorage, with optional expiration in minutes
|
155
|
-
*/
|
156
|
-
setItem<T>(key: string, value: T, expireMinutes?: number): void;
|
157
|
-
/**
|
158
|
-
* Get an item from localStorage, returns undefined if expired or not found
|
159
|
-
* Automatically expires data if version is different
|
160
|
-
*/
|
161
|
-
getItem<T>(key: string): T | undefined;
|
162
|
-
/**
|
163
|
-
* Remove an item from localStorage
|
164
|
-
*/
|
165
|
-
removeItem(key: string): void;
|
166
|
-
/**
|
167
|
-
* Clear all data for the current systemId
|
168
|
-
*/
|
169
|
-
clear(): void;
|
170
|
-
/**
|
171
|
-
* Get all keys for the current systemId
|
172
|
-
*/
|
173
|
-
getKeys(): string[];
|
174
|
-
/**
|
175
|
-
* Check if a key exists
|
176
|
-
*/
|
177
|
-
hasKey(key: string): boolean;
|
178
|
-
/**
|
179
|
-
* Get storage info for debugging
|
180
|
-
*/
|
181
|
-
getStorageInfo(): {
|
182
|
-
systemId: number | string | undefined;
|
183
|
-
currentVersion: string;
|
184
|
-
totalKeys: number;
|
185
|
-
systemKeys: number;
|
186
|
-
};
|
187
|
-
}
|
188
|
-
|
189
189
|
declare const USER_INFO_KEY = "opms_user_info";
|
190
190
|
declare const RESOURCE_KEY = "opms_resources";
|
191
191
|
declare const TOKEN_KEY = "opms_authorization";
|
@@ -411,6 +411,7 @@ declare class Permission {
|
|
411
411
|
logout(clearData?: boolean): Promise<void>;
|
412
412
|
clear(): void;
|
413
413
|
getUserInfo(): Promise<UserInfo$1>;
|
414
|
+
isSameUser(account: string): boolean;
|
414
415
|
/**
|
415
416
|
* Get resources and process to menuList, menuMap, widgetMap (matches app store logic)
|
416
417
|
*/
|
package/dist/index.d.ts
CHANGED
@@ -1,3 +1,53 @@
|
|
1
|
+
declare class Storage {
|
2
|
+
private systemId?;
|
3
|
+
private currentVersion;
|
4
|
+
setSystemId(systemId: number | string): void;
|
5
|
+
/**
|
6
|
+
* Set the current version for new data
|
7
|
+
* If version changes, all existing data for this systemId will be cleared
|
8
|
+
*/
|
9
|
+
setVersion(version: string): void;
|
10
|
+
/**
|
11
|
+
* Get the current version
|
12
|
+
*/
|
13
|
+
getVersion(): string;
|
14
|
+
private prefixKey;
|
15
|
+
/**
|
16
|
+
* Set an item in localStorage, with optional expiration in minutes
|
17
|
+
*/
|
18
|
+
setItem<T>(key: string, value: T, expireMinutes?: number): void;
|
19
|
+
/**
|
20
|
+
* Get an item from localStorage, returns undefined if expired or not found
|
21
|
+
* Automatically expires data if version is different
|
22
|
+
*/
|
23
|
+
getItem<T>(key: string): T | undefined;
|
24
|
+
/**
|
25
|
+
* Remove an item from localStorage
|
26
|
+
*/
|
27
|
+
removeItem(key: string): void;
|
28
|
+
/**
|
29
|
+
* Clear all data for the current systemId
|
30
|
+
*/
|
31
|
+
clear(): void;
|
32
|
+
/**
|
33
|
+
* Get all keys for the current systemId
|
34
|
+
*/
|
35
|
+
getKeys(): string[];
|
36
|
+
/**
|
37
|
+
* Check if a key exists
|
38
|
+
*/
|
39
|
+
hasKey(key: string): boolean;
|
40
|
+
/**
|
41
|
+
* Get storage info for debugging
|
42
|
+
*/
|
43
|
+
getStorageInfo(): {
|
44
|
+
systemId: number | string | undefined;
|
45
|
+
currentVersion: string;
|
46
|
+
totalKeys: number;
|
47
|
+
systemKeys: number;
|
48
|
+
};
|
49
|
+
}
|
50
|
+
|
1
51
|
interface ApiResponse<T> {
|
2
52
|
obj: T;
|
3
53
|
success: boolean;
|
@@ -136,56 +186,6 @@ interface QueryOrgCustomParams {
|
|
136
186
|
*/
|
137
187
|
declare function queryOrgCustom(baseUrl: string, params: QueryOrgCustomParams): Promise<ApiResponse<OrgRecord$1[]>>;
|
138
188
|
|
139
|
-
declare class Storage {
|
140
|
-
private systemId?;
|
141
|
-
private currentVersion;
|
142
|
-
setSystemId(systemId: number | string): void;
|
143
|
-
/**
|
144
|
-
* Set the current version for new data
|
145
|
-
* If version changes, all existing data for this systemId will be cleared
|
146
|
-
*/
|
147
|
-
setVersion(version: string): void;
|
148
|
-
/**
|
149
|
-
* Get the current version
|
150
|
-
*/
|
151
|
-
getVersion(): string;
|
152
|
-
private prefixKey;
|
153
|
-
/**
|
154
|
-
* Set an item in localStorage, with optional expiration in minutes
|
155
|
-
*/
|
156
|
-
setItem<T>(key: string, value: T, expireMinutes?: number): void;
|
157
|
-
/**
|
158
|
-
* Get an item from localStorage, returns undefined if expired or not found
|
159
|
-
* Automatically expires data if version is different
|
160
|
-
*/
|
161
|
-
getItem<T>(key: string): T | undefined;
|
162
|
-
/**
|
163
|
-
* Remove an item from localStorage
|
164
|
-
*/
|
165
|
-
removeItem(key: string): void;
|
166
|
-
/**
|
167
|
-
* Clear all data for the current systemId
|
168
|
-
*/
|
169
|
-
clear(): void;
|
170
|
-
/**
|
171
|
-
* Get all keys for the current systemId
|
172
|
-
*/
|
173
|
-
getKeys(): string[];
|
174
|
-
/**
|
175
|
-
* Check if a key exists
|
176
|
-
*/
|
177
|
-
hasKey(key: string): boolean;
|
178
|
-
/**
|
179
|
-
* Get storage info for debugging
|
180
|
-
*/
|
181
|
-
getStorageInfo(): {
|
182
|
-
systemId: number | string | undefined;
|
183
|
-
currentVersion: string;
|
184
|
-
totalKeys: number;
|
185
|
-
systemKeys: number;
|
186
|
-
};
|
187
|
-
}
|
188
|
-
|
189
189
|
declare const USER_INFO_KEY = "opms_user_info";
|
190
190
|
declare const RESOURCE_KEY = "opms_resources";
|
191
191
|
declare const TOKEN_KEY = "opms_authorization";
|
@@ -411,6 +411,7 @@ declare class Permission {
|
|
411
411
|
logout(clearData?: boolean): Promise<void>;
|
412
412
|
clear(): void;
|
413
413
|
getUserInfo(): Promise<UserInfo$1>;
|
414
|
+
isSameUser(account: string): boolean;
|
414
415
|
/**
|
415
416
|
* Get resources and process to menuList, menuMap, widgetMap (matches app store logic)
|
416
417
|
*/
|
package/dist/index.mjs
CHANGED
@@ -646,8 +646,13 @@ var Permission = class {
|
|
646
646
|
async getUserInfo() {
|
647
647
|
const data = await getUserInfo(this.baseUrl);
|
648
648
|
const { obj, success, msg, code } = data;
|
649
|
+
this.storage.setItem(USER_INFO_KEY, obj);
|
649
650
|
return obj;
|
650
651
|
}
|
652
|
+
isSameUser(account) {
|
653
|
+
const userInfo = this.storage.getItem(USER_INFO_KEY);
|
654
|
+
return userInfo?.account === account;
|
655
|
+
}
|
651
656
|
/**
|
652
657
|
* Get resources and process to menuList, menuMap, widgetMap (matches app store logic)
|
653
658
|
*/
|