dev_2022-06-14
yujialong 2 years ago
parent ba933acf76
commit cc375077da
  1. 10
      src/libs/route/addRoutes.js
  2. 26
      src/libs/route/generateRoutes.js
  3. 8
      src/pages/account/login/index.vue
  4. 7
      src/pages/account/redirect/index.vue
  5. 1
      src/pages/match/list/index.vue
  6. 30
      src/plugins/auth/index.js
  7. 2
      src/setting.js

@ -11,15 +11,13 @@ function createMeta(item) {
function createRoute(data) {
data.map(e => {
const { path } = e
if (path) {
let meta = createMeta(e)
newRoutes.push({
// 有path则添加到路由里
path && newRoutes.push({
path,
meta
meta: createMeta(e)
})
}
// 递归生成路由集合
e.children && e.children.length && createRoute(e.children);
e.children && e.children.length && createRoute(e.children)
})
}

@ -1,26 +0,0 @@
import store from "@/store";
import router from "@/router";
export default function() {
setTimeout(() => {
let routes = store.state.auth.routes;
routes.forEach(e => {
if (e.path == "/") {
e.component = () => import("@/layouts/home/index.vue");
} else {
e.component = () => import(`@/pages/${e.path}.vue`);
}
e.children && e.children.forEach(n => {
n.path && (n.component = () => import(`@/pages/${n.path}.vue`));
});
});
routes.push({
path: "*",
redirect: "404"
});
router.addRoutes(routes);
}, 500);
}

@ -157,8 +157,12 @@ export default {
util.successMsg("登录成功");
this.setCustomer(res.customer);
res.customerName && this.setCustomerName(res.customerName);
// let redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : "/index";
this.$router.replace('/station');
const path = '/station/list' //
this.$get(`${this.api.getUserRolesPermissionMenu}?platformId=${Setting.platformId}`).then(res => {
const list = res.permissionMenu[0].children
this.$router.push(list.find(e => e.path === path) ? path : list[0].path)
}).catch(err => {})
}).catch(res => {});
},
phoneCountdown() {

@ -37,7 +37,12 @@ export default {
util.successMsg('登录成功')
this.setCustomer(res.customer)
this.setCustomerName(res.customerName)
this.$router.replace('/index')
const path = '/station/list' //
this.$get(`${this.api.getUserRolesPermissionMenu}?platformId=${Setting.platformId}`).then(res => {
const list = res.permissionMenu[0].children
this.$router.push(list.find(e => e.path === path) ? path : list[0].path)
}).catch(err => {})
}).catch(res => {})
}
}

@ -70,7 +70,6 @@
<el-table-column label="操作" align="center" width="170">
<template slot-scope="scope">
<el-button v-auth type="text" @click="manage(scope.row)">管理</el-button>
<el-divider v-auth="'管理'" direction="vertical"></el-divider>
<el-button v-auth type="text" @click="delData(scope.row)">删除</el-button>
<!-- 列表展示中台的禁启用依据zt_open展示职站的禁启用依据is_open展示 -->
<!-- 中台禁用了这个学校发布的学校这边还能看到但是学校这边不能启用 -->

@ -1,29 +1,21 @@
/**
* @description 鉴权指令
* 当传入的权限当前用户没有时会移除该组件
* 用例<Tag v-auth>text</Tag> <Tag v-auth="'user:'">text</Tag>
* 用例<Tag v-auth>text</Tag> <Tag v-auth="''">text</Tag>
* */
import store from "@/store";
import store from '@/store'
export default {
inserted(el, binding, vnode) {
let btnText = "";
// 如果有传值,就取传的值,否则,就取页面路由和按钮名字拼接起来
const route = vnode.context.$route.path
if (binding.value) {
btnText = route + ':' + binding.value
} else {
btnText = route + ':' + el.innerText
}
const btnPermissions = store.state.auth.btns;
if (btnText && btnPermissions && btnPermissions.length) {
const isPermission = btnPermissions.includes(btnText);
const val = binding.value
// 如果有传值,就取传的值,否则,就取按钮名字
const text = vnode.context.$route.path + ':' + (val || el.innerText)
const { btns } = store.state.auth
if (text && btns && btns.length) {
// 如果按钮集合里没有该权限,就把该按钮给去除
if (!isPermission) {
el.parentNode && el.parentNode.removeChild(el);
if (!btns.includes(text)) {
el.parentNode && el.parentNode.removeChild(el)
}
}
}
}
},
};

@ -51,7 +51,7 @@ const Setting = {
/**
* 路由白名单
* */
whiteList: ['/login'],
whiteList: ['/login', '/redirect'],
/**
* localStorage里保存的token的key
*/

Loading…
Cancel
Save