diff --git a/package.json b/package.json index 9cf8c64..bdc6feb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "front-next", - "version": "5.2.4", + "version": "5.3.0", "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.7", + "@cool-vue/crud": "^5.0.10", "@element-plus/icons-vue": "^1.1.3", "@vueuse/core": "^8.2.5", "axios": "^0.27.2", diff --git a/src/cool/config/index.ts b/src/cool/config/index.ts index a4f4b0a..6ccdbf0 100644 --- a/src/cool/config/index.ts +++ b/src/cool/config/index.ts @@ -12,6 +12,9 @@ export const config = { // 菜单 menu: { + // 是否分组显示 + isGroup: false, + // 自定义菜单列表 list: [] }, @@ -25,16 +28,6 @@ export const config = { views: [] }, - // 主题 - theme: { - // 主色 - color: "", - // 样式地址 - url: "", - // 显示一级菜单 - showAMenu: false - }, - // 字体图标库 iconfont: [] }, diff --git a/src/modules/base/common/theme.ts b/src/modules/base/common/theme.ts index 756651c..c438353 100644 --- a/src/modules/base/common/theme.ts +++ b/src/modules/base/common/theme.ts @@ -2,17 +2,6 @@ import { config } from "/@/cool"; import { basename } from "/@/cool/utils"; import { createLink } from "../utils"; -// 主题初始化 -if (config.app.theme) { - const { url, color } = config.app.theme; - - if (url) { - createLink(url, "theme-style"); - } - - document.getElementsByTagName("body")[0].style.setProperty("--color-primary", color); -} - // 字体图标库加载 if (config.app.iconfont) { config.app.iconfont.forEach((e: string) => { diff --git a/src/modules/base/pages/layout/components/amenu.vue b/src/modules/base/pages/layout/components/amenu.vue new file mode 100644 index 0000000..ba1853b --- /dev/null +++ b/src/modules/base/pages/layout/components/amenu.vue @@ -0,0 +1,114 @@ + + + + + diff --git a/src/modules/base/pages/layout/components/process.vue b/src/modules/base/pages/layout/components/process.vue index 46d9e7c..e91d02f 100644 --- a/src/modules/base/pages/layout/components/process.vue +++ b/src/modules/base/pages/layout/components/process.vue @@ -135,8 +135,9 @@ watch( height: 30px; padding: 0 10px; border-radius: 3px; - cursor: pointer; margin-right: 10px; + font-size: 12px; + cursor: pointer; &:hover { background-color: #eee; diff --git a/src/modules/base/pages/layout/components/route-nav.vue b/src/modules/base/pages/layout/components/route-nav.vue index 0147ef6..d949ec2 100644 --- a/src/modules/base/pages/layout/components/route-nav.vue +++ b/src/modules/base/pages/layout/components/route-nav.vue @@ -64,7 +64,8 @@ export default defineComponent({ } }, { - immediate: true + immediate: true, + deep: true } ); diff --git a/src/modules/base/pages/layout/components/topbar.vue b/src/modules/base/pages/layout/components/topbar.vue index 07f19ba..3941c83 100644 --- a/src/modules/base/pages/layout/components/topbar.vue +++ b/src/modules/base/pages/layout/components/topbar.vue @@ -1,4 +1,6 @@ @@ -39,6 +45,7 @@ import { module } from "/@/cool/utils"; import store from "store"; import { Check } from "@element-plus/icons-vue"; import { ElMessage } from "element-plus"; +import { useBase } from "/$/base"; export default defineComponent({ name: "cl-theme", @@ -48,9 +55,16 @@ export default defineComponent({ }, setup() { + const { app, menu } = useBase(); + // 当前主题 const theme = reactive(store.get("theme") || module.get("theme")); + // 菜单分组显示默认值 + if (theme.isGroup === undefined) { + theme.isGroup = app.info.menu.isGroup; + } + // 表单 const form = reactive({ color: theme.color || "", @@ -60,29 +74,46 @@ export default defineComponent({ // 抽屉 const visible = ref(false); + // 打开 function open() { visible.value = true; } + // 设置颜色 function setColor(color: string) { setTheme({ color }); } + // 设置推荐 function setComd(item: any) { - form.theme = item; + Object.assign(form.theme, item); form.color = item.color; setTheme(item); ElMessage.success(`切换主题:${item.label}`); } + // 设置分组 + function setGroup(val: boolean) { + setTheme({ isGroup: val }); + app.set({ + menu: { + isGroup: val + } + }); + menu.setMenu(); + } + return { + app, form, themes, theme, visible, open, setColor, - setComd + setComd, + setTheme, + setGroup }; } }); @@ -129,5 +160,14 @@ export default defineComponent({ } } } + + &__drawer { + :deep(.el-form-item) { + background-color: #f7f7f7; + padding: 10px; + border-radius: 5px; + border: 1px solid #eee; + } + } } diff --git a/src/modules/theme/config.ts b/src/modules/theme/config.ts index 6b9fb03..ba2e7fd 100644 --- a/src/modules/theme/config.ts +++ b/src/modules/theme/config.ts @@ -2,5 +2,5 @@ export default { // 推荐主题:'jihei', 'guolv', 'jiangzi' name: "default" // 自定义主题色 - // color: "#4165d7" + // color: "#4165d7", }; diff --git a/src/modules/theme/index.ts b/src/modules/theme/index.ts index 29bcb84..7abb176 100644 --- a/src/modules/theme/index.ts +++ b/src/modules/theme/index.ts @@ -1,6 +1,7 @@ import store from "store"; import { App } from "vue"; import { setTheme } from "./utils"; +import { config } from "/@/cool/config"; import "./static/css/index.scss"; export default { @@ -8,6 +9,10 @@ export default { const theme = store.get("theme") || options; if (theme) { + if (theme.isGroup !== undefined) { + config.app.menu.isGroup = theme.isGroup; + } + setTheme(theme); } } diff --git a/src/modules/theme/static/css/index.scss b/src/modules/theme/static/css/index.scss index ea18795..5e5e0ea 100644 --- a/src/modules/theme/static/css/index.scss +++ b/src/modules/theme/static/css/index.scss @@ -3,6 +3,12 @@ .page-layout { background-color: rgba(47, 52, 71, 0.9); + .a-menu { + .el-menu-item { + border-radius: 5px !important; + } + } + .app-topbar { background-color: transparent; color: #fff; diff --git a/src/modules/theme/utils/index.ts b/src/modules/theme/utils/index.ts index 9a6a038..5dd9550 100644 --- a/src/modules/theme/utils/index.ts +++ b/src/modules/theme/utils/index.ts @@ -43,9 +43,10 @@ export const themes = [ declare interface Options { color?: string; name?: string; + isGroup?: boolean; } -export function setTheme({ color, name }: Options) { +export function setTheme({ color, name, isGroup }: Options) { // 主题配置 const theme = store.get("theme") || {}; @@ -69,6 +70,8 @@ export function setTheme({ color, name }: Options) { color = item.color; document.querySelector("#app")?.setAttribute("class", `theme-${name}`); } + + theme.name = name; } // 设置主色 @@ -81,11 +84,14 @@ export function setTheme({ color, name }: Options) { el.style.setProperty(`${pre}-light-${i}`, mix(color, mixWhite, i * 0.1)); el.style.setProperty(`${pre}-dark-${i}`, mix(color, mixBlack, i * 0.1)); } + + theme.color = color; } - // 缓存 - theme.name = name; - theme.color = color; + // 菜单分组显示 + if (isGroup !== undefined) { + theme.isGroup = isGroup; + } store.set("theme", theme); } diff --git a/yarn.lock b/yarn.lock index c253182..a70a6f8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -984,10 +984,10 @@ "@babel/helper-validator-identifier" "^7.16.7" to-fast-properties "^2.0.0" -"@cool-vue/crud@^5.0.7": - version "5.0.7" - resolved "https://registry.npmjs.org/@cool-vue/crud/-/crud-5.0.7.tgz#60459f3e58b04a08c621aa41e25c03618645bd6b" - integrity sha512-/I4f6KFpPHiJE86w2pHAwu2Gn2WAd2LCFn6Bc3jzgg6RdYlAeIyRB9Ph8KasE7CCjyPdb2kyDYEQsZhOfODy9g== +"@cool-vue/crud@^5.0.10": + version "5.0.10" + resolved "https://registry.npmjs.org/@cool-vue/crud/-/crud-5.0.10.tgz#c2d70504fccdf89c907e1d32e62a93dd777fba9c" + integrity sha512-a3jZPS+Y/+7IJTA3iYjD7PK83rwtIDrnE0tcf5LfenZ7JnnlXs+QFMRybGypJfoeswsG97JmWFeSY6o/JyALDw== dependencies: array.prototype.flat "^1.2.4" core-js "^3.21.1"