@fairys/taro-tools-react 1.0.3 → 1.0.5
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/esm/context/auth.data.instance.d.ts +10 -2
- package/esm/context/auth.data.instance.js +19 -3
- package/esm/context/global.data.instance.d.ts +4 -0
- package/esm/context/global.data.instance.js +5 -0
- package/esm/context/index.d.ts +1 -0
- package/esm/context/index.js +1 -0
- package/lib/components/EnterLoading/index.d.ts +14 -0
- package/lib/components/EnterLoading/index.js +112 -0
- package/lib/components/MainPage/index.d.ts +10 -0
- package/lib/components/MainPage/index.js +102 -0
- package/lib/components/Mesage/index.d.ts +48 -0
- package/lib/components/Mesage/index.js +172 -0
- package/lib/components/Portal/index.d.ts +8 -0
- package/lib/components/Portal/index.js +45 -0
- package/lib/components/Toast/index.d.ts +1 -0
- package/lib/components/Toast/index.js +54 -0
- package/lib/components/connectToastMessage/index.d.ts +10 -0
- package/lib/components/connectToastMessage/index.js +62 -0
- package/lib/components/index.d.ts +6 -0
- package/lib/components/index.js +105 -0
- package/lib/context/auth.data.instance.d.ts +81 -0
- package/lib/context/auth.data.instance.js +155 -0
- package/lib/context/global.data.instance.d.ts +54 -0
- package/lib/context/global.data.instance.js +122 -0
- package/lib/context/global.setting.data.instance.d.ts +56 -0
- package/lib/context/global.setting.data.instance.js +79 -0
- package/lib/context/index.d.ts +5 -0
- package/lib/context/index.js +96 -0
- package/lib/context/page.data.instance.d.ts +151 -0
- package/lib/context/page.data.instance.js +382 -0
- package/lib/context/page.info.data.instance.d.ts +93 -0
- package/lib/context/page.info.data.instance.js +226 -0
- package/lib/index.d.ts +3 -0
- package/lib/styles/index.css +715 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.js +87 -0
- package/lib/utils/navigate.d.ts +109 -0
- package/lib/utils/navigate.js +99 -0
- package/lib/utils/request.d.ts +179 -0
- package/lib/utils/request.js +358 -0
- package/lib/utils/useId.d.ts +2 -0
- package/lib/utils/useId.js +50 -0
- package/lib/utils/valtio/index.d.ts +9 -0
- package/lib/utils/valtio/index.js +99 -0
- package/lib/utils/valtio/instance.d.ts +17 -0
- package/lib/utils/valtio/instance.js +80 -0
- package/package.json +4 -3
- package/src/context/auth.data.instance.ts +27 -3
- package/src/context/global.data.instance.ts +11 -0
- package/src/context/index.ts +1 -0
- package/src/utils/navigate.ts +1 -0
|
@@ -144,23 +144,47 @@ export class AuthDataInstance<T = any> {
|
|
|
144
144
|
* @param menuPermission 菜单权限
|
|
145
145
|
* @returns 是否有指定菜单权限
|
|
146
146
|
*/
|
|
147
|
-
hasMenuPermission(menuPermission: string): boolean {
|
|
147
|
+
hasMenuPermission = (menuPermission: string): boolean => {
|
|
148
148
|
if (!globalSettingDataInstance.store.isEnableAuth) {
|
|
149
149
|
return true;
|
|
150
150
|
}
|
|
151
151
|
return this.menusPermissions.includes(menuPermission);
|
|
152
|
-
}
|
|
152
|
+
};
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
155
|
* 判断是否有指定权限
|
|
156
156
|
* @param permission 权限
|
|
157
157
|
* @returns 是否有指定权限
|
|
158
158
|
*/
|
|
159
|
-
hasPermission(permission: string): boolean {
|
|
159
|
+
hasPermission = (permission: string): boolean => {
|
|
160
160
|
if (!globalSettingDataInstance.store.isEnableAuth) {
|
|
161
161
|
return true;
|
|
162
162
|
}
|
|
163
163
|
return this.permissions.includes(permission);
|
|
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
|
+
}
|
|
164
188
|
}
|
|
165
189
|
}
|
|
166
190
|
|
|
@@ -75,8 +75,19 @@ export class GlobalDataInstance extends ProxyInstanceObjectBase<GlobalDataInstan
|
|
|
75
75
|
this.store.toastData = ref({ ...this.store.toastData, visible: false });
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* 跳转登录页面前执行
|
|
80
|
+
*/
|
|
81
|
+
onBeforetToLoginPage?: () => boolean | void;
|
|
78
82
|
/**跳转登录页面*/
|
|
79
83
|
toLoginPage = () => {
|
|
84
|
+
if (this.onBeforetToLoginPage) {
|
|
85
|
+
const f = this.onBeforetToLoginPage();
|
|
86
|
+
if (f === false) {
|
|
87
|
+
// 如果返回false则不跳转登录页面
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
80
91
|
const loginPageRoute = globalSettingDataInstance.store.loginPageRoute || '';
|
|
81
92
|
const isLoginPage = navigate.isCurrentPage(loginPageRoute || '');
|
|
82
93
|
const _loginPageRoute = `${loginPageRoute || ''}`.replace(/^\//, '');
|
package/src/context/index.ts
CHANGED
package/src/utils/navigate.ts
CHANGED
|
@@ -17,6 +17,7 @@ class NavigateInstance {
|
|
|
17
17
|
if (useAuthHasMenuPermission && typeof isAuthFunction !== 'function' && isEnableAuth) {
|
|
18
18
|
isAuthFunction = authDataInstance.hasMenuPermission;
|
|
19
19
|
}
|
|
20
|
+
|
|
20
21
|
if (url && typeof isAuthFunction === 'function' && !isIgnoreAuthRoutes && isEnableAuth) {
|
|
21
22
|
isAuthTo = await isAuthFunction(url);
|
|
22
23
|
}
|