|
@@ -6,15 +6,15 @@ import NProgress from 'nprogress' // progress bar
|
|
import '@/components/NProgress/nprogress.less' // progress bar custom style
|
|
import '@/components/NProgress/nprogress.less' // progress bar custom style
|
|
import notification from 'ant-design-vue/es/notification'
|
|
import notification from 'ant-design-vue/es/notification'
|
|
import { setDocumentTitle, domTitle } from '@/utils/domUtil'
|
|
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'
|
|
import { i18nRender } from '@/locales'
|
|
|
|
|
|
NProgress.configure({ showSpinner: false }) // NProgress Configuration
|
|
NProgress.configure({ showSpinner: false }) // NProgress Configuration
|
|
|
|
|
|
const allowList = ['login', 'register', 'registerResult', 'download', 'forget', 'oldRegister'] // no redirect allowList
|
|
const allowList = ['login', 'register', 'registerResult', 'download', 'forget', 'oldRegister'] // no redirect allowList
|
|
-const loginRoutePath = '/user/login'
|
|
|
|
|
|
+const loginRoutePath = '/login'
|
|
const defaultRoutePath = '/'
|
|
const defaultRoutePath = '/'
|
|
|
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
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}`)
|
|
to.meta && typeof to.meta.title !== 'undefined' && setDocumentTitle(`${i18nRender(to.meta.title)} - ${domTitle}`)
|
|
/* has token */
|
|
/* has token */
|
|
const token = storage.get(ACCESS_TOKEN)
|
|
const token = storage.get(ACCESS_TOKEN)
|
|
|
|
+ const tenant_id = storage.get(TENANT_ID)
|
|
if (token) {
|
|
if (token) {
|
|
|
|
+ store.commit('SET_TENANT_ID', tenant_id)
|
|
|
|
+ store.commit('SET_TOKEN', token)
|
|
if (to.path === loginRoutePath) {
|
|
if (to.path === loginRoutePath) {
|
|
next({ path: defaultRoutePath })
|
|
next({ path: defaultRoutePath })
|
|
NProgress.done()
|
|
NProgress.done()
|
|
@@ -96,25 +99,17 @@ router.beforeEach(async (to, from, next) => {
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
if (to.path === '/4S') {
|
|
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 {
|
|
let {
|
|
data: { bim_view },
|
|
data: { bim_view },
|
|
} = await fileBimView('1207')
|
|
} = await fileBimView('1207')
|
|
localStorage.setItem(bim_view.lightweightName, JSON.stringify([bim_view]))
|
|
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()
|
|
next()
|
|
}
|
|
}
|
|
@@ -124,7 +119,11 @@ router.beforeEach(async (to, from, next) => {
|
|
// 在免登录名单,直接进入
|
|
// 在免登录名单,直接进入
|
|
next()
|
|
next()
|
|
} else {
|
|
} 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
|
|
NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
|
|
}
|
|
}
|
|
}
|
|
}
|