Browse Source

【接口看板】使用单点登录方式进行登录、登出,用户信息,路由等功能开发,首页隐藏菜单优化开发

faster_AG_grid
安虹睿 1 year ago
parent
commit
5c95325765
  1. 64
      PC/InterFace.Dash/package-lock.json
  2. 1
      PC/InterFace.Dash/package.json
  3. 4
      PC/InterFace.Dash/public/config.js
  4. 5
      PC/InterFace.Dash/src/App.vue
  5. 9
      PC/InterFace.Dash/src/api/wms-auth.js
  6. 25
      PC/InterFace.Dash/src/layout/components/Navbar.vue
  7. 21
      PC/InterFace.Dash/src/oidc/oidc-client.js
  8. 61
      PC/InterFace.Dash/src/permission.js
  9. 140
      PC/InterFace.Dash/src/permission0830.js
  10. 146
      PC/InterFace.Dash/src/permission_old.js
  11. 31
      PC/InterFace.Dash/src/router/index.js
  12. 1
      PC/InterFace.Dash/src/store/getters.js
  13. 319
      PC/InterFace.Dash/src/store/modules/permission copy.js
  14. 267
      PC/InterFace.Dash/src/store/modules/permission_old.js
  15. 168
      PC/InterFace.Dash/src/store/modules/user copy.js
  16. 70
      PC/InterFace.Dash/src/store/modules/user.js
  17. 3
      PC/InterFace.Dash/src/utils/request.js
  18. 25
      PC/InterFace.Dash/src/views/callback/index.vue
  19. 7
      PC/InterFace.Dash/src/views/dashboard/index.vue
  20. 4
      PC/InterFace.Dash/src/views/error-page/401.vue
  21. 2
      PC/InterFace.Dash/vue.config.js

64
PC/InterFace.Dash/package-lock.json

@ -27,6 +27,7 @@
"moment": "^2.29.1",
"normalize.css": "7.0.0",
"nprogress": "0.2.0",
"oidc-client": "^1.11.5",
"path-to-regexp": "2.4.0",
"qs": "^6.10.3",
"screenfull": "4.2.0",
@ -7416,6 +7417,11 @@
"node": "*"
}
},
"node_modules/crypto-js": {
"version": "4.1.1",
"resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.1.1.tgz",
"integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw=="
},
"node_modules/css": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz",
@ -16024,6 +16030,35 @@
"integrity": "sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==",
"dev": true
},
"node_modules/oidc-client": {
"version": "1.11.5",
"resolved": "https://registry.npmmirror.com/oidc-client/-/oidc-client-1.11.5.tgz",
"integrity": "sha512-LcKrKC8Av0m/KD/4EFmo9Sg8fSQ+WFJWBrmtWd+tZkNn3WT/sQG3REmPANE9tzzhbjW6VkTNy4xhAXCfPApAOg==",
"dependencies": {
"acorn": "^7.4.1",
"base64-js": "^1.5.1",
"core-js": "^3.8.3",
"crypto-js": "^4.0.0",
"serialize-javascript": "^4.0.0"
}
},
"node_modules/oidc-client/node_modules/acorn": {
"version": "7.4.1",
"resolved": "https://registry.npmmirror.com/acorn/-/acorn-7.4.1.tgz",
"integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
"bin": {
"acorn": "bin/acorn"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/oidc-client/node_modules/core-js": {
"version": "3.32.1",
"resolved": "https://registry.npmmirror.com/core-js/-/core-js-3.32.1.tgz",
"integrity": "sha512-lqufgNn9NLnESg5mQeYsxQP5w7wrViSj0jr/kv6ECQiByzQkrn1MKvV0L3acttpDqfQrHLwr2KCMgX5b8X+lyQ==",
"hasInstallScript": true
},
"node_modules/omelette": {
"version": "0.4.5",
"resolved": "https://registry.npmjs.org/omelette/-/omelette-0.4.5.tgz",
@ -29520,6 +29555,11 @@
"randomfill": "^1.0.3"
}
},
"crypto-js": {
"version": "4.1.1",
"resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.1.1.tgz",
"integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw=="
},
"css": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz",
@ -36331,6 +36371,30 @@
"integrity": "sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==",
"dev": true
},
"oidc-client": {
"version": "1.11.5",
"resolved": "https://registry.npmmirror.com/oidc-client/-/oidc-client-1.11.5.tgz",
"integrity": "sha512-LcKrKC8Av0m/KD/4EFmo9Sg8fSQ+WFJWBrmtWd+tZkNn3WT/sQG3REmPANE9tzzhbjW6VkTNy4xhAXCfPApAOg==",
"requires": {
"acorn": "^7.4.1",
"base64-js": "^1.5.1",
"core-js": "^3.8.3",
"crypto-js": "^4.0.0",
"serialize-javascript": "^4.0.0"
},
"dependencies": {
"acorn": {
"version": "7.4.1",
"resolved": "https://registry.npmmirror.com/acorn/-/acorn-7.4.1.tgz",
"integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A=="
},
"core-js": {
"version": "3.32.1",
"resolved": "https://registry.npmmirror.com/core-js/-/core-js-3.32.1.tgz",
"integrity": "sha512-lqufgNn9NLnESg5mQeYsxQP5w7wrViSj0jr/kv6ECQiByzQkrn1MKvV0L3acttpDqfQrHLwr2KCMgX5b8X+lyQ=="
}
}
},
"omelette": {
"version": "0.4.5",
"resolved": "https://registry.npmjs.org/omelette/-/omelette-0.4.5.tgz",

1
PC/InterFace.Dash/package.json

@ -33,6 +33,7 @@
"moment": "^2.29.1",
"normalize.css": "7.0.0",
"nprogress": "0.2.0",
"oidc-client": "^1.11.5",
"path-to-regexp": "2.4.0",
"qs": "^6.10.3",
"screenfull": "4.2.0",

4
PC/InterFace.Dash/public/config.js

@ -15,6 +15,10 @@ window.SITE_CONFIG['appClientId'] = 'Z_App'
window.SITE_CONFIG['appClientScope'] = 'Z'
// 浏览器名称
window.SITE_CONFIG['browserTitle'] = '接口看板-QAD&WMS'
// 单点登录使用数据
window.SITE_CONFIG['oidcLogin_url'] = 'http://dev.ccwin-in.com:60065',
window.SITE_CONFIG['oidcLogin_clientId'] = 'InterfaceDash_App'
window.SITE_CONFIG['oidcLogin_scopes'] = 'offline_access Z profile'
// 隐藏的页面
window.SITE_CONFIG['menuHiddenConfig'] = [
'AsnDet','PoDet','ReceiptDet','ReturnDet',

5
PC/InterFace.Dash/src/App.vue

@ -18,6 +18,11 @@ localStorage.setItem('isSinglePage',window.SITE_CONFIG['isSinglePage'])
localStorage.setItem('appClientId',window.SITE_CONFIG['appClientId'])
localStorage.setItem('appClientScope',window.SITE_CONFIG['appClientScope'])
localStorage.setItem('browserTitle',window.SITE_CONFIG['browserTitle'])
// 使
localStorage.setItem('oidcLogin_url',window.SITE_CONFIG['oidcLogin_url'])
localStorage.setItem('oidcLogin_clientId',window.SITE_CONFIG['oidcLogin_clientId'])
localStorage.setItem('oidcLogin_scopes',window.SITE_CONFIG['oidcLogin_scopes'])
//
localStorage.setItem('menuHiddenConfig',window.SITE_CONFIG['menuHiddenConfig'])
// localStorage.setItem('isAutoLogin',window.SITE_CONFIG['isAutoLogin'])

9
PC/InterFace.Dash/src/api/wms-auth.js

@ -30,6 +30,15 @@ export function token(data) {
})
}
// 获取用户信息(单点登录)
export function getUsersByToken(token) {
return request({
url: localStorage.getItem('oidcLogin_url') + '/connect/userinfo',
method: 'get',
Token:token
})
}
// 通过用户名获取用户信息
export function getUsersByUserName(name) {
return request({

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

@ -1,5 +1,5 @@
<template>
<div class="navbar">
<div class="navbar" v-loading.fullscreen.lock="fullscreenLoading">
<hamburger
id="hamburger-container"
:is-active="sidebar.opened"
@ -36,7 +36,7 @@
<router-link to="/">
<el-dropdown-item>系统首页</el-dropdown-item>
</router-link>
<!-- <el-dropdown-item divided @click.native="handleClick">
<!-- <el-dropdown-item @click.native="showProfileuser">
<span style="display: block">个人中心</span>
</el-dropdown-item> -->
<el-dropdown-item divided @click.native="logout">
@ -57,6 +57,10 @@ import Screenfull from "@/components/Screenfull";
import SizeSelect from "@/components/SizeSelect";
import Search from "@/components/HeaderSearch";
import getPageTitle from '@/utils/get-page-title'
import { mgr } from "@/oidc/oidc-client";
import {
logout,
} from '@/api/wms-auth'
export default {
components: {
@ -69,6 +73,7 @@ export default {
},
data(){
return{
fullscreenLoading:false,
pageTitle:getPageTitle()
}
},
@ -80,13 +85,19 @@ export default {
this.$store.dispatch("app/toggleSideBar");
},
async logout() {
await this.$store.dispatch("user/logout")
this.$router.push(`/login?redirect=${this.$route.fullPath}`);
// this.$router.push(`/login?redirect=${this.$route.fullPath}&isAutoLogin=false`)
// this.$router.push(`/login?isAutoLogin=false`)
this.fullscreenLoading = true
mgr.signoutRedirect()
mgr.signoutRedirectCallback()
.then(() => {
this.$store.dispatch("user/logout")
})
.catch(function(error){
this.$message.error("退出登录失败,请重试")
this.fullscreenLoading = false
})
},
handleClick() {
showProfileuser() {
this.$router.push({ name: 'Profileuser'});
},
},

21
PC/InterFace.Dash/src/oidc/oidc-client.js

@ -0,0 +1,21 @@
import Oidc from "oidc-client";
export const identityServerBase = localStorage.getItem('oidcLogin_url');//目标服务器登录地址
export const vueBase = window.location.origin
// 参考文档 https://github.com/IdentityModel/oidc-client-js/wiki
export const mgr = new Oidc.UserManager({
authority: `${identityServerBase}`, // 认证服务器
client_id: localStorage.getItem('oidcLogin_clientId'), // 表示客户端的ID,必选项
redirect_uri: `${vueBase}/callback`,// 表示重定向URI,认证服务器回调的客户端页面。可选项
response_type: `code`,
scope: localStorage.getItem('oidcLogin_scopes'), // 表示申请的权限范围,可选项
post_logout_redirect_uri: `${vueBase}/home?action=logout`,
automaticSilentRenew: false,
// accessTokenExpiringNotificationTime: 10,
// filterProtocolClaims: false,
// loadUserInfo: true,
// monitorSession: false,
// includeIdTokenInSilentRenew : false,
});

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

@ -5,13 +5,15 @@ import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
import { getToken,removeToken } from '@/utils/auth' // get token from cookie
import getPageTitle from '@/utils/get-page-title'
import { mgr } from "@/oidc/oidc-client";
NProgress.configure({
showSpinner: false
}) // NProgress Configuration
const whiteList = ['/login'] // no redirect whitelist
const whiteList = ['/login','/callback'] // no redirect whitelist
const noUserMsg = '获取用户信息失败,请重新登录 !'
const getErrMsg = '数据获取失败 !'
// 跳转登录页
const pageToLogin = (to, from, next) => {
@ -55,18 +57,27 @@ const toNextHandle = async (to, from, next) => {
// 获取表头转义
if(!store.getters.columZHList){
await store.dispatch('definition/getColumZHList')
await store.dispatch('definition/getColumZHList').catch(()=>{
Message.error(getErrMsg)
NProgress.done()
})
}
// 获取菜单数据
if(!store.getters.permission_routes || store.getters.permission_routes.length <= 0){
isFresh = true
await store.dispatch('permission/getApiColumnsNames')
await store.dispatch('permission/getApiColumnsNames').catch(()=>{
Message.error(getErrMsg)
NProgress.done()
})
}
// 获取枚举数据
if(!store.getters.enumList || store.getters.enumList.length <= 0){
await store.dispatch('definition/getDefinitionConfig')
await store.dispatch('definition/getDefinitionConfig').catch(()=>{
Message.error(getErrMsg)
NProgress.done()
})
}
if(isFresh){
@ -88,7 +99,7 @@ router.beforeEach(async (to, from, next) => {
// 判断是否自动登录
let isAutoLogin = JSON.parse(localStorage.getItem('isConfigLogin')) || to.query.loginName
if(hasToken){
if(hasToken || to.path == '/callback'){
if (to.path === '/login') {
console.log('有token,是登录页,将跳转至/')
// if is logged in, redirect to the home page
@ -97,30 +108,38 @@ router.beforeEach(async (to, from, next) => {
})
NProgress.done() // hack: https://github.com/PanJiaChen/vue-element-admin/pull/2939
} else {
console.log('有token,不是登录页,toPageInit')
if(to.path == '/callback'){
console.log('有token,是callback页,next')
next()
}else{
console.log('有token,不是登录页,不是callback页,toPageInit')
await toPageInit(to, from, next)
}
}
}else{
if (to.path === '/login') {
console.log('没有token,是登录页,pageToLogin')
pageToLogin(to, from, next)
} else {
if(isAutoLogin){
let _username = localStorage.getItem("isConfigLogin") && localStorage.getItem("isConfigLogin") != 'false' ? localStorage.getItem("configLoginName") : to.query.loginName
await store.dispatch('user/loginOnlyName', {username:_username})
.then(()=>{
toPageInit(to, from, next)
})
.catch(()=>{
// todo-fast:接口恢复后更改
toNextHandle(to, from, next)
// Message.error(noUserMsg)
// todo:自动登录,即没有密码登录情况处理
mgr.signinRedirect(); //执行重定向
// if(isAutoLogin){
// let _username = localStorage.getItem("isConfigLogin") && localStorage.getItem("isConfigLogin") != 'false' ? localStorage.getItem("configLoginName") : to.query.loginName
// await store.dispatch('user/loginOnlyName', {username:_username})
// .then(()=>{
// toPageInit(to, from, next)
// })
// .catch(()=>{
// // todo-fast:接口恢复后更改
// toNextHandle(to, from, next)
// // Message.error(noUserMsg)
// // pageToLogin(to, from, next)
// })
// }else{
// console.log('没有token,不是登录页,不是自动登录,pageToLogin')
// pageToLogin(to, from, next)
})
}else{
console.log('没有token,不是登录页,不是自动登录,pageToLogin')
pageToLogin(to, from, next)
}
// }
}
}
})

140
PC/InterFace.Dash/src/permission0830.js

@ -1,140 +0,0 @@
// 第一版token路由
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'
NProgress.configure({
showSpinner: false
}) // NProgress Configuration
const whiteList = ['/login', '/auth-redirect', '/testForm'] // no redirect whitelist
// 跳转登录页
const pageToLogin = (to, from, next) => {
if (whiteList.indexOf(to.path) !== -1) {
// in the free login whitelist, go directly
next()
NProgress.done()
} else {
// other pages that do not have permission to access are redirected to the login page.
next(`/login?redirect=${to.path}`)
NProgress.done()
}
}
// 首次进入页面加载数据处理
const toPageInit = async (to, from, next) => {
let isFresh = false
// 获取表头转义
if(!store.getters.columZHList){
await store.dispatch('definition/getColumZHList')
}
// 获取菜单数据
if(!store.getters.permission_routes || store.getters.permission_routes.length <= 0){
isFresh = true
await store.dispatch('permission/getApiColumnsNames')
}
// 获取枚举数据
if(!store.getters.enumList || store.getters.enumList.length <= 0){
await store.dispatch('definition/getDefinitionConfig')
}
// 获取用户信息
let _username = to.query.loginName || localStorage.getItem("isLoginName") || localStorage.getItem("loginName")
if(!store.getters.currentUserInfo || store.getters.currentUserInfo.length <= 0){
await store.dispatch('user/getUserInfo',_username)
.then(()=>{
toNextHandle(to, from, next,isFresh)
})
.catch(()=>{
toNextHandle(to, from, next,isFresh)
})
}else{
toNextHandle(to, from, next,isFresh)
}
}
// 跳转处理
const toNextHandle = (to, from, next,isFresh) => {
if(isFresh){
next({...to,replace:true})
}else{
next()
}
NProgress.done()
}
router.beforeEach(async (to, from, next) => {
// start progress bar
NProgress.start()
// set page title
document.title = getPageTitle()
const hasToken = getToken()
// 判断是否自动登录
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)
}
if(hasToken){
if (to.path === '/login') {
console.log('有token,是登录页,将跳转至/')
// if is logged in, redirect to the home page
next({
path: '/'
})
NProgress.done() // hack: https://github.com/PanJiaChen/vue-element-admin/pull/2939
} else {
console.log('有token,不是登录页,toPageInit')
await toPageInit(to, from, next)
}
}else{
if (to.path === '/login') {
console.log('没有token,是登录页,pageToLogin')
pageToLogin(to, from, next)
} else {
if(isAutoLogin){
console.log('没有token,不是登录页,是自动登录,自动登录是否成功都将继续toPageInit')
let _username = to.query.loginName || localStorage.getItem("isLoginName") || localStorage.getItem("loginName")
let _password = to.query.loginPass || localStorage.getItem("client_secret")
// todo-fast:password确定
await store.dispatch('user/login', {password:_password,username:_username})
.then(()=>{
toPageInit(to, from, next)
})
.catch(()=>{
toPageInit(to, from, next)
})
}else{
console.log('没有token,不是登录页,不是自动登录,pageToLogin')
pageToLogin(to, from, next)
}
}
}
})
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()
})

146
PC/InterFace.Dash/src/permission_old.js

@ -1,146 +0,0 @@
// 加token之前版本
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
router.beforeEach(async (to, from, next) => {
// start progress bar
NProgress.start()
// set page title
document.title = getPageTitle()
const hasToken = getToken()
console.log(21,'hasToken',hasToken,!hasToken)
// 获取表头转义
if(!store.getters.columZHList || store.getters.columZHList.length <= 0){
await store.dispatch('definition/getColumZHList',()=>{
NProgress.done()
})
}
// 获取菜单数据
if(!store.getters.permission_routes || store.getters.permission_routes.length <= 0){
const accessRoutes = await store.dispatch('permission/getApiColumnsNames')
router.addRoutes(accessRoutes)
console.log(35,router)
}
// 获取枚举数据
if(!store.getters.enumList || store.getters.enumList.length <= 0){
await store.dispatch('definition/getDefinitionConfig')
}
// 是否已尝试过自动登录
const alreadyTryLogin = localStorage.getItem('alreadyTryLogin')
// 是否有用户信息:
const userInfo = store.getters.currentUserInfo
// 判断是否自动登录
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)
}
if(to.path == '/login'){
console.log('-------当前路由为登录页-------')
next()
}else{
console.log('-------当前路由不是登录页-------')
if((userInfo && userInfo.id) || alreadyTryLogin == 'true'){
if(userInfo && userInfo.id){
console.log('-------当前有用户信息-------',userInfo)
}else{
console.log('-------当前没有用户信息,但是已尝试过登录-------')
}
next()
}else{
console.log('-------当前没有用户信息-------')
if(isAutoLogin || to.query.loginName){
let _username = to.query.loginName || localStorage.getItem("isLoginName") || localStorage.getItem("loginName")
console.log('-------要求自动登录-------',isAutoLogin,to.query.loginName,_username)
// let loginForm= {
// userNameOrEmailAddress:localStorage.getItem("loginName"),
// password:localStorage.getItem("client_secret"),
// // rememberMe:true,
// // grant_type: 'password',
// // client_id: 'Auth_App',
// }
// // store.dispatch('user/login', loginForm).then(() => {
// login(loginForm).then(()=>{
await store.dispatch('user/getUserInfo',_username).then(()=>{
console.log("-------用户信息获取成功-------")
localStorage.setItem('alreadyTryLogin',true)
next(to)
NProgress.done()
// next({
// ...to,
// query:{
// loginName:to.query.loginName,
// isAutoLogin:to.query.isAutoLogin,
// isSinglePage:to.query.isSinglePage
// },
// replace: true
// })
}).catch(()=>{
localStorage.setItem('alreadyTryLogin',true)
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`)
localStorage.setItem("isLoginName",_username)
// Message.error('获取用户信息失败,请重试!')
})
// })
// .catch((error) => {
// console.log('登录失败')
// })
}else{
console.log('-------不需要自动登录-------',isAutoLogin,to.query.loginName)
next({
path:'/login',
query:{
loginName:to.query.loginName,
isAutoLogin:to.query.isAutoLogin,
isSinglePage:to.query.isSinglePage
},
replace: true
})
NProgress.done()
}
}
}
localStorage.setItem('alreadyTryLogin',false)
})
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()
})

31
PC/InterFace.Dash/src/router/index.js

@ -60,15 +60,20 @@ export let constantRoutes = [
component: () => import('@/views/error-page/401'),
hidden: true
},
{
path: '/callback',
component: () => import('@/views/callback/index'),
hidden: true
},
{
path: '/',
component: Layout,
redirect: '/dashboard',
redirect: '/home',
// hidden: true,
children: [{
path: 'dashboard',
path: 'home',
component: () => import('@/views/dashboard/index'),
name: 'Dashboard',
name: 'Home',
meta: {
keepAlive : true,
title: i18n.t('common.home'),
@ -96,6 +101,22 @@ export let constantRoutes = [
}
}]
},
{
path: '/profileuser',
component: Layout,
redirect: '/profileuser/index',
hidden: true,
children: [{
path: 'index',
component: () => import('@/views/profileuser/index'),
name: 'Profileuser',
meta: {
title: '个人中心',
icon: 'user',
noCache: true
}
}]
},
// {
// path: '/',
// component: Layout,
@ -132,13 +153,11 @@ export let asyncRoutes = [
]
const createRouter = () => new Router({
// mode: 'history', // require service support
mode: 'history', // 单点登录需要使用history,require service support
scrollBehavior: () => ({
y: 0
}),
// todo-new:有token后使用去掉下一行代码
// routes: constantRoutes.concat(asyncRoutes)
// todo-new:有token后使打开下方代码,并检查是否有效
routes: constantRoutes
})

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

@ -5,7 +5,6 @@ const getters = {
loading: state => state.app.loading,
visitedViews: state => state.tagsView.visitedViews,
cachedViews: state => state.tagsView.cachedViews,
token: state => state.user.token,
introduction: state => state.user.introduction,
roles: state => state.permission.roles,//当前用户权限
currentUserInfo: state => state.user.userInfo,//当前用户信息

319
PC/InterFace.Dash/src/store/modules/permission copy.js

@ -1,319 +0,0 @@
import {
asyncRoutes,
constantRoutes
} from '@/router'
import Layout from '@/layout'
import { getDefinitionMenu } from '@/api/wms-auth'
import store from '@/store'
import router from '@/router'
/**
* Use meta.role to determine if the current user has permission
* @param roles
* @param route
*/
function hasPermission(roles, route) {
if (route.meta && route.meta.roles) {
if (route.meta.roles == "skip") {
return true
} else {
return roles.some(role => route.meta.roles.includes(role))
}
} else {
return false
}
}
const filterAccessedRoutes = (items,indexVal,childrenIndex) => {
const route = JSON.parse(JSON.stringify(items))
route.forEach((val, index) => {
// debugger;
if(val.meta && val.meta.roles == "skip"){
if (val.children && val.children.length != 0) {
filterAccessedRoutes(items[index-indexVal].children,childrenIndex)
}
if(items[index-indexVal].children && items[index-indexVal].children.length == 0){
items.splice(index-indexVal, 1)
indexVal++
}
}
})
indexVal = 0
}
/**
* Filter asynchronous routing tables by recursion
* @param routes asyncRoutes
* @param roles
*/
export function filterAsyncRoutes(routes, roles) {
const res = []
routes.forEach(route => {
const tmp = {
...route
}
if (hasPermission(roles, tmp)) {
if (tmp.children) {
tmp.children = filterAsyncRoutes(tmp.children, roles)
}
res.push(tmp)
}
})
return res
}
const state = {
routes: [],//菜单
// addRoutes: [],
tablesName:null,//所有的表名
abpIdentityName:null,//所有身份配置权限
}
const mutations = {
SET_ROUTES: (state, routes) => {
// state.addRoutes = routes
state.routes = constantRoutes.concat(routes)
router.addRoutes(routes)
},
SET_TABLESNAME: (state, data) => {
state.tablesName = data
},
SET_AbpIdentity: (state, data) => {
state.abpIdentityName = data
}
}
/**
* 静态路由懒加载
* @param view 格式必须为 xxx/xxx 开头不要加斜杠
* @returns
*/
export const loadView = (view) => {
return (resolve) => require([`@/views/menuList/${view}`], resolve)
}
const AbpIdentity_mark = 'AbpIdentityMark'
/**
* 把从后端查询的菜单数据拼装成路由格式的数据
* @param routes
* @param data 后端返回的菜单数据
*/
export function generaMenu(routes, data, first) {
// 不显示的菜单配置隐藏
let _noShowMenus = localStorage.getItem('menuHiddenConfig').split(',')
data.forEach(item => {
let _item = {
path: '/'+item.name,
component: loadView(item.name),
hidden: _noShowMenus.indexOf(item.name) >= 0, // 状态为0的隐藏
name: item.name,
// meta: item.meta
meta: {
title: item.title,
icon: item.icon || 'svg_default',
roles: item.permission,
outerFirst:first
},
}
let menu = _item
if(first && item.component == '@/layout'){
menu = {
path: '/',
component: Layout,
redirect: '/' + item.name,
children: [],
}
menu.children = []
menu.children.push(_item)
}
// 一级菜单 二级菜单 特定属性
// if (item.component == '@/layout' || item.component == 'index') {
// menu.alwaysShow = true
// menu.redirect = 'noRedirect'
// }
// if (item.sort < 99) {
// menu.level = 1
// } else if (item.sort > 99 && item.sort < 9999) {
// menu.level = 2
// } else {
// menu.level = 3
// }
// iframe页面处理
// if (item.permission.indexOf('Report') > -1) {
// // delete menu.component
// menu.iframeComponent = item.component === '@/layout' ? Layout : loadView(item.component)
// menu.hasOpen = false // 是否打开过,默认false
// }
if (item.children && item.children.length > 0) {
generaMenu(menu.children, item.children)
}
// if (item.permission == 'skip' && item.children.length == 0) {
// }
if(!routes)routes = []
routes.push(menu)
})
return routes
}
// todo:接口返回的层级菜单,与查重后最终显示的菜单数组做查重及组合处理
export function initTreeMenusHandle(tree, list,first) {
let _res = []
tree.forEach(item=>{
// 如果有身份权限的页面
// if(state.abpIdentityName && state.abpIdentityName.length > 0){
// // // 身份权限的页面(角色等)
// if(item.name == '系统权限管理'){
// let _name = item.name.slice(AbpIdentity_mark.length,item.name.length)
// console.log(165,item.name,_name)
// // item.title = store.getters.columZHList[_name] || _name
// // if(first)item.component = '@/layout'
// // if (item.children && item.children.length > 0) {
// // item.children = initTreeMenusHandle(item.children,list)
// // }
// // _res.push(item)
// }
// }
//配置权限的页面
// else{
if(list.indexOf(item.name) >= 0){
item.title = store.getters.columZHList[item.name] || item.name
console.log(175,item.name,first)
if(first){
// if(item.name == AbpIdentity_mark){
// item.title = '系统权限管理'
// }
item.component = '@/layout'
}
if (item.children && item.children.length > 0) {
item.children = initTreeMenusHandle(item.children,list)
}
console.log(186,item)
_res.push(item)
}
// }
})
console.log(191,_res)
return _res
}
const actions = {
getApiColumnsNames({
commit
}, userId) {
return new Promise(resolve => {
let accessedRoutes = asyncRoutes
// accessedRoutes = filterAsyncRoutes(asyncRoutes, roles)
// let indexVal = 0
// let childrenIndex = 0
// filterAccessedRoutes(accessedRoutes,indexVal,childrenIndex)
// commit('SET_ROUTES', accessedRoutes)
// resolve(accessedRoutes)
getDefinitionMenu(true).then(res => {
let _allConfig = res.auth.grantedPolicies;//所有配置
let _menuList = []//接口获取所有的菜单
let _AbpIdentity = []//接口获取所有的身份配置信息数据
for(let item in _allConfig){
let point_number = item.split('.').length - 1
// 只选择配置项中的数据
if(point_number == 1 && item.substring(0,item.indexOf('.')) == localStorage.getItem('appClientScope')){
_menuList.push(item.substring(item.indexOf('.') + 1,item.length))
}
// 身份配置信息数据(用户、角色)
if(point_number == 1 && item.substring(0,item.indexOf('.')) == 'AbpIdentity'){
_AbpIdentity.push(AbpIdentity_mark + item.substring(item.indexOf('.') + 1,item.length))
}
}
// 存储所有的表名
commit('SET_TABLESNAME', _menuList)
// 存储身份标识
commit('SET_AbpIdentity', _AbpIdentity)
// 数据模拟,todo-new:接口获取
let _treeMenusAll = null//树形菜单
_treeMenusAll = [
{name:"aaaaaaa"},
{name:"ExportCustomUserSetting"
// ,children:[
// {name:'OutgoingDataHistory',children:[
// {name:'IncomingData',children:[
// {name:'OutgoingDataHistory'},
// {name:'IncomingData'},
// {name:'333333'},
// ]},
// {name:'eee1111-bbb',children:[
// {name:'ExportCustomUserSetting'},
// {name:'MessageReceive'},
// ]},
// ]},
// {name:'eee222'},
// {name:'eee333'},
// {name:'eee444'},
// {name:'eee555'},
// ]
},
{name:"OutgoingDataHistory"},
{name:"IncomingData"},
{name:"IncomingDataHistory"},
{name:"MesProductL7PartsNote"},
{name:"MessageReceive"},
{name:"OutgoingData"},
{name:"AsnDet"},
{name:"AsnMstr"},
{name:"Bom"},
{name:"CustPart"},
{name:"Cust"},
{name:"Inventory"},
{name:"Loc"},
{name:"Part"},
{name:"PoDet"},
{name:"PoMstr"},
{name:"PrhHist"},
{name:"ProdLine"},
{name:"ReceiptDet"},
{name:"ReceiptMstr"},
{name:"ReturnDet"},
{name:"ReturnMstr"},
{name:"SodDet"},
{name:"VendPart"},
{name:"Vend"},
]
// 包含配置项中的业务菜单+身份权限菜单(角色用户等)
// let _menuAndAbpList = [..._menuList,...[AbpIdentity_mark],..._AbpIdentity]
let _menuAndAbpList = [..._menuList,..._AbpIdentity]
let _initTreeMenus = []
if(_treeMenusAll && _treeMenusAll.length > 0){
_initTreeMenus = initTreeMenusHandle(_treeMenusAll,_menuAndAbpList,true)
}else{
let _data = []
if(_AbpIdentity && _AbpIdentity.length > 0){
_data.push({name:AbpIdentity_mark,children:[]})
}
for(let i in _menuAndAbpList){
if(_menuAndAbpList[i].indexOf(AbpIdentity_mark) >= 0){
_data[0].children.push({ name:_menuAndAbpList[i] })
}
else{
_data.push({name:_menuAndAbpList[i]})
}
}
_initTreeMenus = initTreeMenusHandle(_data,[..._menuAndAbpList,...[AbpIdentity_mark]],true)
}
// 最后查重+层级查重后的菜单
let _initEndMenus = generaMenu(asyncRoutes, _initTreeMenus,true)
let accessedRoutes = _initEndMenus
// let indexVal = 0
// let childrenIndex = 0
// filterAccessedRoutes(accessedRoutes,indexVal,childrenIndex)
commit('SET_ROUTES', accessedRoutes)
resolve(accessedRoutes)
}).catch(err => {
console.log(err)
})
})
},
}
export default {
namespaced: true,
state,
mutations,
actions
}

267
PC/InterFace.Dash/src/store/modules/permission_old.js

@ -1,267 +0,0 @@
import {
asyncRoutes,
constantRoutes
} from '@/router'
import Layout from '@/layout'
import { getDefinitionMenu } from '@/api/wms-auth'
import store from '@/store'
import router from '@/router'
/**
* Use meta.role to determine if the current user has permission
* @param roles
* @param route
*/
function hasPermission(roles, route) {
if (route.meta && route.meta.roles) {
if (route.meta.roles == "skip") {
return true
} else {
return roles.some(role => route.meta.roles.includes(role))
}
} else {
return false
}
}
const filterAccessedRoutes = (items,indexVal,childrenIndex) => {
const route = JSON.parse(JSON.stringify(items))
route.forEach((val, index) => {
// debugger;
if(val.meta && val.meta.roles == "skip"){
if (val.children && val.children.length != 0) {
filterAccessedRoutes(items[index-indexVal].children,childrenIndex)
}
if(items[index-indexVal].children && items[index-indexVal].children.length == 0){
items.splice(index-indexVal, 1)
indexVal++
}
}
})
indexVal = 0
}
/**
* Filter asynchronous routing tables by recursion
* @param routes asyncRoutes
* @param roles
*/
export function filterAsyncRoutes(routes, roles) {
const res = []
routes.forEach(route => {
const tmp = {
...route
}
if (hasPermission(roles, tmp)) {
if (tmp.children) {
tmp.children = filterAsyncRoutes(tmp.children, roles)
}
res.push(tmp)
}
})
return res
}
const state = {
routes: [],//菜单
addRoutes: [],
tablesName:null,//所有的表名
}
const mutations = {
SET_ROUTES: (state, routes) => {
state.addRoutes = routes
state.routes = constantRoutes.concat(routes)
router.addRoutes(routes)
},
SET_TABLESNAME: (state, data) => {
state.tablesName = data
}
}
/**
* 静态路由懒加载
* @param view 格式必须为 xxx/xxx 开头不要加斜杠
* @returns
*/
export const loadView = (view) => {
return (resolve) => require([`@/views/menuList/${view}`], resolve)
}
/**
* 把从后端查询的菜单数据拼装成路由格式的数据
* @param routes
* @param data 后端返回的菜单数据
*/
export function generaMenu(routes, data, first) {
// 不显示的菜单配置隐藏
let _noShowMenus = localStorage.getItem('menuHiddenConfig').split(',')
data.forEach(item => {
let _item = {
path: '/'+item.name,
component: loadView(item.name),
hidden: _noShowMenus.indexOf(item.name) >= 0, // 状态为0的隐藏
name: item.name,
// meta: item.meta
meta: {
title: item.title,
icon: item.icon || 'svg_default',
roles: item.permission,
outerFirst:first
},
}
let menu = _item
if(first && item.component == '@/layout'){
menu = {
path: '/',
component: Layout,
redirect: '/' + item.name,
children: [],
}
menu.children = []
menu.children.push(_item)
}
// 一级菜单 二级菜单 特定属性
// if (item.component == '@/layout' || item.component == 'index') {
// menu.alwaysShow = true
// menu.redirect = 'noRedirect'
// }
// if (item.sort < 99) {
// menu.level = 1
// } else if (item.sort > 99 && item.sort < 9999) {
// menu.level = 2
// } else {
// menu.level = 3
// }
// iframe页面处理
// if (item.permission.indexOf('Report') > -1) {
// // delete menu.component
// menu.iframeComponent = item.component === '@/layout' ? Layout : loadView(item.component)
// menu.hasOpen = false // 是否打开过,默认false
// }
if (item.children && item.children.length > 0) {
generaMenu(menu.children, item.children)
}
// if (item.permission == 'skip' && item.children.length == 0) {
// }
routes.push(menu)
})
return routes
}
// todo:接口返回的层级菜单,与查重后最终显示的菜单数组做查重及组合处理
export function initTreeMenusHandle(tree, list,first) {
let _res = []
tree.forEach(item=>{
if(list.indexOf(item.name) >= 0){
item.title = store.getters.columZHList[item.name] || item.name
if(first)item.component = '@/layout'
if (item.children && item.children.length > 0) {
item.children = initTreeMenusHandle(item.children,list)
}
_res.push(item)
}
})
return _res
}
const actions = {
getApiColumnsNames({
commit
}, userId) {
return new Promise(resolve => {
let accessedRoutes = asyncRoutes
// accessedRoutes = filterAsyncRoutes(asyncRoutes, roles)
// let indexVal = 0
// let childrenIndex = 0
// filterAccessedRoutes(accessedRoutes,indexVal,childrenIndex)
// commit('SET_ROUTES', accessedRoutes)
// resolve(accessedRoutes)
getDefinitionMenu(true).then(res => {
let _allConfig = res.auth.grantedPolicies;//所有配置
let _menuList = []//接口获取所有的菜单
for(let item in _allConfig){
let point_number = item.split('.').length - 1
// 只选择配置项中的数据
if(point_number == 1 && item.substring(0,item.indexOf('.')) == localStorage.getItem('appClientScope')){
_menuList.push(item.substring(item.indexOf('.') + 1,item.length))
}
}
// 存储所有的表名
commit('SET_TABLESNAME', _menuList)
// 数据模拟,todo-new:接口获取
let _treeMenusAll = null//树形菜单
// _treeMenusAll = [
// {name:"aaaaaaa"},
// {name:"ExportCustomUserSetting"
// // ,children:[
// // {name:'OutgoingDataHistory',children:[
// // {name:'IncomingData',children:[
// // {name:'OutgoingDataHistory'},
// // {name:'IncomingData'},
// // {name:'333333'},
// // ]},
// // {name:'eee1111-bbb',children:[
// // {name:'ExportCustomUserSetting'},
// // {name:'MessageReceive'},
// // ]},
// // ]},
// // {name:'eee222'},
// // {name:'eee333'},
// // {name:'eee444'},
// // {name:'eee555'},
// // ]
// },
// {name:"OutgoingDataHistory"},
// {name:"IncomingData"},
// {name:"IncomingDataHistory"},
// {name:"MesProductL7PartsNote"},
// {name:"MessageReceive"},
// {name:"OutgoingData"},
// {name:"AsnDet"},
// {name:"AsnMstr"},
// {name:"Bom"},
// {name:"CustPart"},
// {name:"Cust"},
// {name:"Inventory"},
// {name:"Loc"},
// {name:"Part"},
// {name:"PoDet"},
// {name:"PoMstr"},
// {name:"PrhHist"},
// {name:"ProdLine"},
// {name:"ReceiptDet"},
// {name:"ReceiptMstr"},
// {name:"ReturnDet"},
// {name:"ReturnMstr"},
// {name:"SodDet"},
// {name:"VendPart"},
// {name:"Vend"},
// ]
let _initTreeMenus = []
if(_treeMenusAll && _treeMenusAll.length > 0){
_initTreeMenus = initTreeMenusHandle(_treeMenusAll,_menuList,true)
}else{
let _data = []
for(let i in _menuList){
_data.push({name:_menuList[i]})
}
_initTreeMenus = initTreeMenusHandle(_data,_menuList,true)
}
// 最后查重+层级查重后的菜单
let _initEndMenus = generaMenu(asyncRoutes, _initTreeMenus,true)
let accessedRoutes = _initEndMenus
// let indexVal = 0
// let childrenIndex = 0
// filterAccessedRoutes(accessedRoutes,indexVal,childrenIndex)
commit('SET_ROUTES', accessedRoutes)
resolve(accessedRoutes)
}).catch(err => {
console.log(err)
})
})
},
}
export default {
namespaced: true,
state,
mutations,
actions
}

168
PC/InterFace.Dash/src/store/modules/user copy.js

@ -1,168 +0,0 @@
import {
token,
logout,
getUsersByUserName
} from '@/api/wms-auth'
import {
getToken,
setToken,
removeToken,
} from '@/utils/auth'
import router, {
resetRouter
} from '@/router'
import qs from 'qs'
import store from '@/store'
const state = {
token: getToken(),
introduction: '',
roles: [],
userInfo:null
}
const mutations = {
SET_TOKEN: (state, token) => {
state.token = token
},
SET_INTRODUCTION: (state, introduction) => {
state.introduction = introduction
},
// 设置权限(v-permission)
SET_ROLES: (state, roles) => {
let _roles = [
'IncomingDataHistory.filter',
'IncomingData.export',
'MesProductL7PartsNote.filter',
'MesProductL7PartsNote.export'
]
state.roles = _roles
},
SET_USERINFO: (state, data) => {
state.userInfo = data
}
}
const actions = {
// user login
login({
commit,
dispatch
}, userInfo) {
const {
password,
username,
company,
warehouseCode
} = userInfo
let loginData = {
userNameOrEmailAddress: username,
password: password,
rememberMe: true
}
let parseData = JSON.parse(JSON.stringify(userInfo))
delete parseData.warehouseCode
delete parseData.company
parseData.client_secret = window.SITE_CONFIG['client_secret']
let tokenData = qs.stringify(parseData)
return new Promise((resolve, reject) => {
// login(loginData).then(response => {
let params = qs.stringify({
password: password,
username: username,
client_id:'Z_App',
grant_type:'password',
scopes:'Z'
});
token(params).then(response => {
const {
access_token,
token_type
} = response
if (access_token == null) {
reject()
} else {
commit('SET_TOKEN', access_token)
setToken(token_type + ' ' + access_token)
store.dispatch('user/getUserInfo',username).then(()=>{
resolve()
}).catch(()=>{
reject()
})
}
}).catch(error => {
reject(error)
})
// }).catch(error => {
// reject(error)
// })
})
},
// user logout
logout({
commit,
dispatch
}) {
return new Promise((resolve, reject) => {
// logout().then(() => {
commit('SET_TOKEN', null)
commit('SET_USERINFO', null)
removeToken()
store.dispatch('permission/clearRouters')
// resetRouter()
// reset visited views and cached views
// to fixed https://github.com/PanJiaChen/vue-element-admin/issues/2485
dispatch('tagsView/delAllViews', null, {
root: true
})
resolve()
// 防止路由叠加
// location.reload()
// }).catch(error => {
// reject(error)
// })
})
},
// remove token
resetToken({
commit
}) {
return new Promise(resolve => {
commit('SET_TOKEN', '')
commit('SET_ROLES', [])
removeToken()
resolve()
})
},
// get userInfo
getUserInfo({
commit
},username) {
return new Promise((resolve, reject) => {
getUsersByUserName(username).then(res=>{
if(res && JSON.stringify(res).length > 0){
localStorage.setItem('isLoginName',username)
// commit('SET_ROLES', res)
commit('SET_USERINFO', res)
resolve(res)
}else{
reject('获取用户信息失败,请重试')
}
})
.catch(err => {
reject(err)
console.log('获取用户信息失败,请重试')
})
})
},
}
export default {
namespaced: true,
state,
mutations,
actions
}

70
PC/InterFace.Dash/src/store/modules/user.js

@ -1,6 +1,7 @@
import {
token,
logout,
getUsersByToken,
getUsersByUserName
} from '@/api/wms-auth'
import {
@ -13,17 +14,14 @@ import router, {
} from '@/router'
import qs from 'qs'
import store from '@/store'
import { mgr } from "@/oidc/oidc-client";
const state = {
token: getToken(),
introduction: '',
userInfo:null
}
const mutations = {
SET_TOKEN: (state, token) => {
state.token = token
},
SET_INTRODUCTION: (state, introduction) => {
state.introduction = introduction
},
@ -33,8 +31,7 @@ const mutations = {
}
// 登录(token)成功后处理
const loginSuccess = (res,username,resolve,reject,commit) => {
commit('SET_TOKEN', res.access_token)
const loginSuccess = (res,username,resolve,reject) => {
setToken(res.token_type + ' ' + res.access_token)
localStorage.setItem('isLoginTokenName',username)
@ -45,6 +42,27 @@ const loginSuccess = (res,username,resolve,reject,commit) => {
})
}
// 单点登录(token)成功后处理
const loginSuccessBySignin = (res,resolve, reject,commit) => {
let _token = res.token_type + ' ' + res.access_token
setToken(_token)
getUsersByToken(res.access_token)
.then(info=>{
if(info){
let _info = info
_info.userInfo = info.preferred_username
_info.id = info.sub
commit('SET_USERINFO', _info)
resolve(_info)
}else{
reject('用户信息获取失败')
}
})
.catch(err=>{
reject(err)
})
}
const actions = {
// 登录,需要密码
login({
@ -102,26 +120,49 @@ const actions = {
})
},
// 单点登录
loginBySignin({
commit,
}) {
return new Promise((resolve, reject) => {
mgr.signinRedirectCallback()
.then(() => {
mgr.getUser()
.then((res_token) => {
if(res_token){
loginSuccessBySignin(res_token,resolve, reject,commit)
}else{
mgr.signinRedirect(); //执行重定向
}
})
})
.catch(function(e) {
// console.log('catch')
mgr.signinRedirect(); //执行重定向
console.error("CallBack 错误信息" + e);
});
})
},
// user logout
logout({
commit,
dispatch
}) {
return new Promise((resolve, reject) => {
// todo-fast:退出登录接口好使后,打开logout
// logout().then(() => {
commit('SET_TOKEN', '')
dispatch('permission/setUserRoles',[])
dispatch('tagsView/delAllViews', null, {
root: true
}).then(()=>{
removeToken()
resetRouter()
resolve()
})
// reset visited views and cached views
// to fixed https://github.com/PanJiaChen/vue-element-admin/issues/2485
dispatch('tagsView/delAllViews', null, {
root: true
})
resolve()
// 防止路由叠加
location.reload()
// 防止路由叠加(打开后单点登录的退出无效)
// location.reload()
// }).catch(error => {
// reject(error)
// })
@ -133,7 +174,6 @@ const actions = {
commit
}) {
return new Promise(resolve => {
commit('SET_TOKEN', '')
commit('SET_ROLES', [])
localStorage.setItem('isLoginTokenName',null)
removeToken()

3
PC/InterFace.Dash/src/utils/request.js

@ -20,7 +20,8 @@ service.interceptors.request.use(
config => {
// do something before request is sent
if (store.getters.token) {
// if (store.getters.token) {
if (getToken() && getToken() != null) {
// let each request carry token
// ['X-Token'] is a custom headers key
// please modify it according to the actual situation

25
PC/InterFace.Dash/src/views/callback/index.vue

@ -0,0 +1,25 @@
<template>
<!-- callback.vue单点登录成功的回调页面 -->
<div
style="height: 100vh;"
v-loading="loading"
element-loading-text="正在加载中"
element-loading-spinner="el-icon-loading"
></div>
</template>
<script>
export default {
name:'callback',
data() {
return {
loading:true
};
},
created() {
this.$store.dispatch("user/loginBySignin").then(()=>{
this.$router.push("/");
})
}
};
</script>

7
PC/InterFace.Dash/src/views/dashboard/index.vue

@ -44,10 +44,13 @@ export default {
}
//
else{
_list.push(item.children[0])
if(item.children && item.children.length > 0)_list.push(item.children[0])
}
if(item.children)item.children = this.initData(item.children)
if(item.children && item.children.length > 0)item.children = this.initData(item.children)
});
_list = _list.filter(item=>{
return !item.hidden
})
return _list
},
goPage(item){

4
PC/InterFace.Dash/src/views/error-page/401.vue

@ -14,7 +14,7 @@
<ul class="list-unstyled">
<li>或者你可以去:</li>
<li class="link-type">
<router-link to="/dashboard">
<router-link to="/home">
回首页
</router-link>
</li>
@ -49,7 +49,7 @@ export default {
methods: {
back() {
if (this.$route.query.noGoBack) {
this.$router.push({ path: '/dashboard' })
this.$router.push({ path: '/home' })
} else {
this.$router.go(-1)
}

2
PC/InterFace.Dash/vue.config.js

@ -13,7 +13,7 @@ const name = defaultSettings.title || '接口看板-QAD&WMS' // page title
// For example, Mac: sudo npm run
// You can change the port by the following method:
// port = 9528 npm run dev OR npm run dev --port = 9528
const port = process.env.port || process.env.npm_config_port || 9528 // dev port
const port = process.env.port || process.env.npm_config_port || 60066 // dev port
const Timestamp = new Date().getTime();
// All configuration item explanations can be find in https://cli.vuejs.org/config/
module.exports = {

Loading…
Cancel
Save