From a65ad9edd56994ae79b91288e36c8306e2c23057 Mon Sep 17 00:00:00 2001 From: vben Date: Tue, 15 Dec 2020 00:13:23 +0800 Subject: [PATCH] wip(menu): perf menu --- CHANGELOG.zh_CN.md | 6 +- src/components/Application/index.ts | 4 +- .../Application/src/AppLocalePicker.vue | 11 +- src/components/Application/src/AppLogo.vue | 2 +- .../Application/src/AppProvider.vue | 15 +- .../Application/src/search/AppSearch.vue | 2 +- .../Application/src/useAppContext.ts | 2 + src/components/Icon/index.tsx | 2 +- src/components/Menu/src/BasicMenu.vue | 135 ++++------ src/components/Menu/src/MenuContent.tsx | 96 ------- .../Menu/src/components/BasicMenuItem.vue | 17 +- .../Menu/src/components/BasicSubMenuItem.vue | 10 +- .../Menu/src/components/MenuItemContent.vue | 41 +++ .../Menu/src/components/MenuItemTag.vue | 56 ++++ src/components/Menu/src/index.less | 144 +++-------- src/components/Menu/src/props.ts | 13 +- src/components/Menu/src/useOpenKeys.ts | 2 + src/components/Page/src/PageFooter.vue | 4 +- src/components/Preview/src/index.less | 2 +- src/components/Upload/src/UploadModal.vue | 3 +- src/design/color.less | 2 +- src/design/index.less | 4 + src/design/var/index.less | 14 +- src/hooks/event/useBreakpoint.ts | 19 +- src/hooks/setting/useHeaderSetting.ts | 5 - src/hooks/setting/useMenuSetting.ts | 5 + src/hooks/setting/useMultipleTabSetting.ts | 3 + src/hooks/web/useAppInject.ts | 10 + src/hooks/web/useI18n.ts | 2 +- src/hooks/web/usePage.ts | 12 +- src/hooks/web/useTabs.ts | 6 +- src/layouts/default/content/index.vue | 3 +- src/layouts/default/header/LayoutHeader.tsx | 154 +++-------- .../default/header/LayoutMultipleHeader.less | 4 +- .../default/header/LayoutMultipleHeader.tsx | 16 +- src/layouts/default/header/UserDropdown.tsx | 125 --------- .../Breadcrumb.vue} | 80 +++++- .../default/header/components/ErrorAction.vue | 47 ++++ .../default/header/components/FullScreen.vue | 36 +++ .../default/header/components/index.ts | 15 ++ .../lock}/LockAction.less | 0 .../lock}/LockAction.tsx | 0 .../header/components/lock/LockModal.vue | 116 +++++++++ .../default/header/components/lock/index.vue | 38 +++ .../notify}/NoticeList.vue | 12 +- .../{notice => components/notify}/data.ts | 0 .../notify/index.vue} | 21 +- .../components/user-dropdown/DropMenuItem.vue | 27 ++ .../header/components/user-dropdown/index.vue | 156 ++++++++++++ src/layouts/default/header/index.less | 239 +++++------------- src/layouts/default/header/index.vue | 161 ++++++++++++ src/layouts/default/index.vue | 21 +- src/layouts/default/menu/index.tsx | 46 +++- src/layouts/default/menu/useLayoutMenu.ts | 12 +- src/layouts/default/setting/SettingDrawer.tsx | 9 +- src/layouts/default/setting/enum.ts | 1 + src/layouts/default/setting/handler.ts | 2 + src/layouts/default/sider/index.less | 12 +- src/layouts/default/sider/index.tsx | 65 ++--- src/layouts/default/sider/useLayoutSider.tsx | 9 +- .../default/tabs/components/TabContent.vue | 2 +- .../default/tabs/components/TabRedo.vue | 37 +++ src/layouts/default/tabs/index.less | 49 ++-- src/layouts/default/tabs/index.vue | 49 ++-- src/layouts/default/tabs/useTabDropdown.ts | 6 +- src/layouts/default/useLayoutContext.ts | 1 - src/locales/lang/en/layout/header.ts | 2 +- src/locales/lang/en/layout/multipleTab.ts | 1 + src/locales/lang/en/layout/setting.ts | 1 + src/locales/lang/zh_CN/layout/header.ts | 2 +- src/locales/lang/zh_CN/layout/multipleTab.ts | 1 + src/locales/lang/zh_CN/layout/setting.ts | 1 + src/logics/mitt/tabChange.ts | 28 ++ src/router/guard/index.ts | 6 +- src/router/menus/index.ts | 1 + src/settings/projectSetting.ts | 6 +- src/store/modules/tab.ts | 23 +- src/types/config.d.ts | 6 +- src/utils/mitt.ts | 10 +- src/views/sys/lock/LockPage.vue | 2 +- 80 files changed, 1338 insertions(+), 972 deletions(-) delete mode 100644 src/components/Menu/src/MenuContent.tsx create mode 100644 src/components/Menu/src/components/MenuItemContent.vue create mode 100644 src/components/Menu/src/components/MenuItemTag.vue create mode 100644 src/hooks/web/useAppInject.ts delete mode 100644 src/layouts/default/header/UserDropdown.tsx rename src/layouts/default/header/{LayoutBreadcrumb.vue => components/Breadcrumb.vue} (53%) create mode 100644 src/layouts/default/header/components/ErrorAction.vue create mode 100644 src/layouts/default/header/components/FullScreen.vue create mode 100644 src/layouts/default/header/components/index.ts rename src/layouts/default/header/{actions => components/lock}/LockAction.less (100%) rename src/layouts/default/header/{actions => components/lock}/LockAction.tsx (100%) create mode 100644 src/layouts/default/header/components/lock/LockModal.vue create mode 100644 src/layouts/default/header/components/lock/index.vue rename src/layouts/default/header/{notice => components/notify}/NoticeList.vue (85%) rename src/layouts/default/header/{notice => components/notify}/data.ts (100%) rename src/layouts/default/header/{notice/NoticeActionItem.vue => components/notify/index.vue} (76%) create mode 100644 src/layouts/default/header/components/user-dropdown/DropMenuItem.vue create mode 100644 src/layouts/default/header/components/user-dropdown/index.vue create mode 100644 src/layouts/default/header/index.vue create mode 100644 src/layouts/default/tabs/components/TabRedo.vue create mode 100644 src/logics/mitt/tabChange.ts diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index 55e6ffd3..483de9e2 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -7,11 +7,13 @@ ### ⚡ Performance Improvements - 异步引入组件 +- 优化整体结构 ### 🎫 Chores - 返回顶部样式调整,避免遮住其他元素 -- 升级`ant-design-vue`到`2.0.0-rc.4` +- 升级`ant-design-vue`到`2.0.0-rc.5` +- 刷新按钮布局调整 ### 🐛 Bug Fixes @@ -23,6 +25,8 @@ - 修复按钮样式问题 - 修复菜单分割模式问题 - 修复 `Modal`与`Drawer`组件在使用 emits 数据传递失效问题 +- 修复菜单已知问题 +- 修复上传组件 api 失效问题 ## 2.0.0-rc.13 (2020-12-10) diff --git a/src/components/Application/index.ts b/src/components/Application/index.ts index 983b4cfd..eafb2803 100644 --- a/src/components/Application/index.ts +++ b/src/components/Application/index.ts @@ -2,9 +2,7 @@ import { withInstall } from '../util'; import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; import AppLogo from './src/AppLogo.vue'; -export const AppLocalePicker = createAsyncComponent(() => import('./src/AppLocalePicker.vue'), { - loading: true, -}); +export const AppLocalePicker = createAsyncComponent(() => import('./src/AppLocalePicker.vue')); export const AppProvider = createAsyncComponent(() => import('./src/AppProvider.vue')); export const AppSearch = createAsyncComponent(() => import('./src/search/AppSearch.vue'), { loading: true, diff --git a/src/components/Application/src/AppLocalePicker.vue b/src/components/Application/src/AppLocalePicker.vue index 72c4c7f9..3a592ffb 100644 --- a/src/components/Application/src/AppLocalePicker.vue +++ b/src/components/Application/src/AppLocalePicker.vue @@ -11,8 +11,8 @@ :overlayClassName="`${prefixCls}-overlay`" > - - {{ getLangText }} + + {{ getLangText }} @@ -30,9 +30,10 @@ import { propTypes } from '/@/utils/propTypes'; import { useDesign } from '/@/hooks/web/useDesign'; + import Icon from '/@/components/Icon'; export default defineComponent({ name: 'AppLocalPicker', - components: { GlobalOutlined, Dropdown }, + components: { GlobalOutlined, Dropdown, Icon }, props: { // Whether to display text showText: propTypes.bool.def(true), @@ -88,8 +89,8 @@ align-items: center; cursor: pointer; - &__icon { - margin-right: 4px; + &__text { + margin-left: 6px; } } diff --git a/src/components/Application/src/AppLogo.vue b/src/components/Application/src/AppLogo.vue index 270bb485..17d4b6c5 100644 --- a/src/components/Application/src/AppLogo.vue +++ b/src/components/Application/src/AppLogo.vue @@ -87,7 +87,7 @@ } &__title { - font-size: 18px; + font-size: 16px; font-weight: 700; opacity: 0; transition: all 0.5s; diff --git a/src/components/Application/src/AppProvider.vue b/src/components/Application/src/AppProvider.vue index e8d905cd..ddf8c6ce 100644 --- a/src/components/Application/src/AppProvider.vue +++ b/src/components/Application/src/AppProvider.vue @@ -3,11 +3,13 @@ diff --git a/src/layouts/default/header/components/ErrorAction.vue b/src/layouts/default/header/components/ErrorAction.vue new file mode 100644 index 00000000..1d496415 --- /dev/null +++ b/src/layouts/default/header/components/ErrorAction.vue @@ -0,0 +1,47 @@ + + diff --git a/src/layouts/default/header/components/FullScreen.vue b/src/layouts/default/header/components/FullScreen.vue new file mode 100644 index 00000000..42a7ea5c --- /dev/null +++ b/src/layouts/default/header/components/FullScreen.vue @@ -0,0 +1,36 @@ + + diff --git a/src/layouts/default/header/components/index.ts b/src/layouts/default/header/components/index.ts new file mode 100644 index 00000000..fb628706 --- /dev/null +++ b/src/layouts/default/header/components/index.ts @@ -0,0 +1,15 @@ +import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; + +export const UserDropDown = createAsyncComponent(() => import('./user-dropdown/index.vue'), { + loading: true, +}); + +export const LayoutBreadcrumb = createAsyncComponent(() => import('./Breadcrumb.vue')); + +export const FullScreen = createAsyncComponent(() => import('./FullScreen.vue')); + +export const Notify = createAsyncComponent(() => import('./notify/index.vue')); + +export const LockItem = createAsyncComponent(() => import('./lock/index.vue')); + +export const ErrorAction = createAsyncComponent(() => import('./ErrorAction.vue')); diff --git a/src/layouts/default/header/actions/LockAction.less b/src/layouts/default/header/components/lock/LockAction.less similarity index 100% rename from src/layouts/default/header/actions/LockAction.less rename to src/layouts/default/header/components/lock/LockAction.less diff --git a/src/layouts/default/header/actions/LockAction.tsx b/src/layouts/default/header/components/lock/LockAction.tsx similarity index 100% rename from src/layouts/default/header/actions/LockAction.tsx rename to src/layouts/default/header/components/lock/LockAction.tsx diff --git a/src/layouts/default/header/components/lock/LockModal.vue b/src/layouts/default/header/components/lock/LockModal.vue new file mode 100644 index 00000000..7ca58007 --- /dev/null +++ b/src/layouts/default/header/components/lock/LockModal.vue @@ -0,0 +1,116 @@ + + + diff --git a/src/layouts/default/header/components/lock/index.vue b/src/layouts/default/header/components/lock/index.vue new file mode 100644 index 00000000..37b2ff4d --- /dev/null +++ b/src/layouts/default/header/components/lock/index.vue @@ -0,0 +1,38 @@ + + diff --git a/src/layouts/default/header/notice/NoticeList.vue b/src/layouts/default/header/components/notify/NoticeList.vue similarity index 85% rename from src/layouts/default/header/notice/NoticeList.vue rename to src/layouts/default/header/components/notify/NoticeList.vue index 6337dc0b..ff50874f 100644 --- a/src/layouts/default/header/notice/NoticeList.vue +++ b/src/layouts/default/header/components/notify/NoticeList.vue @@ -1,5 +1,5 @@ -