解决权限问题

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

View File

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

View File

@ -169,8 +169,6 @@ export default defineComponent({
font-size: 16px; font-size: 16px;
letter-spacing: 1px; letter-spacing: 1px;
margin-bottom: 50px; 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 { .el-form {
@ -178,6 +176,7 @@ export default defineComponent({
:deep(.el-form-item) { :deep(.el-form-item) {
margin-bottom: 20px; margin-bottom: 20px;
border-bottom: 1px solid #eee;
.el-form-item__label { .el-form-item__label {
color: #ccc; color: #ccc;
@ -188,7 +187,6 @@ export default defineComponent({
background-color: transparent; background-color: transparent;
color: #fff; color: #fff;
border: 0; border: 0;
border-bottom: 1px solid #eee;
height: 40px; height: 40px;
width: calc(100% - 4px); width: calc(100% - 4px);
margin: 0 2px; margin: 0 2px;

View File

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

View File

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

View File

@ -366,9 +366,10 @@ const Upsert = useUpsert({
}); });
}, },
async onOpen() { async onOpen(isEdit) {
const list = await service.base.sys.role.list(); const list = await service.base.sys.role.list();
//
Upsert.value?.setOptions( Upsert.value?.setOptions(
"roleIdList", "roleIdList",
list.map((e: any) => { 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" "@babel/helper-validator-identifier" "^7.16.7"
to-fast-properties "^2.0.0" to-fast-properties "^2.0.0"
"@cool-vue/crud@^5.0.0": "@cool-vue/crud@^5.0.5":
version "5.0.0" version "5.0.5"
resolved "https://registry.npmjs.org/@cool-vue/crud/-/crud-5.0.0.tgz#efe8482ba481b7717e58c5495fae61a1aae924da" resolved "https://registry.npmjs.org/@cool-vue/crud/-/crud-5.0.5.tgz#35753ad6e2ba8d279415042a2b8421ccd4d98f2a"
integrity sha512-QejFHic2qY4D403Mn0UzHkCII6MNR+Rt7n/aynEbJURYBAwj1zTIhnZx5deNDnr0CCW0F8eyLmqg5WYw3v/FUg== integrity sha512-Km5yPAX1Klucm+APEMdSfeZ7/D4fqBSFJi/n3+FH16mftkHQyS9UK2E17t1TIfNlzWmGBFCKfTHPAvALYfhPpw==
dependencies: dependencies:
array.prototype.flat "^1.2.4" array.prototype.flat "^1.2.4"
core-js "^3.21.1" core-js "^3.21.1"