@fairys/taro-tools-react 1.0.3 → 1.0.4
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.
|
@@ -65,6 +65,14 @@ export declare class AuthDataInstance<T = any> {
|
|
|
65
65
|
* @returns 是否有指定权限
|
|
66
66
|
*/
|
|
67
67
|
hasPermission(permission: string): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* 清除登录凭证(token)、权限列表、菜单权限列表、用户信息
|
|
70
|
+
*/
|
|
71
|
+
clear(): void;
|
|
72
|
+
/**
|
|
73
|
+
* 初始化认证数据实例
|
|
74
|
+
*/
|
|
75
|
+
constructor();
|
|
68
76
|
}
|
|
69
77
|
export declare const authDataInstance: AuthDataInstance<any>;
|
|
70
78
|
/**
|
|
@@ -76,6 +76,22 @@ class AuthDataInstance {
|
|
|
76
76
|
if (!globalSettingDataInstance.store.isEnableAuth) return true;
|
|
77
77
|
return this.permissions.includes(permission);
|
|
78
78
|
}
|
|
79
|
+
clear() {
|
|
80
|
+
this.token = '';
|
|
81
|
+
this.permissions = [];
|
|
82
|
+
this.menusPermissions = [];
|
|
83
|
+
this.userInfo = void 0;
|
|
84
|
+
}
|
|
85
|
+
constructor(){
|
|
86
|
+
try {
|
|
87
|
+
this.store.userInfo = this.userInfo;
|
|
88
|
+
this.store.token = this.token;
|
|
89
|
+
this.store.permissions = this.permissions;
|
|
90
|
+
this.store.menusPermissions = this.menusPermissions;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.error("\u521D\u59CB\u5316\u8BA4\u8BC1\u6570\u636E\u5B9E\u4F8B\u5931\u8D25", error);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
79
95
|
}
|
|
80
96
|
const authDataInstance = new AuthDataInstance();
|
|
81
97
|
function useAuthData() {
|
package/esm/context/index.d.ts
CHANGED
package/esm/context/index.js
CHANGED
package/package.json
CHANGED
|
@@ -162,6 +162,30 @@ export class AuthDataInstance<T = any> {
|
|
|
162
162
|
}
|
|
163
163
|
return this.permissions.includes(permission);
|
|
164
164
|
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* 清除登录凭证(token)、权限列表、菜单权限列表、用户信息
|
|
168
|
+
*/
|
|
169
|
+
clear() {
|
|
170
|
+
this.token = '';
|
|
171
|
+
this.permissions = [];
|
|
172
|
+
this.menusPermissions = [];
|
|
173
|
+
this.userInfo = undefined;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* 初始化认证数据实例
|
|
178
|
+
*/
|
|
179
|
+
constructor() {
|
|
180
|
+
try {
|
|
181
|
+
this.store.userInfo = this.userInfo;
|
|
182
|
+
this.store.token = this.token;
|
|
183
|
+
this.store.permissions = this.permissions;
|
|
184
|
+
this.store.menusPermissions = this.menusPermissions;
|
|
185
|
+
} catch (error) {
|
|
186
|
+
console.error('初始化认证数据实例失败', error);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
165
189
|
}
|
|
166
190
|
|
|
167
191
|
export const authDataInstance = new AuthDataInstance();
|