打包后登录无法跳转问题解决
This commit is contained in:
parent
9daf74b625
commit
4dab02356f
@ -11,8 +11,8 @@ VUE_APP_VERSION = '240803'
|
||||
#VUE_APP_BASE_API = '/dev-api'
|
||||
VUE_APP_PDOMAIN = 'tanex56'
|
||||
VUE_APP_DATA_FROM = 'pc'
|
||||
VUE_APP_BASE_API = 'http://47.96.189.20:58089/api/bizsvr'
|
||||
VUE_APP_WS_HOST = 'ws://47.96.189.20:58089/api/bizsvr'
|
||||
VUE_APP_BASE_API = 'http://localhost:11089/api/bizsvr'
|
||||
VUE_APP_WS_HOST = 'ws://localhost:11089/api/bizsvr'
|
||||
|
||||
VUE_APP_PRINTER_HOST = '192.168.88.108:17080'
|
||||
|
||||
|
||||
2
.env.uat
2
.env.uat
@ -10,7 +10,7 @@ VUE_APP_VERSION = '240803'
|
||||
# 管理系统/生产环境
|
||||
VUE_APP_PDOMAIN = 'tanex56'
|
||||
VUE_APP_DATA_FROM = 'pc'
|
||||
VUE_APP_BASE_API = 'http://tst-api.emis.tanex56.com/api/bizsvr'
|
||||
VUE_APP_BASE_API = 'http://localhost:7777/api/bizsvr'
|
||||
VUE_APP_WS_HOST = 'ws://tst-api.emis.tanex56.com/api/bizsvr'
|
||||
|
||||
VUE_APP_PRINTER_HOST = '127.0.0.1:17080'
|
||||
|
||||
@ -85,7 +85,7 @@
|
||||
"nprogress": "0.2.0",
|
||||
"pako": "^2.1.0",
|
||||
"pdf-lib": "^1.17.1",
|
||||
"pdfjs-dist": "^2.5.207",
|
||||
"pdfjs-dist": "2.5.207",
|
||||
"print-js": "^1.6.0",
|
||||
"qrcode": "^1.5.4",
|
||||
"qrcodejs2": "^0.0.2",
|
||||
@ -118,8 +118,7 @@
|
||||
"vuedraggable": "^2.24.3",
|
||||
"vuex": "3.6.0",
|
||||
"watermark-dom": "2.3.0",
|
||||
"xd-pdf": "1.0.0",
|
||||
"xd-vue-pdf": "3.0.0",
|
||||
"worker-loader": "2.0.0",
|
||||
"xlsx": "^0.17.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import pdf from 'xd-vue-pdf'
|
||||
import pdf from './xdpdf/vuePdfNoSss.vue'
|
||||
export default {
|
||||
components: {
|
||||
pdf
|
||||
|
||||
@ -41,21 +41,9 @@ router.beforeEach(async(to, from, next) => {
|
||||
store.dispatch('GetInfo').then(() => {
|
||||
isRelogin.show = false
|
||||
store.dispatch('GenerateRoutes').then(accessRoutes => {
|
||||
// 根据roles权限生成可访问的路由表
|
||||
let path = '/'
|
||||
if(accessRoutes&&accessRoutes[0].path != path){
|
||||
if(accessRoutes[0].children){
|
||||
path = accessRoutes[0].path + '/' + accessRoutes[0].children[0].path
|
||||
}
|
||||
else{
|
||||
path = accessRoutes[0].path
|
||||
}
|
||||
}else{
|
||||
path = accessRoutes[0].children[0].path
|
||||
}
|
||||
// next({ path, replace: true }) // hack方法 确保addRoutes已完成
|
||||
// next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
||||
router.addRoutes(accessRoutes) // 动态添加可访问路由表
|
||||
// 使用 GenerateRoutes 计算的首页路径,避免相对路径导致跳转失败
|
||||
const path = store.state.permission.indexPage || '/'
|
||||
|
||||
if(from.path == '/login' || to.fullPath=='/'){
|
||||
next({ path, replace: true }) // hack方法 确保addRoutes已完成
|
||||
@ -64,6 +52,11 @@ router.beforeEach(async(to, from, next) => {
|
||||
next({ ...to, replace: true })
|
||||
}
|
||||
|
||||
}).catch(err => {
|
||||
store.dispatch('LogOut').then(() => {
|
||||
Message.error(err || '路由加载失败')
|
||||
next({ path: '/login' })
|
||||
})
|
||||
})
|
||||
}).catch(err => {
|
||||
store.dispatch('LogOut').then(() => {
|
||||
|
||||
@ -36,7 +36,7 @@ const permission = {
|
||||
actions: {
|
||||
// 生成路由
|
||||
GenerateRoutes({ commit,dispatch }) {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 向后端请求路由数据
|
||||
getRouters().then(res => {
|
||||
const sdata = JSON.parse(JSON.stringify(res.data))
|
||||
@ -54,7 +54,8 @@ const permission = {
|
||||
if(sidebarRoutes.length==0){
|
||||
// 无左侧菜单路由,则退出登录
|
||||
dispatch('FedLogOut', { }, { root: true })
|
||||
// rewriteRoutes.push({ path: '*', redirect: '/401', hidden: true })
|
||||
reject(new Error('当前账号无菜单权限,请联系管理员'))
|
||||
return
|
||||
}
|
||||
|
||||
router.addRoutes(asyncRoutes);
|
||||
@ -66,6 +67,8 @@ const permission = {
|
||||
commit('SET_INDEX_PAGE', indexUrl)
|
||||
|
||||
resolve(rewriteRoutes)
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
@ -164,13 +167,16 @@ export function filterDynamicRoutes(routes) {
|
||||
return res
|
||||
}
|
||||
|
||||
// 匹配 views 目录下所有 .vue 文件,用于动态路由组件加载
|
||||
const viewModules = require.context('../../views', true, /\.vue$/)
|
||||
|
||||
export const loadView = (view) => {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
return (resolve) => require([`@/views/${view}`], resolve)
|
||||
} else {
|
||||
// 使用 import 实现生产环境的路由懒加载
|
||||
return () => import(`@/views/${view}`)
|
||||
// 后端返回的组件路径可能带 .vue 后缀
|
||||
if (view.endsWith('.vue')) {
|
||||
view = view.slice(0, -4)
|
||||
}
|
||||
const modulePath = `./${view}.vue`
|
||||
return () => Promise.resolve(viewModules(modulePath).default || viewModules(modulePath))
|
||||
}
|
||||
|
||||
export default permission
|
||||
|
||||
@ -545,10 +545,11 @@ export default {
|
||||
}
|
||||
|
||||
this.$store.dispatch("Login", this.loginForm).then(() => {
|
||||
this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
|
||||
return this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
|
||||
}).catch(() => {
|
||||
this.loading = false;
|
||||
this.getCode();
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -563,8 +564,8 @@ export default {
|
||||
if (valid) {
|
||||
this.loading = true;
|
||||
this.$store.dispatch("LoginByMobile", this.loginForm2).then(() => {
|
||||
this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
|
||||
}).catch(() => {
|
||||
return this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user