邵剑恒 4 жил өмнө
parent
commit
8c2713b1d1

+ 15 - 2
src/apis/base.js

@@ -2,7 +2,7 @@
 import axios from 'axios'
 import { message } from 'antd'
 import { beforeRequest, handleRequestError, handleResponseSuccess, handleResponseError } from '@/apis/hook'
-import { auth } from '@/conf/config'
+import { dc } from '@/conf/config'
 import getRealUrl from '@/utils/getRealUrl'
 
 function getPrefix () {
@@ -13,6 +13,19 @@ function getPrefix () {
   }
 }
 
+// 截取路径
+function getPathFromUrl (str, keyword = '/') {
+  let index = str.indexOf(keyword)
+  let num = 0
+  while (index !== -1 && num < 2) {
+    // console.log(index)//打印出a的索引
+    num++// 记录出现的次数
+    index = str.indexOf(keyword, index + 1)
+  }
+  // return index
+  return str.slice(index)
+}
+
 export const request = axios.create({
   baseURL: `${getPrefix()}`,
   timeout: 5000,
@@ -66,7 +79,7 @@ async function authRequest ({ method, url, params, data }) {
     }
   } = await request({
     method: 'get',
-    url: `${auth}/common/token?url=${encodeURIComponent(getRealUrl(url))}`,
+    url: `${dc}/api/common/token?url=${encodeURIComponent(getPathFromUrl(getRealUrl(url)))}`,
     params: {}
   })
   if (code === 0) {

+ 14 - 1
src/conf/config.js

@@ -23,4 +23,17 @@ if (document.domain === 'back-admin.weipaitang.com') {
   ms = 'http://back-admin.weipaitang.com'
 }
 
-export { dc, tc, us, apiCdn, auth, hostDev, sTaskJobLog, thanos, wop, ms }
+const menuIcon = {
+  '/dc': 'icon-shujuzhongxin',
+  '/ms': 'icon-99',
+  '/ht': 'icon-huancunguanli',
+  '/tc': 'icon-jihuarenwu',
+  '/fengkong': 'icon-RectangleCopy',
+  '/poster': 'icon-haibaoguanli',
+  '/task': 'icon-renwuzhongxin',
+  '/allseeing': 'icon-xiaonengjiancha',
+  '/openplatform': 'icon-kaifangpingtai',
+  '/smanagement': 'icon-fuwu'
+}
+
+export { dc, tc, us, apiCdn, auth, hostDev, sTaskJobLog, thanos, wop, ms, menuIcon }

+ 2 - 1
src/layouts/index.less

@@ -1,3 +1,4 @@
 .normal {
 
-}
+
+}

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 20 - 5
src/layouts/mainLayout/index.js


+ 5 - 2
src/models/user.js

@@ -1,7 +1,7 @@
 import cloneDeep from 'lodash/cloneDeep';
 import { query, logout, delColumnCache } from '@/services/user';
 import { message } from 'antd';
-// import { menuIcon } from '@/conf/const';
+import { menuIcon } from '@/conf/config';
 
 const generateAntdData = data => {
   data.unshift({ id: -1, name: '全部' })
@@ -64,7 +64,10 @@ const UserModel = {
         const { user_name: name } = action.payload.data;
         const filterMenuList = data => data.filter(item => {
             item.path = item.url;
-            // item.icon = menuIcon[item.path];
+          item.icon = menuIcon[item.path];
+          if (item.icon) {
+            item.firstLevel = true;
+          }
             if (item.children && item.children.length !== 0) {
               // item.selectable = false;
               item.disabled = true;

+ 7 - 0
src/pages/login/index.js

@@ -26,6 +26,13 @@ class LoginPage extends React.PureComponent {
   async componentDidMount () {
     const token = this.props.location.query.token
     if (token) {
+      if (/\.weipaitang\.com/.test(document.domain)) {
+        // 企业微信端需要手动种植work_sso_cookie一以此做登入(虽然pc端的线上和测试也会运行到该代码,但是不影响,就像相当于把sso种的cookie以同样的配置覆写了一遍)
+        document.cookie = `work_sso_cookie=${token};max-age=604800;path=/;domain=.weipaitang.com`;
+      } else {
+        // 本地开发时需要本地种植 work_sso_cookie以此做登入
+        document.cookie = `work_sso_cookie=${token};path=/;`
+      }
       await this.doLogin(token)
     } else {
       this.toLoginPage()

+ 7 - 8
src/services/user.js

@@ -1,16 +1,15 @@
 
 import { request } from '@/apis/base'
-import { auth } from '@/conf/config'
+import { auth, dc } from '@/conf/config'
 
-export async function query() {
-  return request(`${auth}/common/myPower`);
+export async function query () {
+  return request(`${dc}/api/common/myPower`)
 }
 
-export async function logout() {
-  return request(`${auth}/login/ssoLogout`);
+export async function logout () {
+  return request(`${auth}/login/ssoLogout`)
 }
 
-export async function delColumnCache(params) {
-  return request(`${auth}/common/delColumnCache`, params);
+export async function delColumnCache (params) {
+  return request(`${auth}/common/delColumnCache`, params)
 }
-

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно