优化菜单

This commit is contained in:
神仙都没用 2023-11-23 21:54:00 +08:00
parent 833ea0c18c
commit 2327e1527f
7 changed files with 34 additions and 8 deletions

View File

@ -2,7 +2,7 @@ import { createDir, error, firstUpperCase, readFile, toCamel } from "../utils";
import { join } from "path"; import { join } from "path";
import { Entity, DistPath } from "./config"; import { Entity, DistPath } from "./config";
import axios from "axios"; import axios from "axios";
import { isArray, isEmpty, last, merge } from "lodash"; import { isArray, isEmpty, last, merge, unionBy } from "lodash";
import { createWriteStream } from "fs"; import { createWriteStream } from "fs";
import prettier from "prettier"; import prettier from "prettier";
import { proxy } from "../../../src/config/proxy"; import { proxy } from "../../../src/config/proxy";
@ -61,6 +61,8 @@ async function getData(temps?: Eps.Entity[]) {
} }
}); });
} }
list = unionBy(list, "prefix");
} }
// 创建 json 文件 // 创建 json 文件
@ -107,6 +109,7 @@ async function createDescribe({ list, service }: { list: Eps.Entity[]; service:
for (const item of list) { for (const item of list) {
if (!item.name) continue; if (!item.name) continue;
const t = [`interface ${item.name} {`]; const t = [`interface ${item.name} {`];
for (const col of item.columns || []) { for (const col of item.columns || []) {
// 描述 // 描述
t.push("\n"); t.push("\n");

View File

@ -9,7 +9,7 @@
"lint:eslint": "eslint \"{src}/**/*.{vue,ts,tsx}\" --fix" "lint:eslint": "eslint \"{src}/**/*.{vue,ts,tsx}\" --fix"
}, },
"dependencies": { "dependencies": {
"@cool-vue/crud": "^7.0.3", "@cool-vue/crud": "^7.0.4",
"@element-plus/icons-vue": "^2.1.0", "@element-plus/icons-vue": "^2.1.0",
"@vueuse/core": "^10.4.0", "@vueuse/core": "^10.4.0",
"@wangeditor/editor": "^5.1.23", "@wangeditor/editor": "^5.1.23",

View File

@ -73,6 +73,11 @@ export default defineComponent({
} }
} }
// 点击事件, 阻止冒泡
function onClick(event: MouseEvent) {
event.stopPropagation();
}
return () => { return () => {
return ( return (
<el-switch <el-switch
@ -80,6 +85,7 @@ export default defineComponent({
active-value={props.activeValue} active-value={props.activeValue}
inactive-value={props.inactiveValue} inactive-value={props.inactiveValue}
onChange={onChange} onChange={onChange}
onClick={onClick}
/> />
); );
}; };

View File

@ -264,7 +264,11 @@ const Upsert = useUpsert({
{ {
prop: "parentId", prop: "parentId",
label: "上级节点", label: "上级节点",
hook: "empty", hook: {
submit(value) {
return value === "" ? null : value;
}
},
component: { component: {
name: "slot-parentId" name: "slot-parentId"
} }

View File

@ -85,6 +85,16 @@ function open() {
props: { props: {
placeholder: "请输入菜单路由,如:/test" placeholder: "请输入菜单路由,如:/test"
} }
},
rules: {
required: true,
validator(_, value, callback) {
if (!(value || "").startsWith("/")) {
callback(new Error("必须以 / 开头"));
} else {
callback();
}
}
} }
}, },
{ {

View File

@ -198,7 +198,10 @@ export function useMenu() {
function create(data: EpsModule): Promise<() => void> { function create(data: EpsModule): Promise<() => void> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// 视图文件路径 // 视图文件路径
data.viewPath = `modules/${data.module}/views/${last(data.router?.split("/"))}.vue`; data.viewPath = `modules/${data.module}/views${data.router?.replace(
`/${data.module}`,
""
)}.vue`;
// 添加菜单 // 添加菜单
service.base.sys.menu service.base.sys.menu

View File

@ -295,10 +295,10 @@
mitt "^3.0.1" mitt "^3.0.1"
vue "^3.3.4" vue "^3.3.4"
"@cool-vue/crud@^7.0.3": "@cool-vue/crud@^7.0.4":
version "7.0.3" version "7.0.4"
resolved "https://registry.yarnpkg.com/@cool-vue/crud/-/crud-7.0.3.tgz#a6e03ac5bcd22690fae3f61549fe9ff744291a1b" resolved "https://registry.yarnpkg.com/@cool-vue/crud/-/crud-7.0.4.tgz#4f7a33e8ded0930b967325907fbd507404cf6447"
integrity sha512-DyzIZGHL8CxY/Mr8SGfBQgLpl1SLxY6COBKR5khoXqhUQ5XqHKIbjYz5h2UwZh9GfY+nswYaW4vCbKumKiS8KQ== integrity sha512-qS2PvqhXOiJ0Grq8uvYkjDdA6JgpjSO2ODbl+9/XPERCah3ptDLo/dGn5ChlYD2z53T5/Vhch6IQPiXbOjfsOg==
dependencies: dependencies:
"@cool-vue/crud" "^7.0.1-beta14" "@cool-vue/crud" "^7.0.1-beta14"
array.prototype.flat "^1.2.4" array.prototype.flat "^1.2.4"