Browse Source

路由优化+本地化整理

noToken
安虹睿 1 year ago
parent
commit
54dd869743
  1. 2
      PC/InterFace.Dash/src/api/wms-api.js
  2. 2
      PC/InterFace.Dash/src/components/News/dialogIndex.vue
  3. 2
      PC/InterFace.Dash/src/components/News/index.vue
  4. 2
      PC/InterFace.Dash/src/components/rowDrop/index.vue
  5. 1
      PC/InterFace.Dash/src/layout/components/Navbar.vue
  6. 90
      PC/InterFace.Dash/src/permission - 副本.js
  7. 187
      PC/InterFace.Dash/src/permission-0718.js
  8. 178
      PC/InterFace.Dash/src/permission-0725.js
  9. 143
      PC/InterFace.Dash/src/permission.js
  10. 9
      PC/InterFace.Dash/src/store/getters.js
  11. 1
      PC/InterFace.Dash/src/store/modules/definition.js
  12. 3
      PC/InterFace.Dash/src/store/modules/permission.js
  13. 18
      PC/InterFace.Dash/src/utils/index.js
  14. 5
      PC/InterFace.Dash/src/views/login/index.vue
  15. 2
      PC/InterFace.Dash/src/views/profileuser/index.vue
  16. 2
      PC/InterFace.Dash/src/views/profileuser/resetPwd.vue

2
PC/InterFace.Dash/src/api/wms-api.js

@ -12,7 +12,7 @@ export function postCreate(data, url) {
data.warehouseCode = localStorage.getItem('warehouseCode') data.warehouseCode = localStorage.getItem('warehouseCode')
} }
if(Object.keys(data).includes('worker')) { if(Object.keys(data).includes('worker')) {
data.worker = store.getters.name.userName data.worker = store.getters.currentUserInfo.userName
} }
return request({ return request({
url: baseURL + url, url: baseURL + url,

2
PC/InterFace.Dash/src/components/News/dialogIndex.vue

@ -172,7 +172,7 @@ export default {
} }
}, },
mounted () { mounted () {
this.userId = this.$store.getters.name.id this.userId = this.$store.getters.currentUserInfo.id
// todo-new: // todo-new:
// this.getList() // this.getList()
}, },

2
PC/InterFace.Dash/src/components/News/index.vue

@ -25,7 +25,7 @@ export default {
dialogIndex dialogIndex
}, },
mounted () { mounted () {
this.userId = this.$store.getters.name.id this.userId = this.$store.getters.currentUserInfo.id
this.getNoReadCount(this.userId) this.getNoReadCount(this.userId)
this.getSetInterval() this.getSetInterval()
// //

2
PC/InterFace.Dash/src/components/rowDrop/index.vue

@ -100,7 +100,7 @@ export default {
type: 'warning', type: 'warning',
cancelButtonClass:'rowDropNotHideItem' cancelButtonClass:'rowDropNotHideItem'
}).then(() => { }).then(() => {
// set this.$store.getters.name.userName // set this.$store.getters.currentUserInfo.userName
localStorage.setItem('file_Columns_' + this.source + '_' + this.userName + '_' + this.$route.name, JSON.stringify([])) localStorage.setItem('file_Columns_' + this.source + '_' + this.userName + '_' + this.$route.name, JSON.stringify([]))
localStorage.removeItem('file_Columns_' + this.source + '_' +this.userName + '_' + this.$route.name) localStorage.removeItem('file_Columns_' + this.source + '_' +this.userName + '_' + this.$route.name)
// let _resetCol = this.$isTableColumns[this.$route.name] // let _resetCol = this.$isTableColumns[this.$route.name]

1
PC/InterFace.Dash/src/layout/components/Navbar.vue

@ -80,7 +80,6 @@ export default {
async logout() { async logout() {
await this.$store.dispatch("user/logout") await this.$store.dispatch("user/logout")
// this.$router.push(`/login?redirect=${this.$route.fullPath}`); // this.$router.push(`/login?redirect=${this.$route.fullPath}`);
localStorage.removeItem("interfaceBoardColumnsNames")
// this.$router.push(`/login?redirect=${this.$route.fullPath}&isAutoLogin=false`) // this.$router.push(`/login?redirect=${this.$route.fullPath}&isAutoLogin=false`)
this.$router.push(`/login?isAutoLogin=false`) this.$router.push(`/login?isAutoLogin=false`)
}, },

90
PC/InterFace.Dash/src/permission - 副本.js

@ -1,90 +0,0 @@
import router from './router'
import store from './store'
import {
Message
} from 'element-ui'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
import {
getToken
} from '@/utils/auth' // get token from cookie
import getPageTitle from '@/utils/get-page-title'
import {
asyncRoutes
} from '@/router'
NProgress.configure({
showSpinner: false
}) // NProgress Configuration
const whiteList = ['/login', '/auth-redirect', '/testForm'] // no redirect whitelist
router.beforeEach(async (to, from, next) => {
// 添加路由信息,方便代码修改定位
// console.log('----------------' + to.meta.title + '-----------------------'+ to.fullPath.substring(to.fullPath.lastIndexOf('-')+1,to.fullPath.length) + '.vue' );
// start progress bar
NProgress.start()
// set page title
document.title = getPageTitle()
next()
// determine whether the user has logged in
// todo-new:等获取token接口恢复后做处理
const hasRoles =await store.getters.roles && await store.getters.roles.length > 0
if (hasRoles) {
next()
} else {
try {
// get user info
// note: roles must be a object array! such as: ['admin'] or ,['developer','editor']
// 如果缓存中没有 interfaceBoardColumnsNames(接口监控看板表头信息) 的缓存数据 则退出登录
let _interfaceBoardColumnsNames = localStorage.getItem("interfaceBoardColumnsNames")
if(!_interfaceBoardColumnsNames || _interfaceBoardColumnsNames == 'undefined' || _interfaceBoardColumnsNames == 'null'){
await store.dispatch('user/logout')
next(`/login?redirect=${to.path}`)
NProgress.done()
}
const {
roles
} = await store.dispatch('user/getInfo')
// generate accessible routes map based on roles
// const accessRoutes = await store.dispatch('permission/generateRoutes', localStorage.getItem('userId'))
// router.addRoutes(accessRoutes)
// 原码 防止刷新出现空白页(系统暂无出现所以注释)
// const accessRoutes = await store.dispatch('permission/generateRoutes', roles)
// router.addRoutes(accessRoutes)
// hack method to ensure that addRoutes is complete
// set the replace: true, so the navigation will not leave a history record
next({
...to,
replace: true
})
} catch (error) {
// remove token and go to login page to re-login
await store.dispatch('user/resetToken')
Message.error(error || 'Has Error')
next(`/login?redirect=${to.path}`)
NProgress.done()
}
}
})
router.afterEach(() => {
// element-ui 使用 Tooltip 提示时候,更换页面,提示依旧存在偶现bug处理。
const mytooltipList = document.querySelectorAll('.el-tooltip__popper') // 获取页面所有tooltip的dom集合
setTimeout(() => {
mytooltipList.forEach((value) => {
value.style.display = 'none'
if(value.parentElement){
value.parentElement.removeChild(value)
}
})
}, 1000)
// finish progress bar
NProgress.done()
})

187
PC/InterFace.Dash/src/permission-0718.js

@ -1,187 +0,0 @@
import router from './router'
import store from './store'
import {
Message
} from 'element-ui'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
import {
getToken
} from '@/utils/auth' // get token from cookie
import getPageTitle from '@/utils/get-page-title'
import {
asyncRoutes
} from '@/router'
import { getInterfaceBoard } from "@/api/wms-interface"
import { login,getUsersByUserName } from "@/api/wms-auth"
NProgress.configure({
showSpinner: false
}) // NProgress Configuration
const whiteList = ['/login', '/auth-redirect', '/testForm'] // no redirect whitelist
router.beforeEach(async (to, from, next) => {
// 添加路由信息,方便代码修改定位
// console.log('----------------' + to.meta.title + '-----------------------'+ to.fullPath.substring(to.fullPath.lastIndexOf('-')+1,to.fullPath.length) + '.vue' );
// start progress bar
NProgress.start()
// set page title
document.title = getPageTitle()
// 判断是否自动登录
let isAutoLogin = JSON.parse(localStorage.getItem('isAutoLogin'))
// 如果路径中有isAutoLogin参数则优先,否则读取配置文件中的isAutoLogin参数
let _url_isAutoLogin = to.query.isAutoLogin
if( _url_isAutoLogin== 'false' || _url_isAutoLogin == 'true'){
isAutoLogin = JSON.parse(_url_isAutoLogin)
}
let userInfo = localStorage.getItem('currentUserInfo')
let _zh = localStorage.getItem('columnsApiNamesZh')
// 是否有用户信息:
// 1、如果没有判断是否为自动登录(是自动登录则自动执行登录,账号密码为配置信息中的值,不是自动登录则跳到登录页)
// 2、如果有用户信息:则检查是否有api接口的表头数据,没有的话重新获取
if(!userInfo){
if(isAutoLogin || to.query.loginName){
// let loginForm= {
// userNameOrEmailAddress:localStorage.getItem("userNameOrEmailAddress"),
// password:localStorage.getItem("client_secret"),
// // rememberMe:true,
// // grant_type: 'password',
// // client_id: 'Auth_App',
// }
// // store.dispatch('user/login', loginForm).then(() => {
// login(loginForm).then(()=>{
let _username = to.query.loginName ? to.query.loginName : localStorage.getItem("userNameOrEmailAddress")
getUsersByUserName(_username).then(res=>{
// todo:currentUserInfo全程需要优化
localStorage.setItem("currentUserInfo", JSON.stringify(res));
})
.catch(err => {
console.log('获取用户信息失败,请重试')
})
// 提前获取接口监控看板表头数据并存储
getInterfaceBoard().then(result => {
localStorage.setItem("interfaceBoardColumnsNames", JSON.stringify(result.resources[_zh].texts));
next('/')
})
.catch(err => {
console.log('获取表头失败,请重试')
})
// })
// .catch((error) => {
// console.log('登录失败')
// })
}else{
if (to.path != '/login') {
next('/login')
}else{
next()
}
NProgress.done()
}
}else{
// 重新获取api接口表头
// const _interfaceBoardColumnsNames = localStorage.getItem("interfaceBoardColumnsNames")
// if( !_interfaceBoardColumnsNames || _interfaceBoardColumnsNames == 'undefined' || _interfaceBoardColumnsNames == 'null'){
getInterfaceBoard().then(result => {
console.log(9999)
// todo-new:columnsApiNamesZh配置的地址补全(evel)
localStorage.setItem("interfaceBoardColumnsNames", JSON.stringify(result.resources[_zh].texts));
setTimeout(()=>{
next()
},0)
})
// }else{
// next()
// }
}
// determine whether the user has logged in
// todo-new:如果token接口恢复做处理
const hasToken = getToken()
// else if (hasToken) {
// // if(from.path != '/login'){
// // let _interfaceBoardColumnsNames = localStorage.getItem("interfaceBoardColumnsNames")
// // if(!_interfaceBoardColumnsNames){
// // // next({
// // // path: '/'
// // // })
// // // NProgress.done()
// // }
// // }
// if (to.path === '/login') {
// // if is logged in, redirect to the home page
// next({
// path: '/'
// })
// NProgress.done() // hack: https://github.com/PanJiaChen/vue-element-admin/pull/2939
// } else {
// // determine whether the user has obtained his permission roles through getInfo
// const hasRoles =await store.getters.roles && await store.getters.roles.length > 0
// if (hasRoles) {
// next()
// } else {
// try {
// // get user info
// // note: roles must be a object array! such as: ['admin'] or ,['developer','editor']
// const {
// roles
// } = await store.dispatch('user/getInfo')
// // generate accessible routes map based on roles
// // const accessRoutes = await store.dispatch('permission/generateRoutes', localStorage.getItem('userId'))
// // router.addRoutes(accessRoutes)
// // 原码 防止刷新出现空白页(系统暂无出现所以注释)
// // const accessRoutes = await store.dispatch('permission/generateRoutes', roles)
// // router.addRoutes(accessRoutes)
// // hack method to ensure that addRoutes is complete
// // set the replace: true, so the navigation will not leave a history record
// next({
// ...to,
// replace: true
// })
// } catch (error) {
// // remove token and go to login page to re-login
// await store.dispatch('user/resetToken')
// Message.error(error || 'Has Error')
// next(`/login?redirect=${to.path}`)
// NProgress.done()
// }
// }
// }
// } else {
// /* has no token*/
// if (whiteList.indexOf(to.path) !== -1) {
// // in the free login whitelist, go directly
// next()
// } else {
// // other pages that do not have permission to access are redirected to the login page.
// next(`/login?redirect=${to.path}`)
// NProgress.done()
// }
// }
})
router.afterEach(() => {
// element-ui 使用 Tooltip 提示时候,更换页面,提示依旧存在偶现bug处理。
const mytooltipList = document.querySelectorAll('.el-tooltip__popper') // 获取页面所有tooltip的dom集合
setTimeout(() => {
mytooltipList.forEach((value) => {
value.style.display = 'none'
if(value.parentElement){
value.parentElement.removeChild(value)
}
})
}, 1000)
// finish progress bar
NProgress.done()
})

178
PC/InterFace.Dash/src/permission-0725.js

@ -0,0 +1,178 @@
import router from './router'
import store from './store'
import { Message } from 'element-ui'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
import { getToken } from '@/utils/auth' // get token from cookie
import getPageTitle from '@/utils/get-page-title'
import { asyncRoutes } from '@/router'
import { login,getUsersByUserName } from "@/api/wms-auth"
NProgress.configure({
showSpinner: false
}) // NProgress Configuration
router.beforeEach(async (to, from, next) => {
// start progress bar
NProgress.start()
// set page title
document.title = getPageTitle()
// 获取枚举数据
if(!store.getters.enumList || store.getters.enumList.length <= 0){
await store.dispatch('definition/getEnumList')
}
// // 获取表头转义
// if(!store.getters.columZHList || store.getters.columZHList.length <= 0){
// await store.dispatch('definition/getColumZHList')
// }
// 判断是否自动登录
let isAutoLogin = JSON.parse(localStorage.getItem('isAutoLogin'))
const columZHList = store.getters.columZHList
// 如果路径中有isAutoLogin参数则优先,否则读取配置文件中的isAutoLogin参数
let _url_isAutoLogin = to.query.isAutoLogin
if( _url_isAutoLogin== 'false' || _url_isAutoLogin == 'true'){
isAutoLogin = JSON.parse(_url_isAutoLogin)
}
// 是否有用户信息:
const userInfo = store.getters.currentUserInfo
// 1、如果没有判断是否为自动登录(是自动登录则自动执行登录,账号密码为配置信息中的值,不是自动登录则跳到登录页)
// 2、有/没有:则检查是否有api接口的表头数据,没有的话重新获取
if(userInfo){
console.log('有store.getters.currentUserInfo',store.getters.currentUserInfo)
if(store.getters.permission_routes && store.getters.permission_routes.length > 0){
console.log('有store.getters.permission_routes',store.getters.permission_routes)
next()
}
else{
console.log('没有store.getters.permission_routes',store.getters.permission_routes)
const accessRoutes = await store.dispatch('permission/getApiColumnsNames')
router.addRoutes(accessRoutes)
next({
...to,
query:{
loginName:to.query.loginName,
isAutoLogin:to.query.isAutoLogin,
isSinglePage:to.query.isSinglePage
},
replace: true
})
}
}else{
// console.log('没有store.getters.currentUserInfo',store.getters.currentUserInfo)
if(!columZHList){
console.log('没有columZHList',columZHList)
await store.dispatch('definition/getColumZHList')
// const accessRoutes = await store.dispatch('permission/getApiColumnsNames')
// router.addRoutes(accessRoutes)
next({
...to,
query:{
loginName:to.query.loginName,
isAutoLogin:to.query.isAutoLogin,
isSinglePage:to.query.isSinglePage
},
replace: true
})
}
if(isAutoLogin || to.query.loginName){
console.log('有自动登录',isAutoLogin,to.query.loginName)
// let loginForm= {
// userNameOrEmailAddress:localStorage.getItem("userNameOrEmailAddress"),
// password:localStorage.getItem("client_secret"),
// // rememberMe:true,
// // grant_type: 'password',
// // client_id: 'Auth_App',
// }
// // store.dispatch('user/login', loginForm).then(() => {
// login(loginForm).then(()=>{
let _username = to.query.loginName || localStorage.getItem("isLoginName") || localStorage.getItem("userNameOrEmailAddress")
if(to.path != '/login'){
await store.dispatch('user/getUserInfo',_username).then(()=>{
next({
...to,
query:{
loginName:to.query.loginName,
isAutoLogin:to.query.isAutoLogin,
isSinglePage:to.query.isSinglePage
},
replace: true
})
}).catch(()=>{
next()
// next({
// path:'/login',
// query:{
// isAutoLogin:to.query.isAutoLogin,
// isSinglePage:to.query.isSinglePage
// },
// replace: true
// })
// next(`/login?loginName=${to.query.loginName}&isAutoLogin=${to.query.isAutoLogin}`)
// next(`/login`)
Message.error('获取用户信息失败,请重试!')
})
}else{
next()
// next({
// ...to,
// query:{
// loginName:to.query.loginName,
// isAutoLogin:to.query.isAutoLogin,
// isSinglePage:to.query.isSinglePage
// },
// replace: true
// })
}
// })
// .catch((error) => {
// console.log('登录失败')
// })
}
else{
console.log('不自动登录',isAutoLogin,to.query.loginName)
if (to.path != '/login') {
Message.error('获取用户信息失败,请重新登录')
next({
path:'/login',
query:{
isAutoLogin:to.query.isAutoLogin,
loginName:to.query.loginName,
isSinglePage:to.query.isSinglePage
},
replace: true
})
// next(`/login?loginName=${to.query.loginName}&isAutoLogin=${to.query.isAutoLogin}`)
// next(`/login`)
}else{
// next({
// ...to,
// query:{
// isAutoLogin:to.query.isAutoLogin,
// loginName:to.query.loginName,
// },
// replace: true
// })
next()
}
}
NProgress.done()
}
})
router.afterEach(() => {
// element-ui 使用 Tooltip 提示时候,更换页面,提示依旧存在偶现bug处理。
const mytooltipList = document.querySelectorAll('.el-tooltip__popper') // 获取页面所有tooltip的dom集合
setTimeout(() => {
mytooltipList.forEach((value) => {
value.style.display = 'none'
if(value.parentElement){
value.parentElement.removeChild(value)
}
})
}, 1000)
// finish progress bar
NProgress.done()
})

143
PC/InterFace.Dash/src/permission.js

@ -18,68 +18,45 @@ router.beforeEach(async (to, from, next) => {
// set page title // set page title
document.title = getPageTitle() document.title = getPageTitle()
// 获取表头转义
if(!store.getters.columZHList || store.getters.columZHList.length <= 0){
await store.dispatch('definition/getColumZHList')
}
// 获取菜单数据
if(!store.getters.permission_routes || store.getters.permission_routes.length <= 0){
const accessRoutes = await store.dispatch('permission/getApiColumnsNames')
router.addRoutes(accessRoutes)
}
// 获取枚举数据 // 获取枚举数据
if(!store.getters.enumList || store.getters.enumList.length <= 0){ if(!store.getters.enumList || store.getters.enumList.length <= 0){
await store.dispatch('definition/getEnumList') await store.dispatch('definition/getEnumList')
} }
// // 获取表头转义 // 是否有用户信息:
// if(!store.getters.columZHList || store.getters.columZHList.length <= 0){ const userInfo = store.getters.currentUserInfo
// await store.dispatch('definition/getColumZHList')
// }
// 判断是否自动登录 // 判断是否自动登录
let isAutoLogin = JSON.parse(localStorage.getItem('isAutoLogin')) let isAutoLogin = JSON.parse(localStorage.getItem('isAutoLogin'))
const interfaceBoardColumnsNames = localStorage.getItem("interfaceBoardColumnsNames")
// 如果路径中有isAutoLogin参数则优先,否则读取配置文件中的isAutoLogin参数 // 如果路径中有isAutoLogin参数则优先,否则读取配置文件中的isAutoLogin参数
let _url_isAutoLogin = to.query.isAutoLogin let _url_isAutoLogin = to.query.isAutoLogin
if( _url_isAutoLogin== 'false' || _url_isAutoLogin == 'true'){ if( _url_isAutoLogin== 'false' || _url_isAutoLogin == 'true'){
isAutoLogin = JSON.parse(_url_isAutoLogin) isAutoLogin = JSON.parse(_url_isAutoLogin)
} }
// 是否有用户信息: if(to.path == '/login'){
const userInfo = store.getters.currentUserInfo console.log('-------当前路由为登录页-------')
// 1、如果没有判断是否为自动登录(是自动登录则自动执行登录,账号密码为配置信息中的值,不是自动登录则跳到登录页) next()
// 2、有/没有:则检查是否有api接口的表头数据,没有的话重新获取
if(userInfo){
console.log('有store.getters.currentUserInfo',store.getters.currentUserInfo)
if(store.getters.permission_routes && store.getters.permission_routes.length > 0){
console.log('有store.getters.permission_routes',store.getters.permission_routes)
next()
}
else{
console.log('没有store.getters.permission_routes',store.getters.permission_routes)
const accessRoutes = await store.dispatch('permission/getApiColumnsNames')
router.addRoutes(accessRoutes)
next({
...to,
query:{
loginName:to.query.loginName,
isAutoLogin:to.query.isAutoLogin,
isSinglePage:to.query.isSinglePage
},
replace: true
})
}
}else{ }else{
// console.log('没有store.getters.currentUserInfo',store.getters.currentUserInfo) console.log('-------当前路由不是登录页-------')
if(!interfaceBoardColumnsNames){ if(userInfo){
console.log('没有interfaceBoardColumnsNames',interfaceBoardColumnsNames) console.log('-------当前有用户信息-------',userInfo)
await store.dispatch('definition/getColumZHList') next()
// const accessRoutes = await store.dispatch('permission/getApiColumnsNames') }else{
// router.addRoutes(accessRoutes) console.log('-------当前没有用户信息-------',userInfo)
next({ if(isAutoLogin || to.query.loginName){
...to, let _username = to.query.loginName || localStorage.getItem("isLoginName") || localStorage.getItem("userNameOrEmailAddress")
query:{ console.log('-------要求自动登录-------',isAutoLogin,to.query.loginName,_username)
loginName:to.query.loginName, // let loginForm= {
isAutoLogin:to.query.isAutoLogin,
isSinglePage:to.query.isSinglePage
},
replace: true
})
}
if(isAutoLogin || to.query.loginName){
console.log('有自动登录',isAutoLogin,to.query.loginName)
// let loginForm= {
// userNameOrEmailAddress:localStorage.getItem("userNameOrEmailAddress"), // userNameOrEmailAddress:localStorage.getItem("userNameOrEmailAddress"),
// password:localStorage.getItem("client_secret"), // password:localStorage.getItem("client_secret"),
// // rememberMe:true, // // rememberMe:true,
@ -88,77 +65,49 @@ router.beforeEach(async (to, from, next) => {
// } // }
// // store.dispatch('user/login', loginForm).then(() => { // // store.dispatch('user/login', loginForm).then(() => {
// login(loginForm).then(()=>{ // login(loginForm).then(()=>{
let _username = to.query.loginName || localStorage.getItem("isLoginName") || localStorage.getItem("userNameOrEmailAddress") await store.dispatch('user/getUserInfo',_username).then(()=>{
if(to.path != '/login'){ console.log("-------用户信息获取成功-------")
await store.dispatch('user/getUserInfo',_username).then(()=>{ next({
next({ ...to,
...to, query:{
query:{ loginName:to.query.loginName,
loginName:to.query.loginName, isAutoLogin:to.query.isAutoLogin,
isAutoLogin:to.query.isAutoLogin, isSinglePage:to.query.isSinglePage
isSinglePage:to.query.isSinglePage },
}, replace: true
replace: true
})
}).catch(()=>{
next()
// next({
// path:'/login',
// query:{
// isAutoLogin:to.query.isAutoLogin,
// isSinglePage:to.query.isSinglePage
// },
// replace: true
// })
// next(`/login?loginName=${to.query.loginName}&isAutoLogin=${to.query.isAutoLogin}`)
// next(`/login`)
Message.error('获取用户信息失败,请重试!')
}) })
}else{ }).catch(()=>{
next() next()
// next({ // next({
// ...to, // path:'/login',
// query:{ // query:{
// loginName:to.query.loginName,
// isAutoLogin:to.query.isAutoLogin, // isAutoLogin:to.query.isAutoLogin,
// isSinglePage:to.query.isSinglePage // isSinglePage:to.query.isSinglePage
// }, // },
// replace: true // replace: true
// }) // })
} // next(`/login?loginName=${to.query.loginName}&isAutoLogin=${to.query.isAutoLogin}`)
// next(`/login`)
localStorage.removeItem("isLoginName")
Message.error('获取用户信息失败,请重试!')
})
// }) // })
// .catch((error) => { // .catch((error) => {
// console.log('登录失败') // console.log('登录失败')
// }) // })
} }else{
else{ console.log('-------不需要自动登录-------',isAutoLogin,to.query.loginName)
console.log('不自动登录',isAutoLogin,to.query.loginName)
if (to.path != '/login') {
Message.error('获取用户信息失败,请重新登录')
next({ next({
path:'/login', path:'/login',
query:{ query:{
isAutoLogin:to.query.isAutoLogin,
loginName:to.query.loginName, loginName:to.query.loginName,
isAutoLogin:to.query.isAutoLogin,
isSinglePage:to.query.isSinglePage isSinglePage:to.query.isSinglePage
}, },
replace: true replace: true
}) })
// next(`/login?loginName=${to.query.loginName}&isAutoLogin=${to.query.isAutoLogin}`)
// next(`/login`)
}else{
// next({
// ...to,
// query:{
// isAutoLogin:to.query.isAutoLogin,
// loginName:to.query.loginName,
// },
// replace: true
// })
next()
} }
} }
NProgress.done()
} }
}) })

9
PC/InterFace.Dash/src/store/getters.js

@ -7,14 +7,13 @@ const getters = {
cachedViews: state => state.tagsView.cachedViews, cachedViews: state => state.tagsView.cachedViews,
token: state => state.user.token, token: state => state.user.token,
avatar: state => state.user.avatar, avatar: state => state.user.avatar,
name: state => state.user.name,
introduction: state => state.user.introduction, introduction: state => state.user.introduction,
roles: state => state.user.roles, roles: state => state.user.roles,
currentUserInfo: state => state.user.userInfo, currentUserInfo: state => state.user.userInfo,//当前用户信息
permission_routes: state => state.permission.routes, permission_routes: state => state.permission.routes,//接口获取的菜单
errorLogs: state => state.errorLog.logs, errorLogs: state => state.errorLog.logs,
dictionaries: state => state.dictionaries.dict, dictionaries: state => state.dictionaries.dict,
enumList: state => state.definition.enumList, enumList: state => state.definition.enumList,//接口获取的枚举
columZHList: state => state.definition.enumList, columZHList: state => state.definition.columZHList,//接口转义的表头
} }
export default getters export default getters

1
PC/InterFace.Dash/src/store/modules/definition.js

@ -29,7 +29,6 @@ const actions = {
return new Promise(resolve => { return new Promise(resolve => {
getInterfaceBoard().then(res=>{ getInterfaceBoard().then(res=>{
let _zh = res.resources[localStorage.getItem('columnsApiNamesZh')].texts; let _zh = res.resources[localStorage.getItem('columnsApiNamesZh')].texts;
localStorage.setItem("interfaceBoardColumnsNames",JSON.stringify(_zh))
commit('GET_COLUMZH_LIST', _zh) commit('GET_COLUMZH_LIST', _zh)
resolve(res) resolve(res)
}) })

3
PC/InterFace.Dash/src/store/modules/permission.js

@ -5,6 +5,7 @@ import {
import Layout from '@/layout' import Layout from '@/layout'
import { getWebMenu } from '@/api/wms-auth' import { getWebMenu } from '@/api/wms-auth'
import { getDefinitionMenu } from '@/api/wms-interface' import { getDefinitionMenu } from '@/api/wms-interface'
import store from '@/store'
/** /**
* Use meta.role to determine if the current user has permission * Use meta.role to determine if the current user has permission
@ -144,7 +145,7 @@ export function initTreeMenusHandle(tree, list,first) {
let _res = [] let _res = []
tree.forEach(item=>{ tree.forEach(item=>{
if(list.indexOf(item.name) >= 0){ if(list.indexOf(item.name) >= 0){
item.title = JSON.parse(localStorage.getItem("interfaceBoardColumnsNames"))[item.name] || item.name item.title = store.getters.columZHList[item.name] || item.name
if(first)item.component = '@/layout' if(first)item.component = '@/layout'
if (item.children && item.children.length > 0) { if (item.children && item.children.length > 0) {
item.children = initTreeMenusHandle(item.children,list) item.children = initTreeMenusHandle(item.children,list)

18
PC/InterFace.Dash/src/utils/index.js

@ -2,6 +2,7 @@
* Created by PanJiaChen on 16/11/18. * Created by PanJiaChen on 16/11/18.
*/ */
import {fileStorage, getPageList, getDictByCode} from '@/api/wms-api' import {fileStorage, getPageList, getDictByCode} from '@/api/wms-api'
import store from '@/store'
/** /**
* Parse the time to string * Parse the time to string
* @param {(Object|string|number)} time * @param {(Object|string|number)} time
@ -560,22 +561,7 @@ export function createNewTabs (url) {
// faster-new // faster-new
// 转义及读取api接口返回的表头信息 // 转义及读取api接口返回的表头信息
export function initFromApiColumnsLable (data) { export function initFromApiColumnsLable (data) {
//todo:待定:重新获取全局从接口缓存的表头(如:接口监控看板) let _Dashboard = store.getters.columZHList
// import { getInterfaceBoard } from "@/api/wms-interface"
// getList = () => {
// getInterfaceBoard().then(result => {
// localStorage.setItem("interfaceBoardColumnsNames", JSON.stringify(result.data.localization.values.Dashboard));
// })
// .catch(err => {
// })
// }
let _Dashboard = null
let _names = localStorage.getItem("interfaceBoardColumnsNames")
if(_names && _names != 'undefined' && _names != 'null') {
_Dashboard = JSON.parse(localStorage.getItem("interfaceBoardColumnsNames"))
}
return _Dashboard ? _Dashboard[data] : null return _Dashboard ? _Dashboard[data] : null
} }

5
PC/InterFace.Dash/src/views/login/index.vue

@ -164,13 +164,12 @@ export default {
handleLogin () { handleLogin () {
this.$refs.loginForm.validate(valid => { this.$refs.loginForm.validate(valid => {
if (valid) { if (valid) {
// todo-new:localStorage.getItem("userNameOrEmailAddress") // todo-new:
this.$store.dispatch('user/getUserInfo',this.loginForm.username).then(()=>{ this.$store.dispatch('user/getUserInfo',this.loginForm.username).then(()=>{
localStorage.setItem('isLoginName',this.loginForm.username)
this.$router.push({ this.$router.push({
path:'/', path:'/',
query:{ query:{
loginName:this.loginForm.username,
isAutoLogin:this.$route.query.isAutoLogin,
isSinglePage:this.$route.query.isSinglePage isSinglePage:this.$route.query.isSinglePage
}, },
replace: true replace: true

2
PC/InterFace.Dash/src/views/profileuser/index.vue

@ -96,7 +96,7 @@ export default {
}, },
methods: { methods: {
getUser() { getUser() {
loadLoginUserInfo(this.$store.getters.name.id).then((response) => { loadLoginUserInfo(this.$store.getters.currentUserInfo.id).then((response) => {
this.user = response; this.user = response;
}); });
}, },

2
PC/InterFace.Dash/src/views/profileuser/resetPwd.vue

@ -74,7 +74,7 @@ export default {
postLoginUserInfo({ postLoginUserInfo({
currentPassword: this.user.oldPassword, currentPassword: this.user.oldPassword,
newPassword: this.user.newPassword, newPassword: this.user.newPassword,
}, this.$store.getters.name.id) }, this.$store.getters.currentUserInfo.id)
.then((response) => { .then((response) => {
this.$notify({ this.$notify({
title: "成功", title: "成功",

Loading…
Cancel
Save