Shannon_mu 3 年 前
コミット
884eb2200b
3 ファイル変更37 行追加19 行削除
  1. 17 9
      login/src/utils/http.js
  2. 2 2
      login/src/views/NewNav/index.vue
  3. 18 8
      login/vue.config.js

+ 17 - 9
login/src/utils/http.js

@@ -15,7 +15,15 @@ http.interceptors.request.use(
     config => {
         // 所有请求都添加/user-auth前缀,方便接口代理
         // config.url = `/user-auth${config.url}`;
-        config.url = `${config.url.indexOf('/sc-user-center') == 0 ? '' : '/sc-user-auth'}${config.url}`;
+        if (config.url.indexOf('/sc-user-center') == 0) {
+            config.url = `${config.url}`;
+        } else if (config.url.indexOf('/sc-community') == 0) {
+            config.url = `${config.url}`;
+        } else {
+            config.url = `/sc-user-auth${config.url}`;
+        }
+
+        // config.url = `${config.url.indexOf('/sc-user-center') == 0 ? '' : '/sc-user-auth'}${config.url}`;
         config.headers[localStorage.getItem('SC_token') && 'Authorization'] = 'Bearer ' + localStorage.getItem('SC_token');
         // 全局添加cancelToken
         config.cancelToken = source.token;
@@ -31,13 +39,13 @@ http.interceptors.response.use(
         return Promise.resolve(res.data);
     },
     err => {
-        if (err&&err.response.status == 401) {
+        if (err && err.response.status == 401) {
             axios({
-                url:'/sc-user-auth/user/getUserStatus?accessToken='+localStorage.getItem('SC_token'),
-                method:'get'
-            }).then((response)=>{
-              if (window.relogin) return false;
-              window.relogin = true;
+                url: '/sc-user-auth/user/getUserStatus?accessToken=' + localStorage.getItem('SC_token'),
+                method: 'get'
+            }).then((response) => {
+                if (window.relogin) return false;
+                window.relogin = true;
                 let data = response.data.data;
                 if (data == 0) {
                     ELEMENT.MessageBox('你的登录已超时,请重新登录', '提示', 'warning', {
@@ -80,9 +88,9 @@ http.interceptors.response.use(
                         .catch(() => { });
                 }
             })
-          return;
+            return;
         }
-        if (axios.isCancel(err)) return new Promise(() => {}); // 取消请求的情况下,终端Promise调用链
+        if (axios.isCancel(err)) return new Promise(() => { }); // 取消请求的情况下,终端Promise调用链
         return Promise.reject(err);
     }
 );

+ 2 - 2
login/src/views/NewNav/index.vue

@@ -95,9 +95,9 @@ export default {
                     }
                 });
             } else if (appId == 1007) {
-                this.$http.get('/user/getRangeCode', { appId: '1007' }).then(({ status, data, msg }) => {
+                this.$http.get('/sc-community/assets/community/getLoginParkUrl').then(({ status, data, msg }) => {
                     if (0 === status) {
-                        window.open(`${url}?code=${data}`);
+                        window.open(`${data}`);
                     } else {
                         this.$message.error(msg);
                     }

+ 18 - 8
login/vue.config.js

@@ -60,15 +60,15 @@ module.exports = {
             dayjs: 'dayjs',
             echarts: 'echarts'
         },
-          //关闭 webpack 的性能提示
-          performance: {
-            hints:'warning',
+        //关闭 webpack 的性能提示
+        performance: {
+            hints: 'warning',
             //入口起点的最大体积
             maxEntrypointSize: 50000000,
             //生成文件的最大体积
             maxAssetSize: 300000000,
             //只给出 js 文件的性能提示
-            assetFilter: function(assetFilename) {
+            assetFilter: function (assetFilename) {
                 return assetFilename.endsWith('.js');
             }
         }
@@ -85,21 +85,31 @@ module.exports = {
                 target: envConfig.baseApi,
                 ws: true, // 代理的WebSockets
                 changeOrigin: true, // 允许websockets跨域
-                logLevel:'debug',
+                logLevel: 'debug',
                 pathRewrite: {
                     /* "^/api": "" */
                 }
             },
-            '/sc-user-center':{
+            '/sc-user-center': {
                 target: envConfig.baseApi,
                 ws: true, // 代理的WebSockets
                 changeOrigin: true, // 允许websockets跨域
-                logLevel:'debug',
+                logLevel: 'debug',
                 pathRewrite: {
                     /* "^/api": "" */
                 }
 
-            }
+            },
+            '/sc-community': {
+                target: envConfig.baseApi,
+                ws: true, // 代理的WebSockets
+                changeOrigin: true, // 允许websockets跨域
+                logLevel: 'debug',
+                pathRewrite: {
+                    /* "^/api": "" */
+                }
+
+            },
         }
     }
 };