解决权限问题

This commit is contained in:
icssoa 2022-04-07 17:37:09 +08:00
parent 1967e8a53d
commit f6741e3de6
7 changed files with 33 additions and 22 deletions

View File

@ -1,6 +1,6 @@
{
"name": "front-next",
"version": "5.0.1",
"version": "5.0.2",
"scripts": {
"dev": "vite --host",
"build": "vite build",
@ -9,7 +9,7 @@
"lint:eslint": "eslint \"{src,mock}/**/*.{vue,ts,tsx}\" --fix"
},
"dependencies": {
"@cool-vue/crud": "^5.0.1",
"@cool-vue/crud": "^5.0.5",
"@element-plus/icons-vue": "^1.1.3",
"axios": "^0.26.1",
"clipboard": "^2.0.10",

View File

@ -5,7 +5,7 @@
<template v-if="user.token || isLogout">
<div class="router">
<el-select v-model="url" size="medium" filterable>
<el-select v-model="url" filterable>
<el-option v-for="(item, index) in menu.routes" :key="index" :value="item.path">
<span style="float: left">{{ item.name }}</span>
<span style="float: right">{{ item.path }}</span>

View File

@ -169,8 +169,6 @@ export default defineComponent({
font-size: 16px;
letter-spacing: 1px;
margin-bottom: 50px;
transform: skewX(-15deg);
-webkit-box-reflect: below 0 -webkit-linear-gradient(transparent, transparent 40%, rgba(255, 255, 255, 0.4));
}
.el-form {
@ -178,6 +176,7 @@ export default defineComponent({
:deep(.el-form-item) {
margin-bottom: 20px;
border-bottom: 1px solid #eee;
.el-form-item__label {
color: #ccc;
@ -188,7 +187,6 @@ export default defineComponent({
background-color: transparent;
color: #fff;
border: 0;
border-bottom: 1px solid #eee;
height: 40px;
width: calc(100% - 4px);
margin: 0 2px;

View File

@ -5,6 +5,7 @@ import { deepTree, isArray, isEmpty, isObject, revDeepTree, storage } from "/@/c
import { app } from "/@/cool/config";
import { addViews, service } from "/@/cool";
import { revisePath } from "../utils";
import { orderBy } from "lodash";
declare enum Type {
"目录" = 0,
@ -75,7 +76,9 @@ export const useMenuStore = defineStore("menu", function () {
for (const i in d.permission) {
d._permission[i] =
list.findIndex((e: any) =>
e.replace(/:/g, "/").includes(`${d.namespace}/${i}`)
e
.replace(/:/g, "/")
.includes(`${d.namespace.replace("admin/", "")}/${i}`)
) >= 0;
}
} else {
@ -102,8 +105,8 @@ export const useMenuStore = defineStore("menu", function () {
// 设置菜单组
function setGroup(list: Item[]) {
group.value = list;
storage.set("menu.group", list);
group.value = orderBy(list, "orderNum");
storage.set("menu.group", group.value);
}
// 获取菜单,权限信息
@ -154,8 +157,7 @@ export const useMenuStore = defineStore("menu", function () {
resolve(group.value);
}
// 自定义菜单
if (isEmpty(app.menuList)) {
if (isEmpty(app.menu.list)) {
service.base.comm
.permmenu()
.then((res) => {
@ -166,8 +168,9 @@ export const useMenuStore = defineStore("menu", function () {
reject(err);
});
} else {
// 自定义菜单
next({
menus: revDeepTree([])
menus: revDeepTree(app.menu.list)
});
}
});

View File

@ -23,7 +23,7 @@
</ul>
</div>
<div class="dept-tree__container" @contextmenu.stop.prevent="openCM">
<div class="dept-tree__container" @contextmenu.stop.prevent="onContextMenu">
<el-tree
v-loading="loading"
node-key="id"
@ -37,7 +37,7 @@
:allow-drag="allowDrag"
:allow-drop="allowDrop"
:expand-on-click-node="false"
@node-contextmenu="openCM"
@node-contextmenu="onContextMenu"
>
<template #default="{ node, data }">
<div class="dept-tree__node">
@ -47,7 +47,7 @@
<span
v-if="app.browser.isMini"
class="dept-tree__node-icon"
@click="openCM($event, data, node)"
@click="onContextMenu($event, data, node)"
>
<el-icon><more-filled /></el-icon>
</span>
@ -288,7 +288,7 @@ export default defineComponent({
}
//
function openCM(e: any, d?: any, n?: any) {
function onContextMenu(e: any, d?: any, n?: any) {
if (!d) {
d = list.value[0] || {};
}
@ -346,7 +346,7 @@ export default defineComponent({
list,
loading,
isDrag,
openCM,
onContextMenu,
allowDrag,
allowDrop,
refresh,

View File

@ -366,9 +366,10 @@ const Upsert = useUpsert({
});
},
async onOpen() {
async onOpen(isEdit) {
const list = await service.base.sys.role.list();
//
Upsert.value?.setOptions(
"roleIdList",
list.map((e: any) => {
@ -378,6 +379,15 @@ const Upsert = useUpsert({
};
})
);
//
if (isEdit) {
Upsert.value?.setData("password", {
rules: {
required: false
}
});
}
}
});

View File

@ -978,10 +978,10 @@
"@babel/helper-validator-identifier" "^7.16.7"
to-fast-properties "^2.0.0"
"@cool-vue/crud@^5.0.0":
version "5.0.0"
resolved "https://registry.npmjs.org/@cool-vue/crud/-/crud-5.0.0.tgz#efe8482ba481b7717e58c5495fae61a1aae924da"
integrity sha512-QejFHic2qY4D403Mn0UzHkCII6MNR+Rt7n/aynEbJURYBAwj1zTIhnZx5deNDnr0CCW0F8eyLmqg5WYw3v/FUg==
"@cool-vue/crud@^5.0.5":
version "5.0.5"
resolved "https://registry.npmjs.org/@cool-vue/crud/-/crud-5.0.5.tgz#35753ad6e2ba8d279415042a2b8421ccd4d98f2a"
integrity sha512-Km5yPAX1Klucm+APEMdSfeZ7/D4fqBSFJi/n3+FH16mftkHQyS9UK2E17t1TIfNlzWmGBFCKfTHPAvALYfhPpw==
dependencies:
array.prototype.flat "^1.2.4"
core-js "^3.21.1"