outaozhen 3 년 전
부모
커밋
7f87ba2deb
3개의 변경된 파일8개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 0
      config/config.dev.ts
  2. 1 0
      config/proxy.ts
  3. 4 3
      src/app.tsx

+ 3 - 0
config/config.dev.ts

@@ -11,4 +11,7 @@ export default defineConfig({
     babelPlugins: [],
     babelOptions: {}
   }
+  // devServer: {
+  //   port: 8080
+  // }
 })

+ 1 - 0
config/proxy.ts

@@ -10,6 +10,7 @@ export default {
   dev: {
     '/api/': {
       target: 'http://fabqa.com',
+      // target: 'http://fab.com:8052',
       changeOrigin: true,
       pathRewrite: { '^': '' }
     }

+ 4 - 3
src/app.tsx

@@ -1,4 +1,5 @@
 import type { Settings as LayoutSettings } from '@ant-design/pro-layout'
+import { notification } from 'antd'
 import { PageLoading } from '@ant-design/pro-layout'
 import type { RequestConfig, RunTimeLayoutConfig } from 'umi'
 import { getIntl, getLocale, history } from 'umi'
@@ -50,7 +51,7 @@ const authHeaderInterceptor = (url: string, options: RequestOptionsInit) => {
   const token = window.localStorage.getItem('TOKEN_ID')
   // 如果是登录页面,不执行
   if (!token && history.location.pathname !== loginPath) {
-    // return history.push(loginPath)
+    return history.push(loginPath)
   }
   const authHeader = { Authorization: `Bearer ${JSON.parse(token)}` }
   return {
@@ -159,8 +160,8 @@ export const request: RequestConfig = {
       }
       return response
     }
-  ],
-  requestInterceptors: [authHeaderInterceptor]
+  ]
+  // requestInterceptors: [authHeaderInterceptor]
 }
 
 // ProLayout 支持的api https://procomponents.ant.design/components/layout