Sfoglia il codice sorgente

修改无token时跳回登录页

wangfumin 3 mesi fa
parent
commit
85a266e0b7
2 ha cambiato i file con 20 aggiunte e 7 eliminazioni
  1. 8 6
      src/api/instance.ts
  2. 12 1
      src/env/index.ts

+ 8 - 6
src/api/instance.ts

@@ -3,7 +3,7 @@ import { Dialog, Message } from "bill/index";
 import { showLoad, hideLoad } from "@/utils";
 import * as URL from "./constant";
 import { ResCode, ResCodeDesc } from "./constant";
-import { baseURL, params } from "@/env";
+import { baseURL, params, appBackRoot } from "@/env";
 import GAxios from "axios";
 
 const instance = axiosFactory();
@@ -27,7 +27,9 @@ export const {
 } = instance;
 
 const gotoLogin = () => {
-  if (import.meta.env.DEV) {
+  const loginHref = import.meta.env.DEV ? 'http://localhost:5174' : appBackRoot[params.app]
+  location.href = loginHref + '?redirect=' + escape(location.href) + '#/login'
+  // if (import.meta.env.DEV) {
     // GAxios.post("/service/manage/login", {
     //   password: "MRinIEn3ExMjM0NTY=Q5Lm39urQWzN7k4oCG",
     //   userName: "super-admin",
@@ -36,10 +38,10 @@ const gotoLogin = () => {
     //   setToken(res.data.data.token)
     //   setTimeout(() => location.reload())
     // });
-  } else {
-    // const loginHref = `/admin/#/statistics/scene`
-    // location.href = loginHref + '?redirect=' + escape(location.href)
-  }
+  // } else {
+  //   const loginHref = `/admin/#/statistics/scene`
+  //   location.href = loginHref + '?redirect=' + escape(location.href)
+  // }
 };
 
 addReqErrorHandler((err) => {

+ 12 - 1
src/env/index.ts

@@ -62,7 +62,18 @@ export const custom = flatStacksValue({
   showSearch: showSearchStack,
   showViewSetting: showViewSettingStack
 });
-
+export enum appType {
+  fire = '1',
+  criminal = '2',
+  xmfire = '3',
+  police = '4'
+}
+export const appBackRoot = {
+  [appType.fire]: "/fire",
+  [appType.xmfire]: "/xmfire",
+  [appType.criminal]: "/criminal",
+  [appType.police]: "/criminal"
+}
 export const params = reactive(
   strToParams(location.search)
 ) as unknown as Params;