From 86457cbb212057aa5fc7303efdb6c24c6764e063 Mon Sep 17 00:00:00 2001
From: yujialong <479214531@qq.com>
Date: Tue, 15 Oct 2024 17:38:36 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9D=83=E9=99=90=E6=8E=A7?=
=?UTF-8?q?=E5=88=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/index.js | 1 +
src/layouts/navbar/index.vue | 35 ++++++++++++-----------
src/libs/auth/generateBtnPermission.js | 7 +++--
src/libs/route/addRoutes.js | 25 ++++++++--------
src/pages/allocationReview/list/index.vue | 8 +++---
src/plugins/auth/index.js | 8 ++----
src/setting.js | 2 +-
7 files changed, 44 insertions(+), 42 deletions(-)
diff --git a/src/api/index.js b/src/api/index.js
index ea47dd7..784f9f7 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -2,6 +2,7 @@ import Setting from '@/setting'
const { apiBaseURL: host } = Setting
export default {
+ getUserRolesPermissionMenu: `/users/users/user-role/getUserRolesPermissionMenu`,
getCurrentTime: `/competition/competition/management/getCurrentTime`,
encrypt: `/nakadai/data/encrypt`,
diff --git a/src/layouts/navbar/index.vue b/src/layouts/navbar/index.vue
index 17a21d1..c2a6245 100644
--- a/src/layouts/navbar/index.vue
+++ b/src/layouts/navbar/index.vue
@@ -36,6 +36,7 @@
diff --git a/src/libs/auth/generateBtnPermission.js b/src/libs/auth/generateBtnPermission.js
index c150418..3004833 100644
--- a/src/libs/auth/generateBtnPermission.js
+++ b/src/libs/auth/generateBtnPermission.js
@@ -6,15 +6,16 @@ import store from '@/store'
const result = []
// 递归组合权限
-function createAuth(data, auth) {
+function createAuth (data, auth) {
data.map(e => {
- const text = (auth ? auth + ':' : '') + (auth ? e.name : e.url) // 第一级是路由,取path,子级取name
+ const text = (auth ? auth + ':' : '') + (auth ? e.name : e.name) // 第一级是路由,取path,子级取name
result.push(text)
e.children && e.children.length && createAuth(e.children, text)
})
}
-export default function(data) {
+export default function (data) {
+ console.log("🚀 ~ data:", data)
createAuth(data)
store.commit('auth/addBtnAuth', result)
}
diff --git a/src/libs/route/addRoutes.js b/src/libs/route/addRoutes.js
index 74ee332..da1f5af 100644
--- a/src/libs/route/addRoutes.js
+++ b/src/libs/route/addRoutes.js
@@ -1,28 +1,29 @@
-import store from '@/store'
-import generateBtnPermission from '../auth/generateBtnPermission'
+import store from '@/store';
+import generateBtnPermission from '../auth/generateBtnPermission';
const newRoutes = []
-function createMeta(item) {
+function createMeta (item) {
let meta = { title: item.name }
return meta
}
-function createRoute(data) {
+function createRoute (data) {
data.map(e => {
- const { url } = e
- // 有path则添加到路由里
- url && newRoutes.push({
- path: url,
- meta: createMeta(e)
- })
+ if (e.path) {
+ let meta = createMeta(e)
+ newRoutes.push({
+ path: e.path,
+ meta
+ })
+ }
// 递归生成路由集合
e.children && e.children.length && createRoute(e.children)
})
}
-export default function(data, path) {
+export default function (data, path) {
generateBtnPermission(data)
// createRoute(data)
- // store.commit('auth/addRoutes', newRoutes)
+ // store.commit('addRoutes', newRoutes)
}
\ No newline at end of file
diff --git a/src/pages/allocationReview/list/index.vue b/src/pages/allocationReview/list/index.vue
index 46fcc5a..1e8292a 100644
--- a/src/pages/allocationReview/list/index.vue
+++ b/src/pages/allocationReview/list/index.vue
@@ -56,11 +56,11 @@
- 评阅进度
- 修改评阅设置
- 任务分配
+ 评阅进度
+ 修改评阅设置
+ 任务分配
- 评阅设置
+ 评阅设置
diff --git a/src/plugins/auth/index.js b/src/plugins/auth/index.js
index d18c1da..205abc3 100644
--- a/src/plugins/auth/index.js
+++ b/src/plugins/auth/index.js
@@ -7,11 +7,9 @@ import store from '@/store'
import Setting from '@/setting'
export default {
- inserted(el, binding, vnode) {
- if (!Setting.dynamicRoute) return false
- const val = binding.value
- // 如果有传值,判断是否有/,有就说说明传的是完整的值,否则就拿路由拼接传的值;如果没传值,就取按钮名字
- const text = val && val.includes('/') ? val : vnode.context.$route.path + ':' + (val || el.innerText)
+ inserted (el, binding, vnode) {
+ if (!Setting.dynamicRoute) return false
+ const text = binding.value
const { btns } = store.state.auth
if (text && btns && btns.length) {
// 如果按钮集合里没有该权限,就把该按钮给去除
diff --git a/src/setting.js b/src/setting.js
index d8f2899..5a61287 100644
--- a/src/setting.js
+++ b/src/setting.js
@@ -55,7 +55,7 @@ const Setting = {
// 相同路由,不同参数间进行切换,是否强力更新
sameRouteForceUpdate: false,
// 是否使用动态路由(即角色权限,开启了的话就会取后端返回的权限树来显示头部导肮和页面按钮)
- dynamicRoute: false
+ dynamicRoute: true
};
export default Setting;