1
1

7 Коммиты f15f3e508d ... 7343aad8b1

Автор SHA1 Сообщение Дата
  Alfyn 7343aad8b1 调整跳转4s项目方式 2 недель назад
  Alfyn 5c3b487a57 修改跳转4s项目的方式 2 недель назад
  Alfyn bfe02737ff 解决本地登录登出异常 2 недель назад
  Alfyn 7e72e3409b 请求头租户id不受token限制 2 недель назад
  Alfyn 593c313eda 退出登录重定向 2 недель назад
  Alfyn baceee244c 租户id别名没有引用 2 недель назад
  Alfyn 1260748cd4 路由拦截中vuex保存token 2 недель назад

+ 7 - 0
src/api/user.js

@@ -131,4 +131,11 @@ export function operationLogList(params) {
     method: 'get',
     params
   })
+}
+
+export function get4SLoginToken() {
+  return request({
+    url: `/user/get4sAccessToken`,
+    method: 'get',
+  })
 }

+ 5 - 1
src/components/GlobalHeader/AvatarDropdown.vue

@@ -55,7 +55,11 @@ export default {
         content: this.$t('layouts.usermenu.dialog.content'),
         onOk: () => {
           return this.$store.dispatch('Logout').then(() => {
-            this.$router.push({ name: 'login' })
+            if(window.location.href.startsWith("http://localhost")){
+              this.$router.push({ name: 'login' })
+            }else{
+              window.location.href = "https://dev.autocde.com/login";
+            }
           })
         },
         onCancel () {}

+ 18 - 19
src/permission.js

@@ -6,15 +6,15 @@ import NProgress from 'nprogress' // progress bar
 import '@/components/NProgress/nprogress.less' // progress bar custom style
 import notification from 'ant-design-vue/es/notification'
 import { setDocumentTitle, domTitle } from '@/utils/domUtil'
-import { userInfo } from '@/api/headerInfo/index.js'
-import {  fileBimView } from '@/api/document/index.js'
-import { ACCESS_TOKEN } from '@/store/mutation-types'
+import { get4SLoginToken } from '@/api/user.js'
+import { fileBimView } from '@/api/document/index.js'
+import { ACCESS_TOKEN, TENANT_ID } from '@/store/mutation-types'
 import { i18nRender } from '@/locales'
 
 NProgress.configure({ showSpinner: false }) // NProgress Configuration
 
 const allowList = ['login', 'register', 'registerResult', 'download', 'forget', 'oldRegister'] // no redirect allowList
-const loginRoutePath = '/user/login'
+const loginRoutePath = '/login'
 const defaultRoutePath = '/'
 
 router.beforeEach(async (to, from, next) => {
@@ -22,7 +22,10 @@ router.beforeEach(async (to, from, next) => {
   to.meta && typeof to.meta.title !== 'undefined' && setDocumentTitle(`${i18nRender(to.meta.title)} - ${domTitle}`)
   /* has token */
   const token = storage.get(ACCESS_TOKEN)
+  const tenant_id = storage.get(TENANT_ID)
   if (token) {
+    store.commit('SET_TENANT_ID', tenant_id)
+    store.commit('SET_TOKEN', token)
     if (to.path === loginRoutePath) {
       next({ path: defaultRoutePath })
       NProgress.done()
@@ -96,25 +99,17 @@ router.beforeEach(async (to, from, next) => {
           })
       } else {
         if (to.path === '/4S') {
-          const {
-            data: { name, fs_password },
-          } = await userInfo()
-          axios
-            .post(`http://newlinker.net:18001/login/pc?username=${name}&password=${fs_password}`)
-            .then(({ data }) => {
-              if (data.code === 200) {
-                window.open('https://www.newlinker.net:8090?token=' + data.data.token)
-              } else {
-                return
-              }
-            })
+          const res = await get4SLoginToken()
+          if (res.target_url) {
+            window.location.href = res.target_url
+          }
         }
-        if(to.path === '/IOT') {
+        if (to.path === '/IOT') {
           let {
             data: { bim_view },
           } = await fileBimView('1207')
           localStorage.setItem(bim_view.lightweightName, JSON.stringify([bim_view]))
-          window.open(`/modelViewIOT?id=${bim_view.lightweightName}`, '_blank') 
+          next({ path: `/modelViewIOT?id=${bim_view.lightweightName}` })
         }
         next()
       }
@@ -124,7 +119,11 @@ router.beforeEach(async (to, from, next) => {
       // 在免登录名单,直接进入
       next()
     } else {
-      next({ path: loginRoutePath, query: { redirect: to.fullPath } })
+      if (window.location.href.startsWith('http://localhost')) {
+        next({ path: '/user/login' })
+      } else {
+        window.location.href = `https://dev.autocde.com/login?redirect=${to.fullPath}`
+      }
       NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
     }
   }

+ 3 - 1
src/utils/request.js

@@ -49,7 +49,7 @@ const errorHandler = (error) => {
         message: 'Bad request',
         description: data.message,
       })
-      return
+      return data
     }
   }
   return Promise.reject(error)
@@ -64,6 +64,8 @@ request.interceptors.request.use((config) => {
   if (token) {
     config.headers[ACCESS_TOKEN] = token
     config.headers[Authorization] = 'Bearer ' + token
+  }
+  if(tenant_id){
     config.headers['X-Tenant'] = tenant_id
   }
   return config

+ 5 - 1
src/views/exception/404.vue

@@ -26,7 +26,11 @@ export default {
         content: this.$t('layouts.usermenu.dialog.content'),
         onOk: () => {
           return this.$store.dispatch('Logout').then(() => {
-            this.$router.push({ name: 'login' })
+            if(window.location.href.startsWith("http://localhost")){
+              this.$router.push({ name: 'login' })
+            }else{
+              window.location.href = "https://dev.autocde.com/login";
+            }
           })
         },
         onCancel () {}