From dbc284bf8b6dcce3e1eeeb9f2fd3786106555682 Mon Sep 17 00:00:00 2001 From: Gary Fu Date: Sun, 24 Dec 2023 17:50:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E6=A0=87=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/main.css | 13 +++++ src/components/common-icon/index.vue | 16 ++++-- src/icons/index.js | 29 +++++++++- src/messages/menu_cn.js | 2 + src/messages/menu_en.js | 2 + src/route/routes.js | 4 ++ src/services/global/GlobalService.js | 17 +++--- src/views/Icons.vue | 80 ++++++++++++++++++++++++++++ 8 files changed, 148 insertions(+), 15 deletions(-) create mode 100644 src/views/Icons.vue diff --git a/src/assets/main.css b/src/assets/main.css index 1ba3c00..fcce602 100644 --- a/src/assets/main.css +++ b/src/assets/main.css @@ -35,6 +35,19 @@ html, body, #app, .index-container { .padding-right2 { padding-right: 10px; } + +.padding-top1 { + padding-top: 5px; +} +.padding-top2 { + padding-top: 10px; +} +.padding-bottom1 { + padding-bottom: 5px; +} +.padding-bottom2 { + padding-bottom: 10px; +} .text-center { text-align: center; } diff --git a/src/components/common-icon/index.vue b/src/components/common-icon/index.vue index e1188c5..e51ca97 100644 --- a/src/components/common-icon/index.vue +++ b/src/components/common-icon/index.vue @@ -1,19 +1,29 @@ diff --git a/src/icons/index.js b/src/icons/index.js index 877290c..06bd7f5 100644 --- a/src/icons/index.js +++ b/src/icons/index.js @@ -1,12 +1,37 @@ import * as ElementPlusIconsVue from '@element-plus/icons-vue' import * as MaterialIconsVue from '@vicons/material' +import kebabCase from 'lodash/kebabCase' + +export const INSTALL_ICONS = [] +export const ICON_PREFIX = 'icon-' +/** + * icon组件注册工具,默认增加icon-前缀,如果重复,再增加前缀 + * @param app {import('vue').App} Vue实例 + * @param key {string}图标名称 + * @param component {import('vue').Component}组件 + * @param prefix 如果已经注册,增加前缀防止覆盖 + */ +const registryIconComponent = (app, key, component, prefix) => { + let componentName = `${ICON_PREFIX}${kebabCase(key)}` // 组件名字 + if (app.component(componentName)) { + key = `${prefix}${key}` + componentName = `${ICON_PREFIX}${kebabCase(key)}` + } + INSTALL_ICONS.push(key) + app.component(componentName, component) +} + export default { + /** + * 注册图标 + * @param app {import('vue').App} + */ install (app) { for (const [key, component] of Object.entries(ElementPlusIconsVue)) { - app.component(key, component) + registryIconComponent(app, key, component, 'El') } for (const [key, component] of Object.entries(MaterialIconsVue)) { - app.component(key, component) + registryIconComponent(app, key, component, 'Md') } } } diff --git a/src/messages/menu_cn.js b/src/messages/menu_cn.js index bbf2a0d..bb9c45d 100644 --- a/src/messages/menu_cn.js +++ b/src/messages/menu_cn.js @@ -6,6 +6,8 @@ menu.label.userManagement = '用户管理' menu.label.roleManagement = '角色管理' menu.label.authorityManagement = '权限管理' menu.label.menuManagement = '菜单管理' +menu.label.toolsManagement = '工具管理' +menu.label.toolsIcons = '图标管理' menu.label.errorPage = '错误页面' menu.label.errorPage404 = '找不到页面' menu.label.errorPage403 = '没有权限' diff --git a/src/messages/menu_en.js b/src/messages/menu_en.js index e5c4c4e..e7a10f3 100644 --- a/src/messages/menu_en.js +++ b/src/messages/menu_en.js @@ -6,6 +6,8 @@ menu.label.userManagement = 'User Management' menu.label.roleManagement = 'Role Management' menu.label.authorityManagement = 'Authority Management' menu.label.menuManagement = 'Menu Management' +menu.label.toolsManagement = 'Tools' +menu.label.toolsIcons = 'Icons' menu.label.errorPage = 'Error Page' menu.label.errorPage404 = 'Not Found' menu.label.errorPage403 = 'Access Denied' diff --git a/src/route/routes.js b/src/route/routes.js index f361965..182a54c 100644 --- a/src/route/routes.js +++ b/src/route/routes.js @@ -17,6 +17,10 @@ const router = createRouter({ path: 'personal', name: 'personal', component: () => import('@/views/account/PersonalInfo.vue') + }, { + path: 'icons', + name: 'icons', + component: () => import('@/views/Icons.vue') }, { path: '/:pathMatch(.*)*', diff --git a/src/services/global/GlobalService.js b/src/services/global/GlobalService.js index d5ae6d0..f3fda19 100644 --- a/src/services/global/GlobalService.js +++ b/src/services/global/GlobalService.js @@ -38,7 +38,7 @@ export const useBaseTopMenus = () => { click: () => globalConfigStore.changeTheme(!globalConfigStore.isDarkTheme) }, { - icon: 'DisplaySettingsRound', + icon: 'AutoAwesomeMosaicFilled', index: 'layout', isDropdown: true, children: [ @@ -109,21 +109,18 @@ export const useBusinessMenus = () => { ] }, { - icon: 'WarningFilled', - labelKey: 'menu.label.errorPage', + icon: 'BuildRound', + labelKey: 'menu.label.toolsManagement', children: [ { index: '/not-found', - icon: 'Warning', + icon: 'WarningFilled', labelKey: 'menu.label.errorPage404' }, { - icon: 'Warning', - labelKey: 'menu.label.errorPage403' - }, - { - icon: 'Warning', - labelKey: 'menu.label.errorPage500' + index: '/icons', + icon: 'InsertEmoticonOutlined', + labelKey: 'menu.label.toolsIcons' } ] }]) diff --git a/src/views/Icons.vue b/src/views/Icons.vue new file mode 100644 index 0000000..96bfb70 --- /dev/null +++ b/src/views/Icons.vue @@ -0,0 +1,80 @@ + + + + +