@gx-design-vue/create-gx-cli 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/main.js +1 -0
- package/template-design-pro/.editorconfig +19 -0
- package/template-design-pro/.env +2 -0
- package/template-design-pro/.env.development +18 -0
- package/template-design-pro/.env.pro +32 -0
- package/template-design-pro/.env.production +32 -0
- package/template-design-pro/.env.test +20 -0
- package/template-design-pro/.eslintignore +16 -0
- package/template-design-pro/.eslintrc.js +64 -0
- package/template-design-pro/.gitpod.yml +6 -0
- package/template-design-pro/.husky/pre-commit +4 -0
- package/template-design-pro/.prettierignore +9 -0
- package/template-design-pro/.stylelintignore +3 -0
- package/template-design-pro/.yarnclean +48 -0
- package/template-design-pro/LICENSE +21 -0
- package/template-design-pro/README.md +111 -0
- package/template-design-pro/build/constant.ts +6 -0
- package/template-design-pro/build/generate/generateModifyVars.ts +18 -0
- package/template-design-pro/build/getConfigFileName.ts +13 -0
- package/template-design-pro/build/script/buildConf.ts +44 -0
- package/template-design-pro/build/script/postBuild.ts +25 -0
- package/template-design-pro/build/script/reSetRootHtml.ts +20 -0
- package/template-design-pro/build/utils.ts +85 -0
- package/template-design-pro/build/vite/cdn.ts +7 -0
- package/template-design-pro/build/vite/optimizer.ts +22 -0
- package/template-design-pro/build/vite/plugin/autoImport.ts +18 -0
- package/template-design-pro/build/vite/plugin/compress.ts +35 -0
- package/template-design-pro/build/vite/plugin/hmr.ts +25 -0
- package/template-design-pro/build/vite/plugin/html.ts +47 -0
- package/template-design-pro/build/vite/plugin/index.ts +89 -0
- package/template-design-pro/build/vite/plugin/mock.ts +20 -0
- package/template-design-pro/build/vite/plugin/pwa.ts +37 -0
- package/template-design-pro/build/vite/plugin/styleImport.ts +129 -0
- package/template-design-pro/build/vite/plugin/visualizer.ts +17 -0
- package/template-design-pro/build/vite/plugin/vite-plugin-antd-theme/index.ts +24 -0
- package/template-design-pro/build/vite/plugin/vite-plugin-mock/createMockServer.ts +303 -0
- package/template-design-pro/build/vite/plugin/vite-plugin-mock/createProdMockServer.ts +93 -0
- package/template-design-pro/build/vite/plugin/vite-plugin-mock/index.ts +68 -0
- package/template-design-pro/build/vite/plugin/vite-plugin-mock/types.ts +30 -0
- package/template-design-pro/build/vite/plugin/vite-plugin-mock/utils.ts +26 -0
- package/template-design-pro/commitlint.config.js +32 -0
- package/template-design-pro/config/config.ts +14 -0
- package/template-design-pro/config/default/animate.ts +30 -0
- package/template-design-pro/config/default/defaultSettings.ts +75 -0
- package/template-design-pro/config/default/network.ts +16 -0
- package/template-design-pro/config/default/proxy.ts +26 -0
- package/template-design-pro/config/default/theme.ts +43 -0
- package/template-design-pro/config/default/themeColor.ts +62 -0
- package/template-design-pro/index.html +45 -0
- package/template-design-pro/jest.config.mjs +36 -0
- package/template-design-pro/mock/_createProductionServer.ts +19 -0
- package/template-design-pro/mock/_util.ts +55 -0
- package/template-design-pro/mock/controller/menu.ts +85 -0
- package/template-design-pro/mock/controller/notices.ts +114 -0
- package/template-design-pro/mock/system/dict.ts +60 -0
- package/template-design-pro/mock/system/user.ts +218 -0
- package/template-design-pro/package.json +151 -0
- package/template-design-pro/pnpm-lock.yaml +9913 -0
- package/template-design-pro/postcss.config.js +5 -0
- package/template-design-pro/prettier.config.js +18 -0
- package/template-design-pro/public/resource/css/index.css +171 -0
- package/template-design-pro/public/resource/img/favicon.ico +0 -0
- package/template-design-pro/public/resource/img/logo.png +0 -0
- package/template-design-pro/public/resource/img/pro_icon.svg +5 -0
- package/template-design-pro/public/resource/img/pwa-192x192.png +0 -0
- package/template-design-pro/public/resource/img/pwa-512x512.png +0 -0
- package/template-design-pro/src/App.vue +47 -0
- package/template-design-pro/src/assets/error_images/403.png +0 -0
- package/template-design-pro/src/assets/error_images/404.png +0 -0
- package/template-design-pro/src/assets/error_images/cloud.png +0 -0
- package/template-design-pro/src/assets/login_images/login_background.svg +69 -0
- package/template-design-pro/src/assets/logo.png +0 -0
- package/template-design-pro/src/assets/menu_font/iconfont.css +94 -0
- package/template-design-pro/src/assets/menu_font/iconfont.eot +0 -0
- package/template-design-pro/src/assets/menu_font/iconfont.js +1 -0
- package/template-design-pro/src/assets/menu_font/iconfont.json +142 -0
- package/template-design-pro/src/assets/menu_font/iconfont.svg +57 -0
- package/template-design-pro/src/assets/menu_font/iconfont.ttf +0 -0
- package/template-design-pro/src/assets/menu_font/iconfont.woff +0 -0
- package/template-design-pro/src/assets/menu_font/iconfont.woff2 +0 -0
- package/template-design-pro/src/assets/menu_font/index.less +94 -0
- package/template-design-pro/src/common/global.ts +1 -0
- package/template-design-pro/src/components/GDesign/ProLayout/BasicLayout.less +80 -0
- package/template-design-pro/src/components/GDesign/ProLayout/BasicLayout.tsx +342 -0
- package/template-design-pro/src/components/GDesign/ProLayout/PageLoading.tsx +20 -0
- package/template-design-pro/src/components/GDesign/ProLayout/RenderTypings.ts +31 -0
- package/template-design-pro/src/components/GDesign/ProLayout/RouteContext.tsx +82 -0
- package/template-design-pro/src/components/GDesign/ProLayout/WrapContent.tsx +69 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/GlobalFooter/index.tsx +88 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/GlobalHeader/DefaultHeader.tsx +189 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/GlobalHeader/Header.less +8 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/GlobalHeader/index.tsx +105 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/GlobalHeader/props.ts +69 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/GlobalHeader/style.less +144 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/LogoContent/index.tsx +81 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/LogoContent/props.ts +29 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/MultiTab/index.tsx +384 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/MultiTab/props.ts +15 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/MultiTab/style.less +79 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/NoticeIcon/NoticeIcon.tsx +148 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/NoticeIcon/NoticeList.module.less +115 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/NoticeIcon/NoticeList.tsx +154 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/NoticeIcon/index.less +39 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/NoticeIcon/index.tsx +133 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/PageContainer/index.tsx +190 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/PageContainer/props.ts +48 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/PageContainer/style.less +128 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/PageContainer/typings.ts +0 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/RightContent/AvatarDropdown.tsx +63 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/RightContent/HeaderSearch.tsx +122 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/RightContent/headerSearch.less +30 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/RightContent/index.tsx +95 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/RightContent/style.less +90 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/SettingDrawer/BlockCheckbox.tsx +70 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/SettingDrawer/LayoutSetting.tsx +107 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/SettingDrawer/ThemeColor.tsx +68 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/SettingDrawer/index.tsx +346 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/SiderMenu/BaseMenu.tsx +224 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/SiderMenu/SiderMenu.tsx +224 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/SiderMenu/index.tsx +43 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/SiderMenu/props.ts +112 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/SiderMenu/style.less +262 -0
- package/template-design-pro/src/components/GDesign/ProLayout/components/SiderMenu/typings.ts +44 -0
- package/template-design-pro/src/components/GDesign/ProLayout/default.less +2 -0
- package/template-design-pro/src/components/GDesign/ProLayout/defaultSettings.ts +121 -0
- package/template-design-pro/src/components/GDesign/ProLayout/hooks/context/index.ts +45 -0
- package/template-design-pro/src/components/GDesign/ProLayout/index.ts +43 -0
- package/template-design-pro/src/components/GDesign/ProLayout/props.ts +57 -0
- package/template-design-pro/src/components/GDesign/ProLayout/style.less +272 -0
- package/template-design-pro/src/components/GDesign/ProLayout/typings.ts +1 -0
- package/template-design-pro/src/components/GDesign/ProLayout/utils/getMenuData.ts +31 -0
- package/template-design-pro/src/components/GDesign/ProLayout/utils/index.ts +94 -0
- package/template-design-pro/src/components/GDesign/ProLayout/utils/isImg/index.ts +6 -0
- package/template-design-pro/src/components/GDesign/ProLayout/utils/isUrl/index.ts +5 -0
- package/template-design-pro/src/components/GDesign/Result/index.tsx +142 -0
- package/template-design-pro/src/components/GDesign/Result/style.less +140 -0
- package/template-design-pro/src/components/GDesign/Scrollbars/components/Bar/index.tsx +56 -0
- package/template-design-pro/src/components/GDesign/Scrollbars/components/Bar/props.ts +23 -0
- package/template-design-pro/src/components/GDesign/Scrollbars/components/Thumb/index.tsx +164 -0
- package/template-design-pro/src/components/GDesign/Scrollbars/components/Thumb/props.ts +11 -0
- package/template-design-pro/src/components/GDesign/Scrollbars/context.ts +10 -0
- package/template-design-pro/src/components/GDesign/Scrollbars/index.tsx +200 -0
- package/template-design-pro/src/components/GDesign/Scrollbars/props.ts +65 -0
- package/template-design-pro/src/components/GDesign/Scrollbars/style.less +85 -0
- package/template-design-pro/src/components/GDesign/Scrollbars/util.ts +40 -0
- package/template-design-pro/src/components/GDesign/utils/index.ts +7 -0
- package/template-design-pro/src/components/PageLoading/index.tsx +44 -0
- package/template-design-pro/src/components/PageTransition/index.vue +98 -0
- package/template-design-pro/src/components/index.ts +6 -0
- package/template-design-pro/src/core/ant-design/index.ts +14 -0
- package/template-design-pro/src/core/gx-admin-design/index.ts +7 -0
- package/template-design-pro/src/core/gx-admin-directives/index.ts +8 -0
- package/template-design-pro/src/core/gx-admin-directives/permission.ts +28 -0
- package/template-design-pro/src/core/gx-design/index.ts +7 -0
- package/template-design-pro/src/core/gx-pro-design/index.ts +10 -0
- package/template-design-pro/src/core/index.ts +27 -0
- package/template-design-pro/src/design/ant-design/index.less +4 -0
- package/template-design-pro/src/design/ant-design/layout.less +29 -0
- package/template-design-pro/src/design/ant-design/menu.less +55 -0
- package/template-design-pro/src/design/ant-design/table.less +67 -0
- package/template-design-pro/src/design/ant-design/tooltip.less +13 -0
- package/template-design-pro/src/design/color.less +1 -0
- package/template-design-pro/src/design/config.less +5 -0
- package/template-design-pro/src/design/index.less +41 -0
- package/template-design-pro/src/design/mixin.less +66 -0
- package/template-design-pro/src/design/normalize.less +390 -0
- package/template-design-pro/src/global.less +15 -0
- package/template-design-pro/src/hooks/core/index.ts +3 -0
- package/template-design-pro/src/hooks/core/useRequest/index.ts +70 -0
- package/template-design-pro/src/hooks/core/useRequest/typings.ts +0 -0
- package/template-design-pro/src/hooks/event/index.ts +3 -0
- package/template-design-pro/src/hooks/event/useClipboard.ts +14 -0
- package/template-design-pro/src/hooks/system/index.ts +5 -0
- package/template-design-pro/src/hooks/system/useDict.ts +62 -0
- package/template-design-pro/src/hooks/system/usePermissions.ts +39 -0
- package/template-design-pro/src/hooks/typings.ts +17 -0
- package/template-design-pro/src/layout/BasicLayout.vue +104 -0
- package/template-design-pro/src/layout/BlankLayout.vue +5 -0
- package/template-design-pro/src/layout/ContentView.vue +76 -0
- package/template-design-pro/src/layout/IframeView.vue +1 -0
- package/template-design-pro/src/layout/UserLayout.vue +7 -0
- package/template-design-pro/src/main.ts +34 -0
- package/template-design-pro/src/plugins/index.ts +3 -0
- package/template-design-pro/src/router/guard/index.ts +84 -0
- package/template-design-pro/src/router/guard/permissions.ts +73 -0
- package/template-design-pro/src/router/guard/stateGuard.ts +11 -0
- package/template-design-pro/src/router/helper/routeHelper.ts +244 -0
- package/template-design-pro/src/router/helper/utils.ts +19 -0
- package/template-design-pro/src/router/index.ts +30 -0
- package/template-design-pro/src/router/routes/index.ts +85 -0
- package/template-design-pro/src/router/routes/modules/workplace.ts +19 -0
- package/template-design-pro/src/services/common/index.ts +11 -0
- package/template-design-pro/src/services/controller/router.ts +10 -0
- package/template-design-pro/src/services/controller/user.ts +35 -0
- package/template-design-pro/src/services/system/dictData.ts +10 -0
- package/template-design-pro/src/services/system/notices.ts +9 -0
- package/template-design-pro/src/store/index.ts +32 -0
- package/template-design-pro/src/store/modules/dict.ts +27 -0
- package/template-design-pro/src/store/modules/permission.ts +19 -0
- package/template-design-pro/src/store/modules/routes.ts +110 -0
- package/template-design-pro/src/store/modules/settings.ts +102 -0
- package/template-design-pro/src/store/modules/tabsRouter.ts +73 -0
- package/template-design-pro/src/store/modules/user.ts +153 -0
- package/template-design-pro/src/utils/accessToken.ts +93 -0
- package/template-design-pro/src/utils/crypto.ts +39 -0
- package/template-design-pro/src/utils/env.ts +52 -0
- package/template-design-pro/src/utils/fetchFile.ts +79 -0
- package/template-design-pro/src/utils/index.ts +127 -0
- package/template-design-pro/src/utils/pageTitle.ts +17 -0
- package/template-design-pro/src/utils/request/XHR.ts +131 -0
- package/template-design-pro/src/utils/request/axiosCancel.ts +60 -0
- package/template-design-pro/src/utils/request/checkStatus.ts +26 -0
- package/template-design-pro/src/utils/request/index.ts +145 -0
- package/template-design-pro/src/utils/request/typings.ts +114 -0
- package/template-design-pro/src/utils/storage.ts +194 -0
- package/template-design-pro/src/utils/uploadFile.ts +26 -0
- package/template-design-pro/src/utils/util.ts +278 -0
- package/template-design-pro/src/utils/validate.ts +221 -0
- package/template-design-pro/src/views/Iframe/index.vue +76 -0
- package/template-design-pro/src/views/MenuOne/index.vue +15 -0
- package/template-design-pro/src/views/MenuTwo/index.vue +13 -0
- package/template-design-pro/src/views/exception/403/index.vue +9 -0
- package/template-design-pro/src/views/exception/404/index.vue +9 -0
- package/template-design-pro/src/views/user/login/index.vue +110 -0
- package/template-design-pro/src/views/user/login/style.less +38 -0
- package/template-design-pro/stylelint.config.js +106 -0
- package/template-design-pro/tests/__mocks__/fileMock.ts +1 -0
- package/template-design-pro/tests/__mocks__/styleMock.ts +1 -0
- package/template-design-pro/tests/__mocks__/workerMock.ts +5 -0
- package/template-design-pro/tests/server/README.md +15 -0
- package/template-design-pro/tests/server/controller/FileController.ts +18 -0
- package/template-design-pro/tests/server/controller/UserController.ts +15 -0
- package/template-design-pro/tests/server/ecosystem.config.js +18 -0
- package/template-design-pro/tests/server/index.ts +63 -0
- package/template-design-pro/tests/server/nodemon.json +8 -0
- package/template-design-pro/tests/server/package.json +36 -0
- package/template-design-pro/tests/server/routes.ts +23 -0
- package/template-design-pro/tests/server/service/FileService.ts +54 -0
- package/template-design-pro/tests/server/service/UserService.ts +25 -0
- package/template-design-pro/tests/server/tsconfig.json +15 -0
- package/template-design-pro/tests/server/utils.ts +9 -0
- package/template-design-pro/tests/server/yarn.lock +2955 -0
- package/template-design-pro/tests/test.spec.ts +16 -0
- package/template-design-pro/tsconfig.json +47 -0
- package/template-design-pro/types/auto-imports.d.ts +61 -0
- package/template-design-pro/types/config.d.ts +100 -0
- package/template-design-pro/types/global.d.ts +103 -0
- package/template-design-pro/types/gx-components.d.ts +24 -0
- package/template-design-pro/types/index.d.ts +13 -0
- package/template-design-pro/types/mock.d.ts +23 -0
- package/template-design-pro/types/module.d.ts +16 -0
- package/template-design-pro/types/response.d.ts +15 -0
- package/template-design-pro/types/route.d.ts +89 -0
- package/template-design-pro/vite.config.ts +136 -0
- package/template-design-pro/yarn.lock +9697 -0
package/template-design-pro/src/components/GDesign/ProLayout/components/SiderMenu/BaseMenu.tsx
ADDED
@@ -0,0 +1,224 @@
|
|
1
|
+
import {
|
2
|
+
defineComponent,
|
3
|
+
VNodeChild,
|
4
|
+
VNode,
|
5
|
+
computed,
|
6
|
+
isVNode,
|
7
|
+
resolveComponent,
|
8
|
+
ExtractPropTypes,
|
9
|
+
ConcreteComponent
|
10
|
+
} from 'vue'
|
11
|
+
import { useRouter } from 'vue-router'
|
12
|
+
import { Menu } from 'ant-design-vue'
|
13
|
+
import { createFromIconfontCN } from '@ant-design/icons-vue'
|
14
|
+
import { baseMenuProps } from './props'
|
15
|
+
import { defaultSettings } from '../../defaultSettings'
|
16
|
+
import { isImg, isUrl } from '../../utils'
|
17
|
+
|
18
|
+
export interface CustomMenuRender {
|
19
|
+
menuItemRender?: WithFalse<
|
20
|
+
(args: { item: AppRouteModule; title?: JSX.Element; icon?: JSX.Element }) => CustomRender
|
21
|
+
>
|
22
|
+
subMenuItemRender?: WithFalse<
|
23
|
+
(args: { item: AppRouteModule; children?: CustomRender[] }) => CustomRender
|
24
|
+
>
|
25
|
+
}
|
26
|
+
|
27
|
+
export type BaseMenuProps = ExtractPropTypes<typeof baseMenuProps>
|
28
|
+
|
29
|
+
const IconFont: any = (iconfontUrl) => {
|
30
|
+
return createFromIconfontCN({
|
31
|
+
scriptUrl: iconfontUrl || defaultSettings.iconfontUrl
|
32
|
+
})
|
33
|
+
}
|
34
|
+
|
35
|
+
const LazyIcon = (props: {
|
36
|
+
icon: VNodeChild | string
|
37
|
+
iconType?: number
|
38
|
+
iconfontUrl?: string
|
39
|
+
}) => {
|
40
|
+
const { icon, iconType, iconfontUrl } = props
|
41
|
+
if (!icon) {
|
42
|
+
return null
|
43
|
+
}
|
44
|
+
if (typeof icon === 'string' && icon !== '') {
|
45
|
+
if (isUrl(icon) || isImg(icon)) {
|
46
|
+
return <img src={icon} alt="icon" class={`gx-pro-sider-menu-icon customimg`} />
|
47
|
+
}
|
48
|
+
if (iconType === 1) {
|
49
|
+
return iconfontUrl ? <IconFont type={icon} /> : <i class={`iconfont ${icon} customicon`}></i>
|
50
|
+
}
|
51
|
+
}
|
52
|
+
if (isVNode(icon)) {
|
53
|
+
return icon
|
54
|
+
}
|
55
|
+
const DynamicIcon = resolveComponent(icon as string) as any
|
56
|
+
return (typeof LazyIcon === 'function' && <DynamicIcon />) || null
|
57
|
+
}
|
58
|
+
|
59
|
+
LazyIcon.props = {
|
60
|
+
icon: {
|
61
|
+
type: [String, Function, Object] as PropType<string | Function | VNode | JSX.Element>
|
62
|
+
},
|
63
|
+
iconType: Number,
|
64
|
+
iconfontUrl: String
|
65
|
+
}
|
66
|
+
|
67
|
+
export default defineComponent({
|
68
|
+
name: 'BaseMenu',
|
69
|
+
props: baseMenuProps,
|
70
|
+
emits: ['update:openKeys', 'update:selectedKeys', 'click'],
|
71
|
+
setup(props, { attrs, emit }) {
|
72
|
+
const router = useRouter()
|
73
|
+
const handleOpenChange = (openKeys: string[]): void => {
|
74
|
+
emit('update:openKeys', openKeys)
|
75
|
+
}
|
76
|
+
const handleSelect = (params: {
|
77
|
+
key: string | number
|
78
|
+
keyPath: string[] | number[]
|
79
|
+
item: VNodeChild | any
|
80
|
+
domEvent: MouseEvent
|
81
|
+
selectedKeys: string[]
|
82
|
+
}): void => {
|
83
|
+
emit('update:selectedKeys', params.selectedKeys)
|
84
|
+
}
|
85
|
+
const handleClick = (args: {
|
86
|
+
item: VNodeChild
|
87
|
+
key: string | number
|
88
|
+
keyPath: string | string[] | number | number[]
|
89
|
+
}) => {
|
90
|
+
emit('click', args)
|
91
|
+
}
|
92
|
+
const isTotargetLink = (meta: any, routerInfo: any) => {
|
93
|
+
const target = (meta.target || '') as string
|
94
|
+
const hasUrl = isUrl(target)
|
95
|
+
if (router.currentRoute.value?.fullPath !== routerInfo.to) {
|
96
|
+
if (hasUrl && target && meta.targetStatus === 1) {
|
97
|
+
window.open(target)
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
101
|
+
const RouterLink = resolveComponent('router-link') as ConcreteComponent
|
102
|
+
const getNavMenuItems = (menusData: AppRouteModule[] = []) => {
|
103
|
+
return menusData.map((item) => getSubMenuOrItem(item)).filter((item) => item)
|
104
|
+
}
|
105
|
+
const getSubMenuOrItem = (item: AppRouteModule): VNode => {
|
106
|
+
if (
|
107
|
+
Array.isArray(item.children) &&
|
108
|
+
item.children.length > 0 &&
|
109
|
+
!item?.meta?.hideInMenu &&
|
110
|
+
!item?.meta?.hideChildrenInMenu
|
111
|
+
) {
|
112
|
+
if (props.subMenuItemRender) {
|
113
|
+
return props.subMenuItemRender({
|
114
|
+
item,
|
115
|
+
children: getNavMenuItems(item.children)
|
116
|
+
}) as VNode
|
117
|
+
}
|
118
|
+
const menuTitle = item.meta?.title
|
119
|
+
const defaultTitle = item.meta?.icon ? (
|
120
|
+
<span class={`gx-pro-sider-menu-item`}>
|
121
|
+
<span class={`gx-pro-sider-menu-item-title`}>{menuTitle}</span>
|
122
|
+
</span>
|
123
|
+
) : (
|
124
|
+
<span class={`gx-pro-sider-menu-item`}>{menuTitle}</span>
|
125
|
+
)
|
126
|
+
|
127
|
+
const hasGroup = item.meta?.type === 'group'
|
128
|
+
|
129
|
+
const MenuComponent = hasGroup ? Menu.ItemGroup : Menu.SubMenu
|
130
|
+
|
131
|
+
return (
|
132
|
+
<MenuComponent
|
133
|
+
title={defaultTitle}
|
134
|
+
key={item.path}
|
135
|
+
icon={
|
136
|
+
hasGroup ? null : (
|
137
|
+
<LazyIcon
|
138
|
+
icon={item.meta?.icon}
|
139
|
+
iconfontUrl={props.iconfontUrl}
|
140
|
+
iconType={item.meta?.iconType}
|
141
|
+
/>
|
142
|
+
)
|
143
|
+
}
|
144
|
+
>
|
145
|
+
{getNavMenuItems(item.children)}
|
146
|
+
</MenuComponent>
|
147
|
+
)
|
148
|
+
}
|
149
|
+
|
150
|
+
const [title, icon] = getMenuItem(item)
|
151
|
+
|
152
|
+
return (
|
153
|
+
((props.menuItemRender && props.menuItemRender({ item, title, icon })) as VNode) || (
|
154
|
+
<Menu.Item
|
155
|
+
disabled={item.meta?.disabled}
|
156
|
+
danger={item.meta?.danger}
|
157
|
+
key={item.path}
|
158
|
+
icon={icon}
|
159
|
+
>
|
160
|
+
{title}
|
161
|
+
</Menu.Item>
|
162
|
+
)
|
163
|
+
)
|
164
|
+
}
|
165
|
+
const getMenuItem = (item: AppRouteModule) => {
|
166
|
+
const meta = { ...item.meta }
|
167
|
+
const CustomTag: any = meta.targetStatus === 1 && meta.target ? 'a' : RouterLink
|
168
|
+
const parames = { to: item.linkPath || item.path || '' }
|
169
|
+
if (parames.to === '/live/list/operation/:id') parames.to = '/live/list/operation/add'
|
170
|
+
|
171
|
+
const menuTitle = item.meta?.title
|
172
|
+
const defaultTitle = item.meta?.icon ? (
|
173
|
+
<CustomTag
|
174
|
+
{...parames}
|
175
|
+
class={`gx-pro-sider-menu-item`}
|
176
|
+
onClick={() => isTotargetLink(meta, parames)}
|
177
|
+
>
|
178
|
+
<span class={`gx-pro-sider-menu-item-title`}>{menuTitle}</span>
|
179
|
+
</CustomTag>
|
180
|
+
) : (
|
181
|
+
<CustomTag
|
182
|
+
{...parames}
|
183
|
+
class={`gx-pro-sider-menu-item`}
|
184
|
+
onClick={() => isTotargetLink(meta, parames)}
|
185
|
+
>
|
186
|
+
<span>{menuTitle}</span>
|
187
|
+
</CustomTag>
|
188
|
+
)
|
189
|
+
|
190
|
+
const icon =
|
191
|
+
(item.meta?.icon && (
|
192
|
+
<LazyIcon
|
193
|
+
icon={item.meta?.icon}
|
194
|
+
iconfontUrl={props.iconfontUrl}
|
195
|
+
iconType={item.meta?.iconType}
|
196
|
+
/>
|
197
|
+
)) ||
|
198
|
+
undefined
|
199
|
+
|
200
|
+
return [defaultTitle, icon]
|
201
|
+
}
|
202
|
+
const getMenuItems = computed(() => {
|
203
|
+
return getNavMenuItems(props.menuData)
|
204
|
+
})
|
205
|
+
return () => (
|
206
|
+
<Menu
|
207
|
+
key="Menu"
|
208
|
+
inlineIndent={16}
|
209
|
+
mode={props.mode}
|
210
|
+
theme={props.theme as 'dark' | 'light'}
|
211
|
+
openKeys={props.openKeys === false ? [] : props.openKeys}
|
212
|
+
selectedKeys={props.selectedKeys || []}
|
213
|
+
style={attrs.style}
|
214
|
+
class={attrs.class}
|
215
|
+
onOpenChange={handleOpenChange}
|
216
|
+
onSelect={handleSelect}
|
217
|
+
onClick={handleClick}
|
218
|
+
{...props.menuProps}
|
219
|
+
>
|
220
|
+
{getMenuItems.value}
|
221
|
+
</Menu>
|
222
|
+
)
|
223
|
+
}
|
224
|
+
})
|
package/template-design-pro/src/components/GDesign/ProLayout/components/SiderMenu/SiderMenu.tsx
ADDED
@@ -0,0 +1,224 @@
|
|
1
|
+
import type { FunctionalComponent as FC, ExtractPropTypes } from 'vue'
|
2
|
+
import { computed, unref } from 'vue'
|
3
|
+
import { Layout, Spin, Menu } from 'ant-design-vue'
|
4
|
+
import { MenuUnfoldOutlined, MenuFoldOutlined } from '@ant-design/icons-vue'
|
5
|
+
import BaseMenu from './BaseMenu'
|
6
|
+
import { siderMenuProps } from './props'
|
7
|
+
import LogoContent from '../LogoContent'
|
8
|
+
import { useRouteContext } from '../../RouteContext'
|
9
|
+
|
10
|
+
const { Sider } = Layout
|
11
|
+
|
12
|
+
const { Item } = Menu
|
13
|
+
|
14
|
+
export type SiderMenuProps = Partial<ExtractPropTypes<typeof siderMenuProps>>
|
15
|
+
|
16
|
+
export type PrivateSiderMenuProps = {
|
17
|
+
matchMenuKeys?: string[]
|
18
|
+
}
|
19
|
+
|
20
|
+
export const defaultRenderCollapsedButton = (collapsed?: boolean): CustomRender =>
|
21
|
+
collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />
|
22
|
+
|
23
|
+
const SiderMenu: FC<SiderMenuProps> = (props: SiderMenuProps) => {
|
24
|
+
const {
|
25
|
+
theme,
|
26
|
+
layout,
|
27
|
+
isMobile,
|
28
|
+
menuLoading,
|
29
|
+
breakpoint,
|
30
|
+
fixSiderbar,
|
31
|
+
collapsed,
|
32
|
+
siderWidth,
|
33
|
+
collapsedWidth = 48,
|
34
|
+
menuExtraRender = false,
|
35
|
+
menuContentRender = false,
|
36
|
+
menuFooterRender = false,
|
37
|
+
collapsedButtonRender = defaultRenderCollapsedButton,
|
38
|
+
links,
|
39
|
+
onCollapse,
|
40
|
+
onOpenKeys
|
41
|
+
} = props
|
42
|
+
|
43
|
+
const context = useRouteContext()
|
44
|
+
|
45
|
+
const baseClassName = context.getPrefixCls({
|
46
|
+
suffixCls: 'sider',
|
47
|
+
isPor: true
|
48
|
+
})
|
49
|
+
|
50
|
+
const hasContentWide = computed(() => props.layout === 'wide')
|
51
|
+
const hasSplitMenu = computed(() => props.layout === 'mix' && !props.isMobile && props.splitMenus)
|
52
|
+
const layoutSide = computed(() => layout === 'side' || layout === 'simple')
|
53
|
+
const sTheme = computed(
|
54
|
+
() => ((props.layout === 'mix' || hasContentWide.value) && 'light') || theme
|
55
|
+
)
|
56
|
+
const sSideWidth = computed(() => (props.collapsed ? props.collapsedWidth : props.siderWidth))
|
57
|
+
const classNames = computed(() => {
|
58
|
+
return [
|
59
|
+
baseClassName,
|
60
|
+
isMobile ? 'shadow' : null,
|
61
|
+
sTheme.value,
|
62
|
+
hasContentWide.value ? 'wide' : null,
|
63
|
+
fixSiderbar && props.layout !== 'wide' ? `${baseClassName}-fixed` : null
|
64
|
+
]
|
65
|
+
})
|
66
|
+
|
67
|
+
const handleSelect = ($event: string[]) => {
|
68
|
+
if (props.onSelect) {
|
69
|
+
if (unref(hasSplitMenu)) {
|
70
|
+
props.onSelect([context?.selectedKeys?.[0], ...$event])
|
71
|
+
return
|
72
|
+
}
|
73
|
+
props.onSelect($event)
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
if (hasSplitMenu.value && unref(context.flatMenuData).length === 0) {
|
78
|
+
return null
|
79
|
+
}
|
80
|
+
|
81
|
+
const defaultMenuDom = (
|
82
|
+
<BaseMenu
|
83
|
+
class={`${baseClassName}-menu`}
|
84
|
+
theme={sTheme.value}
|
85
|
+
mode="inline"
|
86
|
+
menuData={hasSplitMenu.value ? context.flatMenuData : context.menuData}
|
87
|
+
collapsed={props.collapsed}
|
88
|
+
openKeys={context.openKeys}
|
89
|
+
selectedKeys={context.selectedKeys}
|
90
|
+
menuItemRender={props.menuItemRender}
|
91
|
+
subMenuItemRender={props.subMenuItemRender}
|
92
|
+
onClick={props.onMenuClick}
|
93
|
+
style={{
|
94
|
+
width: '100%'
|
95
|
+
}}
|
96
|
+
{...{
|
97
|
+
'onUpdate:openKeys': ($event: string[]) => onOpenKeys && onOpenKeys($event),
|
98
|
+
'onUpdate:selectedKeys': handleSelect
|
99
|
+
}}
|
100
|
+
/>
|
101
|
+
)
|
102
|
+
|
103
|
+
const headerDom =
|
104
|
+
layoutSide.value || isMobile ? <LogoContent drawer={isMobile} {...props} /> : null
|
105
|
+
|
106
|
+
const extraDom = menuExtraRender && menuExtraRender(props)
|
107
|
+
|
108
|
+
const linksChild = computed(() => {
|
109
|
+
if (typeof links === 'function') return links?.()
|
110
|
+
return links
|
111
|
+
})
|
112
|
+
|
113
|
+
watch(
|
114
|
+
() => sTheme.value,
|
115
|
+
(val) => {
|
116
|
+
console.log(val)
|
117
|
+
}
|
118
|
+
)
|
119
|
+
|
120
|
+
return (
|
121
|
+
<>
|
122
|
+
{!!(hasSplitMenu.value ? context.flatMenuData : context.menuData).length && (
|
123
|
+
<>
|
124
|
+
{fixSiderbar && (
|
125
|
+
<div
|
126
|
+
style={{
|
127
|
+
width: `${sSideWidth.value}px`,
|
128
|
+
overflow: 'hidden',
|
129
|
+
flex: `0 0 ${sSideWidth.value}px`,
|
130
|
+
maxWidth: `${sSideWidth.value}px`,
|
131
|
+
minWidth: `${sSideWidth.value}px`,
|
132
|
+
transition: `background-color 0.3s, min-width 0.3s, max-width 0.3s cubic-bezier(0.645, 0.045, 0.355, 1)`
|
133
|
+
}}
|
134
|
+
/>
|
135
|
+
)}
|
136
|
+
<Sider
|
137
|
+
collapsible
|
138
|
+
trigger={null}
|
139
|
+
class={classNames.value}
|
140
|
+
style={{
|
141
|
+
overflow: 'hidden',
|
142
|
+
zIndex: fixSiderbar ? 101 : undefined,
|
143
|
+
paddingTop:
|
144
|
+
layoutSide.value || props.isMobile || hasContentWide.value
|
145
|
+
? 0
|
146
|
+
: `${props.headerHeight}px`,
|
147
|
+
top: props.layout === 'wide' ? `${props.headerHeight + 20}px` : undefined,
|
148
|
+
height:
|
149
|
+
props.layout === 'wide'
|
150
|
+
? `calc(100vh - ${props.headerHeight + 20 * 2}px)`
|
151
|
+
: undefined
|
152
|
+
}}
|
153
|
+
theme={sTheme.value}
|
154
|
+
breakpoint={breakpoint || undefined}
|
155
|
+
collapsed={collapsed}
|
156
|
+
width={siderWidth}
|
157
|
+
collapsedWidth={collapsedWidth}
|
158
|
+
onCollapse={(collapse) => {
|
159
|
+
if (props.isMobile) return
|
160
|
+
onCollapse?.(collapse)
|
161
|
+
}}
|
162
|
+
>
|
163
|
+
{menuLoading && (
|
164
|
+
<div class="gx-pro-sider-loading">
|
165
|
+
<Spin spinning={menuLoading} />
|
166
|
+
</div>
|
167
|
+
)}
|
168
|
+
{headerDom || null}
|
169
|
+
{extraDom && !props.collapsed && (
|
170
|
+
<div
|
171
|
+
class={{
|
172
|
+
[`${baseClassName}-extra`]: true,
|
173
|
+
[`${baseClassName}-extra-no-logo`]: !headerDom
|
174
|
+
}}
|
175
|
+
>
|
176
|
+
{extraDom}
|
177
|
+
</div>
|
178
|
+
)}
|
179
|
+
<div style="flex: 1 1 0%; overflow: hidden auto">
|
180
|
+
{(menuContentRender && menuContentRender(props, defaultMenuDom)) || defaultMenuDom}
|
181
|
+
</div>
|
182
|
+
{props.layout !== 'wide' && (
|
183
|
+
<div class={`${baseClassName}-links`}>
|
184
|
+
<Menu
|
185
|
+
theme={sTheme.value}
|
186
|
+
inlineIndent={16}
|
187
|
+
class={`${baseClassName}-link-menu`}
|
188
|
+
selectedKeys={[]}
|
189
|
+
openKeys={[]}
|
190
|
+
mode="inline"
|
191
|
+
>
|
192
|
+
{((linksChild.value || []) as any[]).map((node, index) => (
|
193
|
+
<Item class={`${baseClassName}-link`} key={index}>
|
194
|
+
{node}
|
195
|
+
</Item>
|
196
|
+
))}
|
197
|
+
{collapsedButtonRender && !isMobile && (
|
198
|
+
<Item
|
199
|
+
class={`${baseClassName}-collapsed-button`}
|
200
|
+
title={false}
|
201
|
+
key="collapsed"
|
202
|
+
onClick={() => {
|
203
|
+
if (onCollapse) {
|
204
|
+
onCollapse(!collapsed)
|
205
|
+
}
|
206
|
+
}}
|
207
|
+
>
|
208
|
+
{collapsedButtonRender(collapsed)}
|
209
|
+
</Item>
|
210
|
+
)}
|
211
|
+
</Menu>
|
212
|
+
</div>
|
213
|
+
)}
|
214
|
+
{menuFooterRender && (
|
215
|
+
<div class={`${baseClassName}-footer`}>{menuFooterRender(props)}</div>
|
216
|
+
)}
|
217
|
+
</Sider>
|
218
|
+
</>
|
219
|
+
)}
|
220
|
+
</>
|
221
|
+
)
|
222
|
+
}
|
223
|
+
|
224
|
+
export default SiderMenu
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import type { FunctionalComponent as FC } from 'vue'
|
2
|
+
import { Drawer } from 'ant-design-vue'
|
3
|
+
import { siderMenuProps } from './props'
|
4
|
+
import SiderMenu, { SiderMenuProps, PrivateSiderMenuProps } from './SiderMenu'
|
5
|
+
|
6
|
+
export type SiderMenuWrapperProps = Partial<SiderMenuProps> & Partial<PrivateSiderMenuProps>
|
7
|
+
|
8
|
+
const SiderMenuWrapper: FC<SiderMenuWrapperProps> = (props, { attrs }) => {
|
9
|
+
return props.isMobile ? (
|
10
|
+
<Drawer
|
11
|
+
visible={!props.collapsed}
|
12
|
+
closable={false}
|
13
|
+
placement="left"
|
14
|
+
style={{
|
15
|
+
padding: 0,
|
16
|
+
height: '100vh'
|
17
|
+
}}
|
18
|
+
onClose={() => props.onCollapse && props.onCollapse(true)}
|
19
|
+
width={props.siderWidth}
|
20
|
+
bodyStyle={{
|
21
|
+
height: '100vh',
|
22
|
+
padding: 0,
|
23
|
+
display: 'flex',
|
24
|
+
flexDirection: 'row'
|
25
|
+
}}
|
26
|
+
>
|
27
|
+
<SiderMenu {...attrs} {...props} collapsed={props.isMobile ? false : props.collapsed} />
|
28
|
+
</Drawer>
|
29
|
+
) : (
|
30
|
+
<SiderMenu {...attrs} {...props} />
|
31
|
+
)
|
32
|
+
}
|
33
|
+
|
34
|
+
SiderMenuWrapper.inheritAttrs = false
|
35
|
+
SiderMenuWrapper.displayName = 'SiderMenuWrapper'
|
36
|
+
|
37
|
+
export {
|
38
|
+
SiderMenu,
|
39
|
+
// vue props
|
40
|
+
siderMenuProps
|
41
|
+
}
|
42
|
+
|
43
|
+
export default SiderMenuWrapper
|
@@ -0,0 +1,112 @@
|
|
1
|
+
import type { themeConfig, MenuTheme } from '/types/config'
|
2
|
+
import { PropTypes } from '@/utils'
|
3
|
+
import type { CustomMenuRender } from './BaseMenu'
|
4
|
+
import type { SiderProps, MenuMode } from './typings'
|
5
|
+
import logoContentProps from '../LogoContent/props'
|
6
|
+
import type { LinksRender, MenuExtraRender, MenuFooterRender } from '../../RenderTypings'
|
7
|
+
import { defaultSettingProps } from '../../defaultSettings'
|
8
|
+
import { HeaderLogoRender, MenuContentRender } from '../../RenderTypings'
|
9
|
+
|
10
|
+
export const baseMenuProps = {
|
11
|
+
...defaultSettingProps,
|
12
|
+
|
13
|
+
mode: {
|
14
|
+
type: String as PropType<MenuMode>,
|
15
|
+
default: 'inline'
|
16
|
+
},
|
17
|
+
menuData: {
|
18
|
+
type: Array as PropType<AppRouteModule[]>,
|
19
|
+
default: () => []
|
20
|
+
},
|
21
|
+
theme: {
|
22
|
+
type: String as PropType<MenuTheme>,
|
23
|
+
default: 'dark'
|
24
|
+
},
|
25
|
+
layout: {
|
26
|
+
type: String as PropType<themeConfig['layout']>,
|
27
|
+
default: 'mix'
|
28
|
+
},
|
29
|
+
collapsed: {
|
30
|
+
type: Boolean as PropType<boolean | undefined>,
|
31
|
+
default: () => false
|
32
|
+
},
|
33
|
+
openKeys: {
|
34
|
+
type: Array as PropType<WithFalse<string[]>>,
|
35
|
+
default: () => undefined
|
36
|
+
},
|
37
|
+
selectedKeys: {
|
38
|
+
type: Array as PropType<WithFalse<string[]>>,
|
39
|
+
default: () => undefined
|
40
|
+
},
|
41
|
+
menuProps: {
|
42
|
+
type: Object as PropType<Record<string, any>>,
|
43
|
+
default: () => null
|
44
|
+
},
|
45
|
+
menuItemRender: {
|
46
|
+
type: [ Function, Boolean ] as PropType<CustomMenuRender['menuItemRender']>,
|
47
|
+
default: () => false
|
48
|
+
},
|
49
|
+
subMenuItemRender: {
|
50
|
+
type: [ Function, Boolean ] as PropType<CustomMenuRender['subMenuItemRender']>,
|
51
|
+
default: () => false
|
52
|
+
},
|
53
|
+
onClick: [ Function, Object ] as PropType<(...args: any) => void>
|
54
|
+
}
|
55
|
+
|
56
|
+
export const siderMenuProps = {
|
57
|
+
...defaultSettingProps,
|
58
|
+
...baseMenuProps,
|
59
|
+
menuLoading: PropTypes.looseBool,
|
60
|
+
logo: logoContentProps.logo,
|
61
|
+
logoStyle: logoContentProps.logoStyle,
|
62
|
+
logoDirection: logoContentProps.logoDirection,
|
63
|
+
siderWidth: PropTypes.number.def(208),
|
64
|
+
headerHeight: PropTypes.number.def(48),
|
65
|
+
collapsedWidth: PropTypes.number.def(48),
|
66
|
+
links: {
|
67
|
+
type: [ Function, Object, Array ] as PropType<LinksRender>,
|
68
|
+
default: () => undefined
|
69
|
+
},
|
70
|
+
menuHeaderRender: {
|
71
|
+
type: [ Function, Object ] as PropType<HeaderLogoRender>,
|
72
|
+
default: () => undefined
|
73
|
+
},
|
74
|
+
menuFooterRender: {
|
75
|
+
type: [ Function, Object ] as PropType<MenuFooterRender>,
|
76
|
+
default: () => undefined
|
77
|
+
},
|
78
|
+
menuContentRender: {
|
79
|
+
type: [ Function, Object ] as PropType<MenuContentRender>,
|
80
|
+
default: () => undefined
|
81
|
+
},
|
82
|
+
menuExtraRender: {
|
83
|
+
type: [ Function, Object ] as PropType<MenuExtraRender>,
|
84
|
+
default: () => undefined
|
85
|
+
},
|
86
|
+
collapsedButtonRender: {
|
87
|
+
type: [ Function, Object, Boolean ] as PropType<WithFalse<(collapsed?: boolean) => CustomRender>>,
|
88
|
+
default: () => undefined
|
89
|
+
},
|
90
|
+
breakpoint: {
|
91
|
+
type: [ Object, Boolean ] as PropType<SiderProps['breakpoint'] | false>,
|
92
|
+
default: () => false
|
93
|
+
},
|
94
|
+
isMobile: PropTypes.looseBool,
|
95
|
+
matchMenuKeys: {
|
96
|
+
type: Array as PropType<string[]>,
|
97
|
+
default: () => []
|
98
|
+
},
|
99
|
+
|
100
|
+
// events
|
101
|
+
onMenuHeaderClick: PropTypes.func,
|
102
|
+
onMenuClick: PropTypes.func,
|
103
|
+
onCollapse: {
|
104
|
+
type: Function as PropType<(collapsed: boolean) => void>
|
105
|
+
},
|
106
|
+
onOpenKeys: {
|
107
|
+
type: Function as PropType<(openKeys: WithFalse<string[]>) => void>
|
108
|
+
},
|
109
|
+
onSelect: {
|
110
|
+
type: Function as PropType<(selectedKeys: WithFalse<string[]>) => void>
|
111
|
+
}
|
112
|
+
}
|