|
@@ -14,41 +14,42 @@ router.beforeEach(async (to: Route, _: Route, next: any) => {
|
|
|
NProgress.start();
|
|
|
|
|
|
|
|
|
- if (UserModule.token) {
|
|
|
- if (to.path === "/login") {
|
|
|
-
|
|
|
- next({ path: "/" });
|
|
|
- NProgress.done();
|
|
|
- } else {
|
|
|
-
|
|
|
- if (UserModule.roles.length === 0) {
|
|
|
- try {
|
|
|
-
|
|
|
- await UserModule.GetUserInfo();
|
|
|
-
|
|
|
- next({ ...to, replace: true });
|
|
|
- } catch (err) {
|
|
|
-
|
|
|
- UserModule.ResetToken();
|
|
|
- Message.error(err || "Has Error");
|
|
|
- next(`/login?redirect=${to.path}`);
|
|
|
- NProgress.done();
|
|
|
- }
|
|
|
- } else {
|
|
|
- next();
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
-
|
|
|
- if (whiteList.indexOf(to.path) !== -1) {
|
|
|
-
|
|
|
- next();
|
|
|
- } else {
|
|
|
-
|
|
|
- next(`/login?redirect=${to.path}`);
|
|
|
- NProgress.done();
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ next();
|
|
|
});
|
|
|
|
|
|
router.afterEach((to: Route) => {
|