@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.
Files changed (256) hide show
  1. package/package.json +1 -1
  2. package/src/main.js +1 -0
  3. package/template-design-pro/.editorconfig +19 -0
  4. package/template-design-pro/.env +2 -0
  5. package/template-design-pro/.env.development +18 -0
  6. package/template-design-pro/.env.pro +32 -0
  7. package/template-design-pro/.env.production +32 -0
  8. package/template-design-pro/.env.test +20 -0
  9. package/template-design-pro/.eslintignore +16 -0
  10. package/template-design-pro/.eslintrc.js +64 -0
  11. package/template-design-pro/.gitpod.yml +6 -0
  12. package/template-design-pro/.husky/pre-commit +4 -0
  13. package/template-design-pro/.prettierignore +9 -0
  14. package/template-design-pro/.stylelintignore +3 -0
  15. package/template-design-pro/.yarnclean +48 -0
  16. package/template-design-pro/LICENSE +21 -0
  17. package/template-design-pro/README.md +111 -0
  18. package/template-design-pro/build/constant.ts +6 -0
  19. package/template-design-pro/build/generate/generateModifyVars.ts +18 -0
  20. package/template-design-pro/build/getConfigFileName.ts +13 -0
  21. package/template-design-pro/build/script/buildConf.ts +44 -0
  22. package/template-design-pro/build/script/postBuild.ts +25 -0
  23. package/template-design-pro/build/script/reSetRootHtml.ts +20 -0
  24. package/template-design-pro/build/utils.ts +85 -0
  25. package/template-design-pro/build/vite/cdn.ts +7 -0
  26. package/template-design-pro/build/vite/optimizer.ts +22 -0
  27. package/template-design-pro/build/vite/plugin/autoImport.ts +18 -0
  28. package/template-design-pro/build/vite/plugin/compress.ts +35 -0
  29. package/template-design-pro/build/vite/plugin/hmr.ts +25 -0
  30. package/template-design-pro/build/vite/plugin/html.ts +47 -0
  31. package/template-design-pro/build/vite/plugin/index.ts +89 -0
  32. package/template-design-pro/build/vite/plugin/mock.ts +20 -0
  33. package/template-design-pro/build/vite/plugin/pwa.ts +37 -0
  34. package/template-design-pro/build/vite/plugin/styleImport.ts +129 -0
  35. package/template-design-pro/build/vite/plugin/visualizer.ts +17 -0
  36. package/template-design-pro/build/vite/plugin/vite-plugin-antd-theme/index.ts +24 -0
  37. package/template-design-pro/build/vite/plugin/vite-plugin-mock/createMockServer.ts +303 -0
  38. package/template-design-pro/build/vite/plugin/vite-plugin-mock/createProdMockServer.ts +93 -0
  39. package/template-design-pro/build/vite/plugin/vite-plugin-mock/index.ts +68 -0
  40. package/template-design-pro/build/vite/plugin/vite-plugin-mock/types.ts +30 -0
  41. package/template-design-pro/build/vite/plugin/vite-plugin-mock/utils.ts +26 -0
  42. package/template-design-pro/commitlint.config.js +32 -0
  43. package/template-design-pro/config/config.ts +14 -0
  44. package/template-design-pro/config/default/animate.ts +30 -0
  45. package/template-design-pro/config/default/defaultSettings.ts +75 -0
  46. package/template-design-pro/config/default/network.ts +16 -0
  47. package/template-design-pro/config/default/proxy.ts +26 -0
  48. package/template-design-pro/config/default/theme.ts +43 -0
  49. package/template-design-pro/config/default/themeColor.ts +62 -0
  50. package/template-design-pro/index.html +45 -0
  51. package/template-design-pro/jest.config.mjs +36 -0
  52. package/template-design-pro/mock/_createProductionServer.ts +19 -0
  53. package/template-design-pro/mock/_util.ts +55 -0
  54. package/template-design-pro/mock/controller/menu.ts +85 -0
  55. package/template-design-pro/mock/controller/notices.ts +114 -0
  56. package/template-design-pro/mock/system/dict.ts +60 -0
  57. package/template-design-pro/mock/system/user.ts +218 -0
  58. package/template-design-pro/package.json +151 -0
  59. package/template-design-pro/pnpm-lock.yaml +9913 -0
  60. package/template-design-pro/postcss.config.js +5 -0
  61. package/template-design-pro/prettier.config.js +18 -0
  62. package/template-design-pro/public/resource/css/index.css +171 -0
  63. package/template-design-pro/public/resource/img/favicon.ico +0 -0
  64. package/template-design-pro/public/resource/img/logo.png +0 -0
  65. package/template-design-pro/public/resource/img/pro_icon.svg +5 -0
  66. package/template-design-pro/public/resource/img/pwa-192x192.png +0 -0
  67. package/template-design-pro/public/resource/img/pwa-512x512.png +0 -0
  68. package/template-design-pro/src/App.vue +47 -0
  69. package/template-design-pro/src/assets/error_images/403.png +0 -0
  70. package/template-design-pro/src/assets/error_images/404.png +0 -0
  71. package/template-design-pro/src/assets/error_images/cloud.png +0 -0
  72. package/template-design-pro/src/assets/login_images/login_background.svg +69 -0
  73. package/template-design-pro/src/assets/logo.png +0 -0
  74. package/template-design-pro/src/assets/menu_font/iconfont.css +94 -0
  75. package/template-design-pro/src/assets/menu_font/iconfont.eot +0 -0
  76. package/template-design-pro/src/assets/menu_font/iconfont.js +1 -0
  77. package/template-design-pro/src/assets/menu_font/iconfont.json +142 -0
  78. package/template-design-pro/src/assets/menu_font/iconfont.svg +57 -0
  79. package/template-design-pro/src/assets/menu_font/iconfont.ttf +0 -0
  80. package/template-design-pro/src/assets/menu_font/iconfont.woff +0 -0
  81. package/template-design-pro/src/assets/menu_font/iconfont.woff2 +0 -0
  82. package/template-design-pro/src/assets/menu_font/index.less +94 -0
  83. package/template-design-pro/src/common/global.ts +1 -0
  84. package/template-design-pro/src/components/GDesign/ProLayout/BasicLayout.less +80 -0
  85. package/template-design-pro/src/components/GDesign/ProLayout/BasicLayout.tsx +342 -0
  86. package/template-design-pro/src/components/GDesign/ProLayout/PageLoading.tsx +20 -0
  87. package/template-design-pro/src/components/GDesign/ProLayout/RenderTypings.ts +31 -0
  88. package/template-design-pro/src/components/GDesign/ProLayout/RouteContext.tsx +82 -0
  89. package/template-design-pro/src/components/GDesign/ProLayout/WrapContent.tsx +69 -0
  90. package/template-design-pro/src/components/GDesign/ProLayout/components/GlobalFooter/index.tsx +88 -0
  91. package/template-design-pro/src/components/GDesign/ProLayout/components/GlobalHeader/DefaultHeader.tsx +189 -0
  92. package/template-design-pro/src/components/GDesign/ProLayout/components/GlobalHeader/Header.less +8 -0
  93. package/template-design-pro/src/components/GDesign/ProLayout/components/GlobalHeader/index.tsx +105 -0
  94. package/template-design-pro/src/components/GDesign/ProLayout/components/GlobalHeader/props.ts +69 -0
  95. package/template-design-pro/src/components/GDesign/ProLayout/components/GlobalHeader/style.less +144 -0
  96. package/template-design-pro/src/components/GDesign/ProLayout/components/LogoContent/index.tsx +81 -0
  97. package/template-design-pro/src/components/GDesign/ProLayout/components/LogoContent/props.ts +29 -0
  98. package/template-design-pro/src/components/GDesign/ProLayout/components/MultiTab/index.tsx +384 -0
  99. package/template-design-pro/src/components/GDesign/ProLayout/components/MultiTab/props.ts +15 -0
  100. package/template-design-pro/src/components/GDesign/ProLayout/components/MultiTab/style.less +79 -0
  101. package/template-design-pro/src/components/GDesign/ProLayout/components/NoticeIcon/NoticeIcon.tsx +148 -0
  102. package/template-design-pro/src/components/GDesign/ProLayout/components/NoticeIcon/NoticeList.module.less +115 -0
  103. package/template-design-pro/src/components/GDesign/ProLayout/components/NoticeIcon/NoticeList.tsx +154 -0
  104. package/template-design-pro/src/components/GDesign/ProLayout/components/NoticeIcon/index.less +39 -0
  105. package/template-design-pro/src/components/GDesign/ProLayout/components/NoticeIcon/index.tsx +133 -0
  106. package/template-design-pro/src/components/GDesign/ProLayout/components/PageContainer/index.tsx +190 -0
  107. package/template-design-pro/src/components/GDesign/ProLayout/components/PageContainer/props.ts +48 -0
  108. package/template-design-pro/src/components/GDesign/ProLayout/components/PageContainer/style.less +128 -0
  109. package/template-design-pro/src/components/GDesign/ProLayout/components/PageContainer/typings.ts +0 -0
  110. package/template-design-pro/src/components/GDesign/ProLayout/components/RightContent/AvatarDropdown.tsx +63 -0
  111. package/template-design-pro/src/components/GDesign/ProLayout/components/RightContent/HeaderSearch.tsx +122 -0
  112. package/template-design-pro/src/components/GDesign/ProLayout/components/RightContent/headerSearch.less +30 -0
  113. package/template-design-pro/src/components/GDesign/ProLayout/components/RightContent/index.tsx +95 -0
  114. package/template-design-pro/src/components/GDesign/ProLayout/components/RightContent/style.less +90 -0
  115. package/template-design-pro/src/components/GDesign/ProLayout/components/SettingDrawer/BlockCheckbox.tsx +70 -0
  116. package/template-design-pro/src/components/GDesign/ProLayout/components/SettingDrawer/LayoutSetting.tsx +107 -0
  117. package/template-design-pro/src/components/GDesign/ProLayout/components/SettingDrawer/ThemeColor.tsx +68 -0
  118. package/template-design-pro/src/components/GDesign/ProLayout/components/SettingDrawer/index.tsx +346 -0
  119. package/template-design-pro/src/components/GDesign/ProLayout/components/SiderMenu/BaseMenu.tsx +224 -0
  120. package/template-design-pro/src/components/GDesign/ProLayout/components/SiderMenu/SiderMenu.tsx +224 -0
  121. package/template-design-pro/src/components/GDesign/ProLayout/components/SiderMenu/index.tsx +43 -0
  122. package/template-design-pro/src/components/GDesign/ProLayout/components/SiderMenu/props.ts +112 -0
  123. package/template-design-pro/src/components/GDesign/ProLayout/components/SiderMenu/style.less +262 -0
  124. package/template-design-pro/src/components/GDesign/ProLayout/components/SiderMenu/typings.ts +44 -0
  125. package/template-design-pro/src/components/GDesign/ProLayout/default.less +2 -0
  126. package/template-design-pro/src/components/GDesign/ProLayout/defaultSettings.ts +121 -0
  127. package/template-design-pro/src/components/GDesign/ProLayout/hooks/context/index.ts +45 -0
  128. package/template-design-pro/src/components/GDesign/ProLayout/index.ts +43 -0
  129. package/template-design-pro/src/components/GDesign/ProLayout/props.ts +57 -0
  130. package/template-design-pro/src/components/GDesign/ProLayout/style.less +272 -0
  131. package/template-design-pro/src/components/GDesign/ProLayout/typings.ts +1 -0
  132. package/template-design-pro/src/components/GDesign/ProLayout/utils/getMenuData.ts +31 -0
  133. package/template-design-pro/src/components/GDesign/ProLayout/utils/index.ts +94 -0
  134. package/template-design-pro/src/components/GDesign/ProLayout/utils/isImg/index.ts +6 -0
  135. package/template-design-pro/src/components/GDesign/ProLayout/utils/isUrl/index.ts +5 -0
  136. package/template-design-pro/src/components/GDesign/Result/index.tsx +142 -0
  137. package/template-design-pro/src/components/GDesign/Result/style.less +140 -0
  138. package/template-design-pro/src/components/GDesign/Scrollbars/components/Bar/index.tsx +56 -0
  139. package/template-design-pro/src/components/GDesign/Scrollbars/components/Bar/props.ts +23 -0
  140. package/template-design-pro/src/components/GDesign/Scrollbars/components/Thumb/index.tsx +164 -0
  141. package/template-design-pro/src/components/GDesign/Scrollbars/components/Thumb/props.ts +11 -0
  142. package/template-design-pro/src/components/GDesign/Scrollbars/context.ts +10 -0
  143. package/template-design-pro/src/components/GDesign/Scrollbars/index.tsx +200 -0
  144. package/template-design-pro/src/components/GDesign/Scrollbars/props.ts +65 -0
  145. package/template-design-pro/src/components/GDesign/Scrollbars/style.less +85 -0
  146. package/template-design-pro/src/components/GDesign/Scrollbars/util.ts +40 -0
  147. package/template-design-pro/src/components/GDesign/utils/index.ts +7 -0
  148. package/template-design-pro/src/components/PageLoading/index.tsx +44 -0
  149. package/template-design-pro/src/components/PageTransition/index.vue +98 -0
  150. package/template-design-pro/src/components/index.ts +6 -0
  151. package/template-design-pro/src/core/ant-design/index.ts +14 -0
  152. package/template-design-pro/src/core/gx-admin-design/index.ts +7 -0
  153. package/template-design-pro/src/core/gx-admin-directives/index.ts +8 -0
  154. package/template-design-pro/src/core/gx-admin-directives/permission.ts +28 -0
  155. package/template-design-pro/src/core/gx-design/index.ts +7 -0
  156. package/template-design-pro/src/core/gx-pro-design/index.ts +10 -0
  157. package/template-design-pro/src/core/index.ts +27 -0
  158. package/template-design-pro/src/design/ant-design/index.less +4 -0
  159. package/template-design-pro/src/design/ant-design/layout.less +29 -0
  160. package/template-design-pro/src/design/ant-design/menu.less +55 -0
  161. package/template-design-pro/src/design/ant-design/table.less +67 -0
  162. package/template-design-pro/src/design/ant-design/tooltip.less +13 -0
  163. package/template-design-pro/src/design/color.less +1 -0
  164. package/template-design-pro/src/design/config.less +5 -0
  165. package/template-design-pro/src/design/index.less +41 -0
  166. package/template-design-pro/src/design/mixin.less +66 -0
  167. package/template-design-pro/src/design/normalize.less +390 -0
  168. package/template-design-pro/src/global.less +15 -0
  169. package/template-design-pro/src/hooks/core/index.ts +3 -0
  170. package/template-design-pro/src/hooks/core/useRequest/index.ts +70 -0
  171. package/template-design-pro/src/hooks/core/useRequest/typings.ts +0 -0
  172. package/template-design-pro/src/hooks/event/index.ts +3 -0
  173. package/template-design-pro/src/hooks/event/useClipboard.ts +14 -0
  174. package/template-design-pro/src/hooks/system/index.ts +5 -0
  175. package/template-design-pro/src/hooks/system/useDict.ts +62 -0
  176. package/template-design-pro/src/hooks/system/usePermissions.ts +39 -0
  177. package/template-design-pro/src/hooks/typings.ts +17 -0
  178. package/template-design-pro/src/layout/BasicLayout.vue +104 -0
  179. package/template-design-pro/src/layout/BlankLayout.vue +5 -0
  180. package/template-design-pro/src/layout/ContentView.vue +76 -0
  181. package/template-design-pro/src/layout/IframeView.vue +1 -0
  182. package/template-design-pro/src/layout/UserLayout.vue +7 -0
  183. package/template-design-pro/src/main.ts +34 -0
  184. package/template-design-pro/src/plugins/index.ts +3 -0
  185. package/template-design-pro/src/router/guard/index.ts +84 -0
  186. package/template-design-pro/src/router/guard/permissions.ts +73 -0
  187. package/template-design-pro/src/router/guard/stateGuard.ts +11 -0
  188. package/template-design-pro/src/router/helper/routeHelper.ts +244 -0
  189. package/template-design-pro/src/router/helper/utils.ts +19 -0
  190. package/template-design-pro/src/router/index.ts +30 -0
  191. package/template-design-pro/src/router/routes/index.ts +85 -0
  192. package/template-design-pro/src/router/routes/modules/workplace.ts +19 -0
  193. package/template-design-pro/src/services/common/index.ts +11 -0
  194. package/template-design-pro/src/services/controller/router.ts +10 -0
  195. package/template-design-pro/src/services/controller/user.ts +35 -0
  196. package/template-design-pro/src/services/system/dictData.ts +10 -0
  197. package/template-design-pro/src/services/system/notices.ts +9 -0
  198. package/template-design-pro/src/store/index.ts +32 -0
  199. package/template-design-pro/src/store/modules/dict.ts +27 -0
  200. package/template-design-pro/src/store/modules/permission.ts +19 -0
  201. package/template-design-pro/src/store/modules/routes.ts +110 -0
  202. package/template-design-pro/src/store/modules/settings.ts +102 -0
  203. package/template-design-pro/src/store/modules/tabsRouter.ts +73 -0
  204. package/template-design-pro/src/store/modules/user.ts +153 -0
  205. package/template-design-pro/src/utils/accessToken.ts +93 -0
  206. package/template-design-pro/src/utils/crypto.ts +39 -0
  207. package/template-design-pro/src/utils/env.ts +52 -0
  208. package/template-design-pro/src/utils/fetchFile.ts +79 -0
  209. package/template-design-pro/src/utils/index.ts +127 -0
  210. package/template-design-pro/src/utils/pageTitle.ts +17 -0
  211. package/template-design-pro/src/utils/request/XHR.ts +131 -0
  212. package/template-design-pro/src/utils/request/axiosCancel.ts +60 -0
  213. package/template-design-pro/src/utils/request/checkStatus.ts +26 -0
  214. package/template-design-pro/src/utils/request/index.ts +145 -0
  215. package/template-design-pro/src/utils/request/typings.ts +114 -0
  216. package/template-design-pro/src/utils/storage.ts +194 -0
  217. package/template-design-pro/src/utils/uploadFile.ts +26 -0
  218. package/template-design-pro/src/utils/util.ts +278 -0
  219. package/template-design-pro/src/utils/validate.ts +221 -0
  220. package/template-design-pro/src/views/Iframe/index.vue +76 -0
  221. package/template-design-pro/src/views/MenuOne/index.vue +15 -0
  222. package/template-design-pro/src/views/MenuTwo/index.vue +13 -0
  223. package/template-design-pro/src/views/exception/403/index.vue +9 -0
  224. package/template-design-pro/src/views/exception/404/index.vue +9 -0
  225. package/template-design-pro/src/views/user/login/index.vue +110 -0
  226. package/template-design-pro/src/views/user/login/style.less +38 -0
  227. package/template-design-pro/stylelint.config.js +106 -0
  228. package/template-design-pro/tests/__mocks__/fileMock.ts +1 -0
  229. package/template-design-pro/tests/__mocks__/styleMock.ts +1 -0
  230. package/template-design-pro/tests/__mocks__/workerMock.ts +5 -0
  231. package/template-design-pro/tests/server/README.md +15 -0
  232. package/template-design-pro/tests/server/controller/FileController.ts +18 -0
  233. package/template-design-pro/tests/server/controller/UserController.ts +15 -0
  234. package/template-design-pro/tests/server/ecosystem.config.js +18 -0
  235. package/template-design-pro/tests/server/index.ts +63 -0
  236. package/template-design-pro/tests/server/nodemon.json +8 -0
  237. package/template-design-pro/tests/server/package.json +36 -0
  238. package/template-design-pro/tests/server/routes.ts +23 -0
  239. package/template-design-pro/tests/server/service/FileService.ts +54 -0
  240. package/template-design-pro/tests/server/service/UserService.ts +25 -0
  241. package/template-design-pro/tests/server/tsconfig.json +15 -0
  242. package/template-design-pro/tests/server/utils.ts +9 -0
  243. package/template-design-pro/tests/server/yarn.lock +2955 -0
  244. package/template-design-pro/tests/test.spec.ts +16 -0
  245. package/template-design-pro/tsconfig.json +47 -0
  246. package/template-design-pro/types/auto-imports.d.ts +61 -0
  247. package/template-design-pro/types/config.d.ts +100 -0
  248. package/template-design-pro/types/global.d.ts +103 -0
  249. package/template-design-pro/types/gx-components.d.ts +24 -0
  250. package/template-design-pro/types/index.d.ts +13 -0
  251. package/template-design-pro/types/mock.d.ts +23 -0
  252. package/template-design-pro/types/module.d.ts +16 -0
  253. package/template-design-pro/types/response.d.ts +15 -0
  254. package/template-design-pro/types/route.d.ts +89 -0
  255. package/template-design-pro/vite.config.ts +136 -0
  256. package/template-design-pro/yarn.lock +9697 -0
@@ -0,0 +1,104 @@
1
+ <template>
2
+ <g-pro-layout
3
+ v-model:collapsed="baseState.collapsed"
4
+ v-model:selectedKeys="baseState.selectedKeys"
5
+ v-model:openKeys="baseState.openKeys"
6
+ v-bind="state"
7
+ :breadcrumb="{ routes: baseState.breadcrumb }"
8
+ @reloadPage="handleReloadPage"
9
+ @handleCollapse="toggleCollapse"
10
+ @menuHeaderClick="menuHeaderClick"
11
+ >
12
+ <template v-if="store.settings.layout === 'wide'" #menuExtraRender>
13
+ <div class="text-center"> 额外元素 </div>
14
+ </template>
15
+ <ProContent :animate="state.animate" :isRouterAlive="isRouterAlive" />
16
+ </g-pro-layout>
17
+ </template>
18
+ <script setup lang="ts">
19
+ import { computed, reactive } from 'vue'
20
+ import { cloneDeep } from 'lodash-es'
21
+ import { useStore } from '@gx-vuex'
22
+ import { RouteContextProps, getMenuData, clearMenuItem } from '@gx-design/ProLayout'
23
+ import config from '/config/config'
24
+ import ProContent from './ContentView.vue'
25
+
26
+ const { animate } = config
27
+ const { preset } = animate
28
+
29
+ const store = useStore()
30
+ const router = useRouter()
31
+
32
+ const isRouterAlive = ref(true)
33
+ const routeData: AppRouteModule[] = router.getRoutes() as any
34
+
35
+ const { menuData } = getMenuData(clearMenuItem(routeData))
36
+
37
+ const baseState = reactive<Omit<RouteContextProps, 'menuData'>>({
38
+ breadcrumb: [],
39
+ selectedKeys: [],
40
+ openKeys: [],
41
+ collapsed: false
42
+ })
43
+
44
+ const state = reactive({
45
+ menuData,
46
+ logoDirection: 'vertical',
47
+ loading: computed(() => store.routes.routerLoading),
48
+ layout: computed(() => store.settings.layout),
49
+ theme: computed(() => store.settings.theme),
50
+ splitMenus: computed(() => store.settings.splitMenus),
51
+ primaryColor: computed(() => store.settings.primaryColor),
52
+ fixedMultiTab: computed(() => store.settings.fixedMultiTab),
53
+ fixedHeader: computed(() => store.settings.fixedHeader),
54
+ fixSiderbar: computed(() => store.settings.fixSiderbar),
55
+ showTabsBar: computed(() => store.settings.showTabsBar),
56
+ autoHideHeader: computed(() => store.settings.autoHideHeader),
57
+ showProgressBar: computed(() => store.settings.showProgressBar),
58
+ animate: computed(() => store.settings.animate)
59
+ })
60
+
61
+ watch(
62
+ () => router.currentRoute,
63
+ () => {
64
+ const matched = router.currentRoute.value.matched.concat()
65
+ const breadcrumb = matched.map((item) => {
66
+ return {
67
+ path: item.path,
68
+ breadcrumbName: item.meta.title || ''
69
+ }
70
+ })
71
+ baseState.breadcrumb = cloneDeep(breadcrumb)
72
+ },
73
+ {
74
+ deep: true,
75
+ immediate: true
76
+ }
77
+ )
78
+
79
+ watchEffect(() => {
80
+ if (router.currentRoute) {
81
+ const matched = router.currentRoute.value.matched.concat()
82
+ baseState.selectedKeys = matched.filter((r) => r.name !== 'index').map((r) => r.path)
83
+ baseState.openKeys = matched
84
+ .filter((r) => r.path !== router.currentRoute.value.path)
85
+ .map((r) => r.path)
86
+ }
87
+ })
88
+
89
+ const handleReloadPage = () => {
90
+ isRouterAlive.value = false
91
+ nextTick(() => {
92
+ isRouterAlive.value = true
93
+ })
94
+ }
95
+
96
+ const toggleCollapse = () => {
97
+ store.settings.toggleCollapse()
98
+ }
99
+ const menuHeaderClick = () => {
100
+ router.push('/')
101
+ }
102
+
103
+ provide('reloadPage', handleReloadPage)
104
+ </script>
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <router-view v-slot="{ Component }">
3
+ <component :is="Component" />
4
+ </router-view>
5
+ </template>
@@ -0,0 +1,76 @@
1
+ <template>
2
+ <router-view>
3
+ <template #default="{ route, Component }">
4
+ <page-transition
5
+ :disabled="animate.disabled"
6
+ :animate="animate.name"
7
+ :direction="animate.direction"
8
+ >
9
+ <template v-if="isRouterAlive">
10
+ <keep-alive v-if="keepAlive">
11
+ <component :is="Component" :key="route.fullPath" />
12
+ </keep-alive>
13
+ <component v-else :is="Component" :key="route.fullPath" />
14
+ </template>
15
+ </page-transition>
16
+ </template>
17
+ </router-view>
18
+ <IframeView v-if="iframeSrc" :frameSrc="iframeSrc" />
19
+ </template>
20
+
21
+ <script setup lang="ts">
22
+ import { computed } from 'vue'
23
+ import { useRoute, useRouter } from 'vue-router'
24
+ import { useStore } from '@gx-vuex'
25
+ import PageTransition from '@/components/PageTransition/index.vue'
26
+ import IframeView from '../views/Iframe/index.vue'
27
+
28
+ defineProps({
29
+ isRouterAlive: {
30
+ type: Boolean,
31
+ required: false,
32
+ default: true
33
+ },
34
+ contentStyle: {
35
+ type: Object,
36
+ required: false,
37
+ default: () => {
38
+ return {}
39
+ }
40
+ },
41
+ animate: {
42
+ type: Object,
43
+ required: false,
44
+ default: () => {
45
+ return {}
46
+ }
47
+ }
48
+ })
49
+
50
+ const route = useRoute()
51
+ const store = useStore()
52
+ const router = useRouter()
53
+
54
+ const keepAlive = ref(false)
55
+
56
+ const iframeSrc = computed(() => {
57
+ const meta = router.currentRoute.value?.meta
58
+ return meta?.target && Number(meta?.targetStatus) === 0 ? meta?.target : ''
59
+ })
60
+
61
+ watch(
62
+ () => route,
63
+ () => {
64
+ const { meta }: { meta: Meta } = route
65
+ if (!store.settings.showTabsBar && !meta.keepAlive) {
66
+ keepAlive.value = false
67
+ } else {
68
+ keepAlive.value = store.settings.keepAlive || store.settings.showTabsBar || meta.keepAlive
69
+ }
70
+ },
71
+ {
72
+ deep: true,
73
+ immediate: true
74
+ }
75
+ )
76
+ </script>
@@ -0,0 +1 @@
1
+ <template></template>
@@ -0,0 +1,7 @@
1
+ <template>
2
+ <div id="gx-user-layout">
3
+ <router-view v-slot="{ Component }">
4
+ <component :is="Component" />
5
+ </router-view>
6
+ </div>
7
+ </template>
@@ -0,0 +1,34 @@
1
+ import { createApp } from 'vue'
2
+
3
+ import { router, setupRouter } from '@/router'
4
+ import { setupRouterGuard } from '@/router/guard'
5
+
6
+ import App from './App.vue'
7
+ import { setupStore } from './store'
8
+ import { setupGlobCommon } from './core'
9
+
10
+ import 'uno.css'
11
+
12
+ import 'animate.css/source/animate.css'
13
+ import './global.less'
14
+
15
+ import './plugins'
16
+
17
+ function startApp() {
18
+ const app = createApp(App)
19
+
20
+ // 配置store
21
+ setupStore(app)
22
+
23
+ setupGlobCommon(app)
24
+
25
+ // 配置路由
26
+ setupRouter(app)
27
+
28
+ // 路由守卫
29
+ setupRouterGuard(router)
30
+
31
+ app.mount('#app')
32
+ }
33
+
34
+ startApp()
@@ -0,0 +1,3 @@
1
+ // 加载插件
2
+ import.meta.glob('./*.ts', { eager: true })
3
+
@@ -0,0 +1,84 @@
1
+ import type { Router } from 'vue-router'
2
+ import NProgress from 'nprogress'
3
+ import config from '/config/config'
4
+ import { useStoreRoutes, useStoreSettings } from '@gx-vuex'
5
+ import getPageTitle from '@/utils/pageTitle'
6
+ import { scrollToContainer } from '@/utils/util'
7
+ import { createStateGuard } from './stateGuard'
8
+ import { createPermissionGuard } from './permissions'
9
+
10
+ const {
11
+ routerLoadTime,
12
+ routesWhiteList
13
+ } = config.defaultSettings
14
+
15
+ export function setupRouterGuard(router: Router) {
16
+ createPageGuard(router)
17
+ createPageLoadingGuard(router)
18
+ createScrollGuard(router)
19
+ createProgressGuard(router)
20
+ createPermissionGuard(router)
21
+ createStateGuard(router)
22
+ }
23
+
24
+ export function createPageGuard(router: Router) {
25
+ const routes = useStoreRoutes()
26
+ const settings = useStoreSettings()
27
+
28
+ router.afterEach((to) => {
29
+ const { meta }: any = to
30
+ document.title = getPageTitle(meta.title || '')
31
+ if (
32
+ settings.layout !== 'wide' &&
33
+ routes.routerLoadList.every(item => item !== to.path) &&
34
+ routesWhiteList.indexOf(to.path) === -1
35
+ ) {
36
+ routes.addRouterLoadList(to.path)
37
+ }
38
+ })
39
+ }
40
+
41
+ export function createPageLoadingGuard(router: Router) {
42
+ const routes = useStoreRoutes()
43
+ const settings = useStoreSettings()
44
+
45
+ router.beforeEach(async (to) => {
46
+ if (
47
+ settings.layout !== 'wide' &&
48
+ routes.routerLoadList.every(item => item !== to.path) &&
49
+ routesWhiteList.indexOf(to.path) === -1
50
+ ) {
51
+ routes.changeValue('routerLoading', true)
52
+ }
53
+
54
+ return true
55
+ })
56
+
57
+ router.afterEach((_) => {
58
+ if (settings.layout === 'wide') {
59
+ routes.changeValue('routerLoading', false)
60
+ } else {
61
+ setTimeout(() => {
62
+ routes.changeValue('routerLoading', false)
63
+ }, routerLoadTime || 200)
64
+ }
65
+ })
66
+ }
67
+
68
+ export function createScrollGuard(router: Router) {
69
+ router.afterEach((_) => {
70
+ scrollToContainer(0)
71
+ })
72
+ }
73
+
74
+ export function createProgressGuard(router: Router) {
75
+ const settings = useStoreSettings()
76
+ router.beforeEach(() => {
77
+ if (settings.showProgressBar) NProgress.start()
78
+ return true
79
+ })
80
+
81
+ router.afterEach(() => {
82
+ NProgress.done()
83
+ })
84
+ }
@@ -0,0 +1,73 @@
1
+ import type { Router, RouteRecordRaw } from 'vue-router'
2
+ import config from '/config/config'
3
+ import { useStoreUser, useStoreRoutes, useStorePermission } from '@gx-vuex'
4
+
5
+ const {
6
+ authentication,
7
+ loginInterception,
8
+ recordRoute,
9
+ routesWhiteList
10
+ } = config.defaultSettings
11
+
12
+ export function createPermissionGuard(router: Router) {
13
+ const userStore = useStoreUser()
14
+ const routeStore = useStoreRoutes()
15
+ const permissionStore = useStorePermission()
16
+
17
+ router.beforeEach(async (to, _, next) => {
18
+ const token = loginInterception || userStore.accessToken
19
+
20
+ if (routesWhiteList.includes(to.path)) {
21
+ if ((to.path === '/') && token) {
22
+ next({ path: '/', replace: true })
23
+ }
24
+ next()
25
+ return
26
+ }
27
+
28
+ if (!token) {
29
+ userStore.resetPermissions()
30
+ if (recordRoute) {
31
+ next({ path: '/user/login', query: { redirect: to.path }, replace: true })
32
+ } else {
33
+ next({ path: '/user/login', replace: true })
34
+ }
35
+ return
36
+ }
37
+
38
+ const hasRoles = permissionStore.role.length > 0
39
+
40
+ if (hasRoles) {
41
+ next()
42
+ return
43
+ }
44
+
45
+ const userInfo = loginInterception
46
+ ? await userStore.queryUserInfo() : await userStore.setVirtualRoles()
47
+
48
+ if (!userInfo) {
49
+ userStore.resetPermissions()
50
+ if (recordRoute) {
51
+ next({ path: '/user/login', query: { redirect: to.path }, replace: true })
52
+ } else {
53
+ next({ path: '/user/login', replace: true })
54
+ }
55
+ return
56
+ }
57
+
58
+ const routes = authentication === 'all'
59
+ ? await routeStore.setAllRoutes()
60
+ : await routeStore.setRoutes()
61
+
62
+ routeStore.changeValue('meunLoading', false)
63
+
64
+ if (routes?.length) {
65
+ routes.forEach((route) => {
66
+ router.addRoute(route as RouteRecordRaw)
67
+ })
68
+ next({ path: to.fullPath, replace: true })
69
+ return
70
+ }
71
+ next({ path: '/exception/403', replace: true })
72
+ })
73
+ }
@@ -0,0 +1,11 @@
1
+ import type { Router } from 'vue-router'
2
+ import { useStoreUser } from '@gx-vuex'
3
+
4
+ export function createStateGuard(router: Router) {
5
+ router.afterEach((to) => {
6
+ const user = useStoreUser()
7
+ if (to.path === '/user/login') {
8
+ user.resetPermissions()
9
+ }
10
+ })
11
+ }
@@ -0,0 +1,244 @@
1
+ import { cloneDeep } from 'lodash-es'
2
+ import { warning } from '@gx-design/utils'
3
+ import { getMaxFloor } from '@gx-design-vue/pro-utils'
4
+
5
+ /**
6
+ * @description: default layout
7
+ */
8
+ export const BasicLayout = () => import('@/layout/BasicLayout.vue')
9
+ export const IframeView = () => import('@/layout/IframeView.vue')
10
+ export const EXCEPTION_COMPONENT = () => import('@/views/exception/404/index.vue')
11
+
12
+ const LayoutMap = new Map<string, () => Promise<typeof import('*.vue')>>()
13
+
14
+ LayoutMap.set('BasicLayout', BasicLayout)
15
+ LayoutMap.set('IframeView', IframeView)
16
+
17
+ let dynamicViewsModules: Record<string, () => Promise<Recordable>>
18
+
19
+ /**
20
+ * @Author gx12358
21
+ * @DateTime 2021/5/14
22
+ * @lastTime 2021/5/14
23
+ * @description 根路由
24
+ */
25
+ const rootRouter: MenuDataItem[] = buildMenu([
26
+ {
27
+ path: '/',
28
+ name: 'index',
29
+ meta: { title: '首页' },
30
+ component: 'BasicLayout',
31
+ redirect: '',
32
+ children: []
33
+ }
34
+ ])
35
+
36
+ // Dynamic introduction
37
+ function asyncImportRoute(component: string) {
38
+ dynamicViewsModules = dynamicViewsModules || import.meta.glob('../../views/**/*.{vue,tsx}')
39
+ return dynamicImport(dynamicViewsModules, component)
40
+ }
41
+
42
+ function dynamicImport(
43
+ dynamicViewsModules: Record<string, () => Promise<Recordable>>,
44
+ component: string
45
+ ) {
46
+ const keys = Object.keys(dynamicViewsModules)
47
+ const matchKeys = keys.filter((key) => {
48
+ const k = key.replace('../../views', '')
49
+ if (!component) return false
50
+ const startFlag = component.startsWith('/')
51
+ const endFlag = component.endsWith('.vue') || component.endsWith('.tsx')
52
+ const startIndex = startFlag ? 0 : 1
53
+ const lastIndex = endFlag ? k.length : k.lastIndexOf('.')
54
+ return k.substring(startIndex, lastIndex) === component
55
+ })
56
+ if (matchKeys?.length === 1) {
57
+ const matchKey = matchKeys[0]
58
+ return dynamicViewsModules[matchKey]
59
+ } else if (matchKeys?.length > 1) {
60
+ warning(
61
+ true,
62
+ '请不要在views文件夹下的同一层次目录中创建具有相同文件名的“.vue”和“.TSX”文件。这将导致动态导入失败'
63
+ )
64
+ return
65
+ } else {
66
+ warning(true, '在src/views/下找不到`' + component + '.vue` 或 `' + component + '.tsx`, 请自行创建!')
67
+ return EXCEPTION_COMPONENT
68
+ }
69
+ }
70
+
71
+ /**
72
+ * @Author gx12358
73
+ * @DateTime 2021/5/14
74
+ * @lastTime 2021/5/14
75
+ * @description 将后台树形数据菜单和本地菜单结合
76
+ */
77
+ export function getRootMenu(rows: MenuDataItem[]): MenuDataItem[] {
78
+ let menus: MenuDataItem[] = []
79
+ if (getMaxFloor(cloneDeep(rows)) > 1) {
80
+ menus = buildMenu(rows)
81
+ } else {
82
+ buildtree(rows, menus, 0)
83
+ }
84
+ rootRouter[0].children = menus
85
+ rootRouter[0].children.push({
86
+ key: 'externalLink',
87
+ path: '/externalLink',
88
+ meta: {
89
+ title: '外链地址'
90
+ },
91
+ hidden: true
92
+ } as MenuDataItem)
93
+ return cloneDeep(rootRouter)
94
+ }
95
+
96
+ /**
97
+ * @Author gx12358
98
+ * @DateTime 2021/5/14
99
+ * @lastTime 2021/5/14
100
+ * @description 格式化 后端 结构信息并递归生成层级路由表
101
+ */
102
+ export const generator = (routerMap: MenuDataItem[], parent?) => {
103
+ return routerMap.map((item: any) => {
104
+ const currentRouter: AppRouteModule = {
105
+ // 路由地址 动态拼接生成如 /dashboard/workplace
106
+ path: parent && parent.path
107
+ ? `${parent.path === '/'
108
+ ? ''
109
+ : (parent.path || '')}/${item.path}`
110
+ : `/${item.path}`,
111
+ // 路由名称,建议唯一
112
+ name: item.name || '',
113
+ // 该路由对应页面的 组件 优先根据组件名或者key从constantRouterComponents获取,没有则通过组件名地址查询
114
+ component: item.menuType === 'M' ? undefined : (
115
+ LayoutMap.get(item.component || item.key) ||
116
+ asyncImportRoute(item.component)
117
+ ),
118
+ // meta: 页面标题, 菜单图标, 页面权限(供指令权限用,可去掉)
119
+ meta: {
120
+ title: item.title || '',
121
+ tagFixed: item.tagFixed,
122
+ tagHidden: item.tagHidden,
123
+ icon: item.icon || undefined,
124
+ homePage: item.homePage || 0,
125
+ iconType: item.iconType || undefined,
126
+ hideInMenu: item.hidden || false,
127
+ target: item.target,
128
+ targetStatus: item.targetStatus
129
+ }
130
+ }
131
+ // 为了防止出现后端返回结果不规范,处理有可能出现拼接出两个 反斜杠
132
+ if (!currentRouter.path.startsWith('http')) {
133
+ currentRouter.path = currentRouter.path.replace('//', '/')
134
+ }
135
+ // 重定向
136
+ item.redirect && (currentRouter.redirect = item.redirect)
137
+ // 是否有子菜单,并递归处理
138
+ if (item.children && item.children.length > 0) {
139
+ // Recursion
140
+ currentRouter.children = generator(item.children, currentRouter)
141
+ }
142
+ return currentRouter
143
+ })
144
+ }
145
+
146
+ /**
147
+ * @Author gx12358
148
+ * @DateTime 2021/5/14
149
+ * @lastTime 2021/5/14
150
+ * @description 将后台树形结构菜单数据添加后修改属性(具体修改看后台返回值)
151
+ */
152
+ export function buildMenu(list: MenuDataItem[]) {
153
+ return list.map((item: MenuDataItem) => {
154
+ const {
155
+ title = '',
156
+ menuType,
157
+ icon = '',
158
+ iconType = 1, //菜单图标类型 0:本地 1:自定义 2:图片
159
+ tagFixed = '1', //标签栏固定状态(标签栏路由地址是否固定(只有标签栏为显示转态才生效))0:是 1:否
160
+ tagHidden = '0', //标签栏显示状态(隐藏的路由是否显示在标签栏中(只有标签栏为显示转态才生效))0:显示 1:隐藏
161
+ homePageFlag = 0, //是否为主页(选择后为登录后跳转改地址,不选择默认跳转 /)0:否 1:是
162
+ isFrame = '1', //是否外链 0:是 1:否
163
+ outLinkType = 0 //外链类型(选择是系统内则以iframe形式在系统内部展示,否则跳转新页面打开) 0:系统内 1:系统外
164
+ } = item.meta ?? item
165
+ const child = {
166
+ title,
167
+ level: 'tree',
168
+ name: item.name || title,
169
+ key: item.name || title,
170
+ icon,
171
+ menuType,
172
+ iconType: iconType || 1,
173
+ hidden: !!item.hidden,
174
+ homePage: homePageFlag,
175
+ path: item.path && item.path.length > 0
176
+ ? item.path
177
+ : undefined,
178
+ component: item.component,
179
+ redirect: item.redirect === 'noRedirect'
180
+ ? ''
181
+ : item.redirect,
182
+ tagFixed: tagFixed === '0',
183
+ tagHidden: tagHidden === '1',
184
+ target: isFrame === '0' ? item.target : '',
185
+ targetStatus: outLinkType || 0,
186
+ children: item.children && item.children.length > 0
187
+ ? buildMenu(item.children)
188
+ : []
189
+ }
190
+ return child
191
+ })
192
+ }
193
+
194
+ /**
195
+ * @Author gx12358
196
+ * @DateTime 2021/5/14
197
+ * @lastTime 2021/5/14
198
+ * @description 将后台菜单数据变成树形结构(具体修改看后台返回值)
199
+ */
200
+ export function buildtree(list: MenuDataItem[], arr: MenuDataItem[], parentId: string | number) {
201
+ list.forEach((item: MenuDataItem) => {
202
+ const {
203
+ title = '',
204
+ icon = '',
205
+ menuType,
206
+ iconType = 1, //菜单图标类型 0:本地 1:自定义 2:图片
207
+ tagFixed = '1', //标签栏固定状态(标签栏路由地址是否固定(只有标签栏为显示转态才生效))0:是 1:否
208
+ tagHidden = '0', //标签栏显示状态(隐藏的路由是否显示在标签栏中(只有标签栏为显示转态才生效))0:显示 1:隐藏
209
+ homePageFlag = 0, //是否为主页(选择后为登录后跳转改地址,不选择默认跳转 /)0:否 1:是
210
+ isFrame = '1', //是否外链 0:是 1:否
211
+ outLinkType = 0 //外链类型(选择是系统内则以iframe形式在系统内部展示,否则跳转新页面打开) 0:系统内 1:系统外
212
+ } = item.meta ?? item
213
+ if (item.parentId === parentId) {
214
+ const child: any = {
215
+ level: 'flat',
216
+ title,
217
+ name: item.name || title,
218
+ key: item.name || title,
219
+ icon,
220
+ menuType,
221
+ iconType,
222
+ hidden: item.hidden,
223
+ homePage: homePageFlag,
224
+ path: item.path && item.path.length > 0
225
+ ? item.path
226
+ : undefined,
227
+ component: item.component,
228
+ redirect: item.redirect === 'noRedirect'
229
+ ? ''
230
+ : item.redirect,
231
+ tagFixed: tagFixed === '0',
232
+ tagHidden: tagHidden === '1',
233
+ target: isFrame === '0' ? item.target : '',
234
+ targetStatus: outLinkType || 0,
235
+ children: []
236
+ }
237
+ buildtree(list, child.children, item.menuId)
238
+ if (child.children.length === 0) {
239
+ delete child.children
240
+ }
241
+ arr.push(child)
242
+ }
243
+ })
244
+ }
@@ -0,0 +1,19 @@
1
+ export function getFirstLastChild(data: any[]) {
2
+ let newPath
3
+ // 获取第一个children的path
4
+ const getRoutePath = function (newdata) {
5
+ let firstPath = ''
6
+ if (newdata.children && newdata.children.length > 0) {
7
+ firstPath = getRoutePath(newdata.children[0])
8
+ } else {
9
+ firstPath = `${newdata.path}`
10
+ }
11
+ return firstPath
12
+ }
13
+ if (data[0].children && data[0].children.length > 0) {
14
+ newPath = getRoutePath(data[0].children[0])
15
+ } else {
16
+ newPath = data[0].path
17
+ }
18
+ return newPath
19
+ }