@gx-design-vue/create-gx-cli 0.1.12 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. package/bin/create-gx-cli +3 -2
  2. package/package.json +4 -4
  3. package/src/cli.js +9 -7
  4. package/src/git.js +8 -5
  5. package/src/main.js +29 -16
  6. package/template-mobile-vant-cli/package.json +5 -5
  7. package/template-gx-design-thin/.editorconfig +0 -19
  8. package/template-gx-design-thin/.env +0 -4
  9. package/template-gx-design-thin/.env.development +0 -15
  10. package/template-gx-design-thin/.env.production +0 -28
  11. package/template-gx-design-thin/.eslintignore +0 -16
  12. package/template-gx-design-thin/.prettierignore +0 -9
  13. package/template-gx-design-thin/LICENSE +0 -21
  14. package/template-gx-design-thin/README.md +0 -112
  15. package/template-gx-design-thin/build/constant.ts +0 -1
  16. package/template-gx-design-thin/build/generate/generateModifyVars.ts +0 -14
  17. package/template-gx-design-thin/build/rollupOptions/index.ts +0 -22
  18. package/template-gx-design-thin/build/util/hash.ts +0 -17
  19. package/template-gx-design-thin/build/util/index.ts +0 -131
  20. package/template-gx-design-thin/build/vite/cdn.ts +0 -63
  21. package/template-gx-design-thin/build/vite/optimizer.ts +0 -26
  22. package/template-gx-design-thin/build/vite/plugin/appConfig.ts +0 -91
  23. package/template-gx-design-thin/build/vite/plugin/autoImport.ts +0 -26
  24. package/template-gx-design-thin/build/vite/plugin/compress.ts +0 -31
  25. package/template-gx-design-thin/build/vite/plugin/html.ts +0 -39
  26. package/template-gx-design-thin/build/vite/plugin/index.ts +0 -75
  27. package/template-gx-design-thin/build/vite/plugin/mock.ts +0 -14
  28. package/template-gx-design-thin/build/vite/plugin/pwa.ts +0 -31
  29. package/template-gx-design-thin/build/vite/plugin/visualizer.ts +0 -14
  30. package/template-gx-design-thin/build/vite/plugin/viteMock/client.ts +0 -88
  31. package/template-gx-design-thin/build/vite/plugin/viteMock/createMockServer.ts +0 -271
  32. package/template-gx-design-thin/build/vite/plugin/viteMock/index.ts +0 -69
  33. package/template-gx-design-thin/build/vite/plugin/viteMock/types.ts +0 -48
  34. package/template-gx-design-thin/build/vite/plugin/viteMock/utils.ts +0 -48
  35. package/template-gx-design-thin/build/vite/plugin/viteNotice.ts +0 -40
  36. package/template-gx-design-thin/commitlint.config.cjs +0 -32
  37. package/template-gx-design-thin/config/default/defaultSettings.ts +0 -78
  38. package/template-gx-design-thin/config/default/network.ts +0 -10
  39. package/template-gx-design-thin/config/default/proxy.ts +0 -47
  40. package/template-gx-design-thin/config/default/theme.ts +0 -3
  41. package/template-gx-design-thin/config/index.ts +0 -11
  42. package/template-gx-design-thin/eslint.config.js +0 -51
  43. package/template-gx-design-thin/index.html +0 -42
  44. package/template-gx-design-thin/mock/_createProductionServer.ts +0 -19
  45. package/template-gx-design-thin/mock/_util.ts +0 -33
  46. package/template-gx-design-thin/mock/config/menu.ts +0 -21
  47. package/template-gx-design-thin/mock/config/user.ts +0 -123
  48. package/template-gx-design-thin/mock/datasSource/system/menu.ts +0 -10
  49. package/template-gx-design-thin/mock/datasSource/user/account.ts +0 -30
  50. package/template-gx-design-thin/mock/datasSource/user/index.ts +0 -47
  51. package/template-gx-design-thin/mock/util/crypto.ts +0 -23
  52. package/template-gx-design-thin/mock/util/table.ts +0 -92
  53. package/template-gx-design-thin/mock/util/utils.ts +0 -73
  54. package/template-gx-design-thin/package.json +0 -129
  55. package/template-gx-design-thin/pnpm-lock.yaml +0 -12575
  56. package/template-gx-design-thin/prettier.config.cjs +0 -18
  57. package/template-gx-design-thin/public/resource/css/index.css +0 -119
  58. package/template-gx-design-thin/public/resource/css/normalize.css +0 -396
  59. package/template-gx-design-thin/public/resource/img/favicon.ico +0 -0
  60. package/template-gx-design-thin/public/resource/img/logo.png +0 -0
  61. package/template-gx-design-thin/public/resource/img/pro_icon.svg +0 -1
  62. package/template-gx-design-thin/public/resource/img/pwa-192x192.png +0 -0
  63. package/template-gx-design-thin/public/resource/img/pwa-512x512.png +0 -0
  64. package/template-gx-design-thin/src/App.vue +0 -42
  65. package/template-gx-design-thin/src/assets/error_images/403.png +0 -0
  66. package/template-gx-design-thin/src/assets/error_images/404.png +0 -0
  67. package/template-gx-design-thin/src/assets/error_images/cloud.png +0 -0
  68. package/template-gx-design-thin/src/assets/login_images/login_background.svg +0 -1
  69. package/template-gx-design-thin/src/assets/logo.png +0 -0
  70. package/template-gx-design-thin/src/assets/menu_font/iconfont.css +0 -94
  71. package/template-gx-design-thin/src/assets/menu_font/iconfont.eot +0 -0
  72. package/template-gx-design-thin/src/assets/menu_font/iconfont.js +0 -1
  73. package/template-gx-design-thin/src/assets/menu_font/iconfont.json +0 -142
  74. package/template-gx-design-thin/src/assets/menu_font/iconfont.svg +0 -1
  75. package/template-gx-design-thin/src/assets/menu_font/iconfont.ttf +0 -0
  76. package/template-gx-design-thin/src/assets/menu_font/iconfont.woff +0 -0
  77. package/template-gx-design-thin/src/assets/menu_font/iconfont.woff2 +0 -0
  78. package/template-gx-design-thin/src/assets/menu_font/index.less +0 -94
  79. package/template-gx-design-thin/src/assets/public_icon/iconfont.css +0 -42
  80. package/template-gx-design-thin/src/assets/public_icon/iconfont.eot +0 -0
  81. package/template-gx-design-thin/src/assets/public_icon/iconfont.js +0 -1
  82. package/template-gx-design-thin/src/assets/public_icon/iconfont.json +0 -51
  83. package/template-gx-design-thin/src/assets/public_icon/iconfont.svg +0 -1
  84. package/template-gx-design-thin/src/assets/public_icon/iconfont.ttf +0 -0
  85. package/template-gx-design-thin/src/assets/public_icon/iconfont.woff +0 -0
  86. package/template-gx-design-thin/src/assets/public_icon/iconfont.woff2 +0 -0
  87. package/template-gx-design-thin/src/assets/public_icon/index.less +0 -42
  88. package/template-gx-design-thin/src/assets/public_images/nodata.svg +0 -1
  89. package/template-gx-design-thin/src/common/global.ts +0 -4
  90. package/template-gx-design-thin/src/components/GDesign/Result/index.tsx +0 -144
  91. package/template-gx-design-thin/src/components/GDesign/Result/style.less +0 -140
  92. package/template-gx-design-thin/src/components/GDesign/utils/index.ts +0 -7
  93. package/template-gx-design-thin/src/components/GlobalLayout/Confirm/index.ts +0 -21
  94. package/template-gx-design-thin/src/components/GlobalLayout/Empty/index.vue +0 -18
  95. package/template-gx-design-thin/src/components/GlobalLayout/RightContent/index.tsx +0 -126
  96. package/template-gx-design-thin/src/components/GlobalLayout/RightContent/style.ts +0 -77
  97. package/template-gx-design-thin/src/components/GlobalLayout/Spin/index.tsx +0 -30
  98. package/template-gx-design-thin/src/components/PageLoading/index.tsx +0 -51
  99. package/template-gx-design-thin/src/components/index.ts +0 -6
  100. package/template-gx-design-thin/src/core/ant-design/index.ts +0 -10
  101. package/template-gx-design-thin/src/core/gx-admin-design/index.ts +0 -6
  102. package/template-gx-design-thin/src/core/gx-design/index.ts +0 -6
  103. package/template-gx-design-thin/src/core/gx-pro-design/index.ts +0 -8
  104. package/template-gx-design-thin/src/core/index.ts +0 -84
  105. package/template-gx-design-thin/src/design/ant-design/index.less +0 -4
  106. package/template-gx-design-thin/src/design/ant-design/layout.less +0 -22
  107. package/template-gx-design-thin/src/design/ant-design/menu.less +0 -48
  108. package/template-gx-design-thin/src/design/ant-design/spin.less +0 -23
  109. package/template-gx-design-thin/src/design/ant-design/tooltip.less +0 -7
  110. package/template-gx-design-thin/src/design/color.less +0 -1
  111. package/template-gx-design-thin/src/design/config.less +0 -5
  112. package/template-gx-design-thin/src/design/imageEditor.less +0 -180
  113. package/template-gx-design-thin/src/design/index.less +0 -95
  114. package/template-gx-design-thin/src/design/mixin.less +0 -65
  115. package/template-gx-design-thin/src/design/normalize.less +0 -391
  116. package/template-gx-design-thin/src/design/root.less +0 -3
  117. package/template-gx-design-thin/src/hooks/core/index.ts +0 -3
  118. package/template-gx-design-thin/src/hooks/core/useRequest/index.ts +0 -118
  119. package/template-gx-design-thin/src/hooks/event/index.ts +0 -3
  120. package/template-gx-design-thin/src/hooks/event/useClipboard.ts +0 -15
  121. package/template-gx-design-thin/src/hooks/web/index.ts +0 -5
  122. package/template-gx-design-thin/src/hooks/web/useThemeStyle.ts +0 -16
  123. package/template-gx-design-thin/src/layout/BasicLayout.vue +0 -123
  124. package/template-gx-design-thin/src/layout/BlankLayout.vue +0 -5
  125. package/template-gx-design-thin/src/layout/ContentView.vue +0 -50
  126. package/template-gx-design-thin/src/layout/IframeView.vue +0 -1
  127. package/template-gx-design-thin/src/layout/UserLayout.vue +0 -7
  128. package/template-gx-design-thin/src/main.ts +0 -34
  129. package/template-gx-design-thin/src/plugins/index.ts +0 -2
  130. package/template-gx-design-thin/src/router/guard/index.ts +0 -83
  131. package/template-gx-design-thin/src/router/guard/permissions.ts +0 -70
  132. package/template-gx-design-thin/src/router/guard/stateGuard.ts +0 -10
  133. package/template-gx-design-thin/src/router/helper/routeHelper.ts +0 -223
  134. package/template-gx-design-thin/src/router/helper/utils.ts +0 -19
  135. package/template-gx-design-thin/src/router/index.ts +0 -31
  136. package/template-gx-design-thin/src/router/routes/index.ts +0 -86
  137. package/template-gx-design-thin/src/router/routes/modules/dataSource.ts +0 -12
  138. package/template-gx-design-thin/src/services/common/index.ts +0 -11
  139. package/template-gx-design-thin/src/services/systemCenter/index.ts +0 -1
  140. package/template-gx-design-thin/src/services/systemCenter/menu.ts +0 -9
  141. package/template-gx-design-thin/src/services/userCenter/account.ts +0 -42
  142. package/template-gx-design-thin/src/services/userCenter/index.ts +0 -28
  143. package/template-gx-design-thin/src/store/index.ts +0 -32
  144. package/template-gx-design-thin/src/store/modules/dict.ts +0 -28
  145. package/template-gx-design-thin/src/store/modules/global.ts +0 -42
  146. package/template-gx-design-thin/src/store/modules/permission.ts +0 -19
  147. package/template-gx-design-thin/src/store/modules/routes.ts +0 -113
  148. package/template-gx-design-thin/src/store/modules/tabsRouter.ts +0 -76
  149. package/template-gx-design-thin/src/store/modules/user.ts +0 -136
  150. package/template-gx-design-thin/src/utils/accessToken.ts +0 -80
  151. package/template-gx-design-thin/src/utils/crypto/base64.ts +0 -101
  152. package/template-gx-design-thin/src/utils/crypto/index.ts +0 -57
  153. package/template-gx-design-thin/src/utils/env.ts +0 -50
  154. package/template-gx-design-thin/src/utils/fetchFile.ts +0 -81
  155. package/template-gx-design-thin/src/utils/index.ts +0 -123
  156. package/template-gx-design-thin/src/utils/pageTitle.ts +0 -20
  157. package/template-gx-design-thin/src/utils/request/XHR.ts +0 -139
  158. package/template-gx-design-thin/src/utils/request/axiosCancel.ts +0 -69
  159. package/template-gx-design-thin/src/utils/request/checkStatus.ts +0 -25
  160. package/template-gx-design-thin/src/utils/request/index.ts +0 -144
  161. package/template-gx-design-thin/src/utils/request/typings.ts +0 -171
  162. package/template-gx-design-thin/src/utils/storage.ts +0 -199
  163. package/template-gx-design-thin/src/utils/uploadFile.ts +0 -27
  164. package/template-gx-design-thin/src/utils/util.ts +0 -198
  165. package/template-gx-design-thin/src/utils/validate.ts +0 -216
  166. package/template-gx-design-thin/src/views/Iframe/index.vue +0 -76
  167. package/template-gx-design-thin/src/views/Page/one.vue +0 -13
  168. package/template-gx-design-thin/src/views/Page/two.vue +0 -13
  169. package/template-gx-design-thin/src/views/exception/403/index.vue +0 -7
  170. package/template-gx-design-thin/src/views/exception/404/index.vue +0 -9
  171. package/template-gx-design-thin/src/views/user/login/index.vue +0 -109
  172. package/template-gx-design-thin/src/views/user/login/style.less +0 -38
  173. package/template-gx-design-thin/tsconfig.json +0 -46
  174. package/template-gx-design-thin/types/ant-design-import.d.ts +0 -99
  175. package/template-gx-design-thin/types/auto-imports.d.ts +0 -81
  176. package/template-gx-design-thin/types/components.d.ts +0 -24
  177. package/template-gx-design-thin/types/config.d.ts +0 -44
  178. package/template-gx-design-thin/types/global.d.ts +0 -97
  179. package/template-gx-design-thin/types/mock.d.ts +0 -16
  180. package/template-gx-design-thin/types/module.d.ts +0 -20
  181. package/template-gx-design-thin/types/response.d.ts +0 -15
  182. package/template-gx-design-thin/unocss.config.ts +0 -101
  183. package/template-gx-design-thin/vite.config.ts +0 -120
  184. package/template-gx-design-thin/yarn.lock +0 -9492
@@ -1,42 +0,0 @@
1
- import request from '@/utils/request'
2
-
3
- export function getUserInfo() {
4
- return request({
5
- url: '/user/queryUserDetail',
6
- method: 'get',
7
- isMock: true
8
- })
9
- }
10
-
11
- export function getUserList() {
12
- return request({
13
- url: '/user/account/list',
14
- method: 'get',
15
- isMock: true
16
- })
17
- }
18
-
19
- export function getAccountGroupList() {
20
- return request({
21
- url: '/user/account/group',
22
- method: 'get',
23
- isMock: true
24
- })
25
- }
26
-
27
- export function getAccountCount() {
28
- return request({
29
- url: '/user/account/count',
30
- method: 'get',
31
- isMock: true
32
- })
33
- }
34
-
35
- export function updateUserDetails(data) {
36
- return request({
37
- url: '/user/account/update',
38
- method: 'post',
39
- data,
40
- isMock: true
41
- })
42
- }
@@ -1,28 +0,0 @@
1
- import request from '@/utils/request'
2
-
3
- export * from './account'
4
-
5
- export function login(data) {
6
- return request({
7
- url: '/user/login',
8
- method: 'post',
9
- data,
10
- isMock: true
11
- })
12
- }
13
-
14
- export function logout() {
15
- return request({
16
- url: '/user/logout',
17
- method: 'get',
18
- isMock: true
19
- })
20
- }
21
-
22
- export function register() {
23
- return request({
24
- url: '/user/register',
25
- method: 'post',
26
- isMock: true
27
- })
28
- }
@@ -1,32 +0,0 @@
1
- import type { App } from 'vue'
2
- import { createPinia } from 'pinia'
3
- import { useStoreGlobal } from './modules/global'
4
- import { useStoreDict } from './modules/dict'
5
- import { useStoreUser } from './modules/user'
6
- import { useStoreRoutes } from './modules/routes'
7
- import { useStorePermission } from './modules/permission'
8
- import { useStoreTabsRouter } from './modules/tabsRouter'
9
-
10
- export {
11
- useStoreGlobal,
12
- useStoreDict,
13
- useStoreUser,
14
- useStoreRoutes,
15
- useStorePermission,
16
- useStoreTabsRouter
17
- }
18
-
19
- export function useStore() {
20
- return {
21
- user: useStoreUser(),
22
- dict: useStoreDict(),
23
- global: useStoreGlobal(),
24
- routes: useStoreRoutes(),
25
- permission: useStorePermission(),
26
- tabsRouter: useStoreTabsRouter()
27
- }
28
- }
29
-
30
- export function setupStore(app: App<Element>) {
31
- app.use(createPinia())
32
- }
@@ -1,28 +0,0 @@
1
- import { reactive, toRefs } from 'vue'
2
- import { defineStore } from 'pinia'
3
- import type { DictRecord, DictType } from '@gx-mock/config/dict'
4
-
5
- /**
6
- * @Author gx12358
7
- * @DateTime 2022/1/11
8
- * @lastTime 2022/1/11
9
- * @description store-dict 数字字典
10
- */
11
- export interface DictState {
12
- data: Partial<Record<DictType, DictRecord[]>>;
13
- }
14
-
15
- export const useStoreDict = defineStore('dict', () => {
16
- const state = reactive<DictState>({
17
- data: {}
18
- })
19
-
20
- const setDictData = (type, value) => {
21
- state.data[type] = value
22
- }
23
-
24
- return {
25
- ...toRefs(state),
26
- setDictData
27
- }
28
- })
@@ -1,42 +0,0 @@
1
- import { reactive } from 'vue'
2
- import { defineStore } from 'pinia'
3
- import type { ThemeConfig } from '@gx-design-vue/pro-provider'
4
- import { themeConfig as proThemeConfig } from '@gx-design-vue/pro-provider'
5
- import type { BasicLayoutProps } from '@gx-design-vue/pro-layout'
6
- import { handleThemeConfig } from '@gx-design-vue/pro-layout'
7
- import { defaultSettings, theme } from '@gx-config'
8
- import logo from '@/assets/logo.png'
9
-
10
- const layoutThemeConfig = {
11
- ...proThemeConfig,
12
- title: defaultSettings.title
13
- } as ThemeConfig
14
-
15
- /**
16
- * @Author gx12358
17
- * @DateTime 2022/1/11
18
- * @lastTime 2022/1/11
19
- * @description store-global 全局属性
20
- */
21
- export interface GlobalState {
22
- globalLayout: BasicLayoutProps;
23
- keepAlive: boolean;
24
- showProgressBar: boolean;
25
- disabledScrollTop: boolean;
26
- }
27
-
28
- export const useStoreGlobal = defineStore('global', () => {
29
- const state = reactive<GlobalState>({
30
- keepAlive: true,
31
- showProgressBar: true,
32
- disabledScrollTop: false,
33
- globalLayout: {
34
- logo,
35
- ...handleThemeConfig({ ...layoutThemeConfig, primaryColor: theme.colorPrimary })
36
- }
37
- })
38
-
39
- return {
40
- ...toRefs(state)
41
- }
42
- })
@@ -1,19 +0,0 @@
1
- import { reactive, toRefs } from 'vue'
2
- import { defineStore } from 'pinia'
3
-
4
- export const useStorePermission = defineStore('permission', () => {
5
- const state = reactive({
6
- admin: false,
7
- role: [],
8
- ability: []
9
- })
10
-
11
- const changeValue = (type: string, value: any) => {
12
- state[type] = value
13
- }
14
-
15
- return {
16
- ...toRefs(state),
17
- changeValue
18
- }
19
- })
@@ -1,113 +0,0 @@
1
- import { reactive, toRefs } from 'vue'
2
- import { defineStore } from 'pinia'
3
- import type { AppRouteModule, MenuDataItem } from '@gx-design-vue/pro-layout'
4
- import { asyncRoutes, localRoutes } from '@/router/routes'
5
- import { getMenuList } from '@/services/systemCenter'
6
- import { generator, getRootMenu } from '@/router/helper/routeHelper'
7
- import { getFirstLastChild } from '@/router/helper/utils'
8
- import { getLevelData } from '@gx-design-vue/pro-utils'
9
-
10
- /**
11
- * @Author gx12358
12
- * @DateTime 2022/1/11
13
- * @lastTime 2022/1/11
14
- * @description store-routes 路由
15
- */
16
- export interface RoutesState {
17
- routes: AppRouteModule[];
18
- routerLoadList: string[];
19
- meunLoading: boolean;
20
- routerLoading: boolean;
21
- }
22
-
23
- type RouteStateKey = keyof RoutesState
24
-
25
- export const useStoreRoutes = defineStore('routes', () => {
26
- const state = reactive<RoutesState>({
27
- routes: [],
28
- routerLoadList: [],
29
- meunLoading: false,
30
- routerLoading: false
31
- })
32
-
33
- /**
34
- * @Author gx12358
35
- * @DateTime 2022/1/11
36
- * @lastTime 2022/1/11
37
- * @description intelligence(前端静态路由)模式设置路由
38
- */
39
- const setRoutes = () => {
40
- state.routes = localRoutes
41
- return [ ...localRoutes ]
42
- }
43
-
44
- /**
45
- * @Author gx12358
46
- * @DateTime 2022/1/11
47
- * @lastTime 2022/1/11
48
- * @description all(后端动态路由)
49
- */
50
- const setAllRoutes = async () => {
51
- let routes: AppRouteModule[] = []
52
- state.meunLoading = true
53
- const response: ResponseResult<MenuDataItem[]> = await getMenuList()
54
- if (response && (response?.data)?.length) {
55
- const notFoundRouter: AppRouteModule = {
56
- path: '/:path(.*)*',
57
- redirect: '/exception/404',
58
- hidden: true
59
- }
60
- const rootMenu = getRootMenu(response?.data || [])
61
- const asyncRouteList = generator(rootMenu)
62
- asyncRouteList[0].children = [ ...(asyncRouteList[0]?.children || []), ...asyncRoutes ]
63
- const haveHomePage = getLevelData(asyncRouteList[0].children)
64
- .find(item => item.meta ? item.meta.homePage === 1 : false)
65
- asyncRouteList[0].redirect = haveHomePage ? haveHomePage.path : getFirstLastChild(asyncRouteList[0].children)
66
- asyncRouteList.push(notFoundRouter)
67
- routes = [ ...asyncRouteList ]
68
- }
69
- state.routes = routes
70
- state.meunLoading = false
71
- return routes
72
- }
73
-
74
- /**
75
- * @Author gx12358
76
- * @DateTime 2022/1/11
77
- * @lastTime 2022/1/11
78
- * @description 重置路由
79
- */
80
- const resetRoute = () => {
81
- state.routes = []
82
- state.routerLoadList = []
83
- }
84
-
85
- /**
86
- * @Author gx12358
87
- * @DateTime 2022/1/11
88
- * @lastTime 2022/1/11
89
- * @description 添加路由记录
90
- */
91
- const addRouterLoadList = (path) => {
92
- state.routerLoadList.push(path)
93
- }
94
-
95
- /**
96
- * @Author gx12358
97
- * @DateTime 2022/1/11
98
- * @lastTime 2022/1/11
99
- * @description 修改state状态
100
- */
101
- const setRouteState: (params: Partial<Record<RouteStateKey, RoutesState[RouteStateKey]>>) => void = (params) => {
102
- Object.assign(state, params)
103
- }
104
-
105
- return {
106
- ...toRefs(state),
107
- setRoutes,
108
- setAllRoutes,
109
- resetRoute,
110
- addRouterLoadList,
111
- setRouteState
112
- }
113
- })
@@ -1,76 +0,0 @@
1
- import { reactive, toRefs } from 'vue'
2
- import { defineStore } from 'pinia'
3
-
4
- export interface TabsRouterState {
5
- visitedRoutes: Recordable[];
6
- }
7
-
8
- export const useStoreTabsRouter = defineStore('tabsRouter', () => {
9
- const state = reactive({
10
- visitedRoutes: []
11
- } as TabsRouterState)
12
-
13
- const addVisitedRoute = (route) => {
14
- const target = state.visitedRoutes.find(item => item.path === route.path)
15
- if (target) {
16
- if (route.fullPath !== target.fullPath)
17
- Object.assign(target, route)
18
- return
19
- }
20
- if (route.tagFixed) {
21
- state.visitedRoutes.unshift(Object.assign({}, route))
22
- } else {
23
- state.visitedRoutes.push(Object.assign({}, route))
24
- }
25
- }
26
-
27
- const delVisitedRoute = (route) => {
28
- state.visitedRoutes.forEach((item, index) => {
29
- if (item.path === route.path)
30
- state.visitedRoutes.splice(index, 1)
31
- })
32
- }
33
-
34
- const delOthersVisitedRoutes = (route) => {
35
- state.visitedRoutes = state.visitedRoutes.filter(
36
- item => item.meta.tagFixed || item.path === route.path
37
- )
38
- }
39
-
40
- const delLeftVisitedRoutes = (route) => {
41
- let index = state.visitedRoutes.length
42
- state.visitedRoutes = state.visitedRoutes.filter((item) => {
43
- if (item.name === route.name)
44
- index = state.visitedRoutes.indexOf(item)
45
- return item.meta.tagFixed || index <= state.visitedRoutes.indexOf(item)
46
- })
47
- }
48
-
49
- const delRightVisitedRoutes = (route) => {
50
- let index = state.visitedRoutes.length
51
- state.visitedRoutes = state.visitedRoutes.filter((item) => {
52
- if (item.name === route.name)
53
- index = state.visitedRoutes.indexOf(item)
54
- return item.meta.tagFixed || index >= state.visitedRoutes.indexOf(item)
55
- })
56
- }
57
-
58
- const delAllVisitedRoutes = () => {
59
- state.visitedRoutes = state.visitedRoutes.filter(item => item.meta.tagFixed)
60
- }
61
-
62
- const blankingTabs = () => {
63
- state.visitedRoutes = []
64
- }
65
-
66
- return {
67
- ...toRefs(state),
68
- blankingTabs,
69
- addVisitedRoute,
70
- delVisitedRoute,
71
- delOthersVisitedRoutes,
72
- delLeftVisitedRoutes,
73
- delRightVisitedRoutes,
74
- delAllVisitedRoutes
75
- }
76
- })
@@ -1,136 +0,0 @@
1
- import { reactive, toRefs } from 'vue'
2
- import { defineStore } from 'pinia'
3
- import { notification } from 'ant-design-vue'
4
- import { defaultSettings } from '@gx-config'
5
- import type { UserDetails, UserInfo } from '@gx-mock/config/user'
6
- import { defaultUser } from '@gx-mock/config/user'
7
- import { getUserInfo, login, logout } from '@/services/userCenter'
8
- import { getAccessToken, removeAccessToken, setAccessToken } from '@/utils/accessToken'
9
- import { timeFix } from '@/utils/util'
10
- import { useStoreRoutes } from './routes'
11
- import { useStorePermission } from './permission'
12
- import { useStoreTabsRouter } from './tabsRouter'
13
- import { isObject } from '@gx-design-vue/pro-utils'
14
- import { cloneDeep } from 'lodash-es'
15
-
16
- const { tokenName, loginInterception } = defaultSettings
17
-
18
- export interface UserState {
19
- accessToken: string;
20
- userInfo: UserDetails;
21
- }
22
-
23
- type UserStateKey = keyof UserState
24
-
25
- export const useStoreUser = defineStore('user', () => {
26
- const routes = useStoreRoutes()
27
- const auth = useStorePermission()
28
- const tabsRouter = useStoreTabsRouter()
29
-
30
- const state = reactive<UserState>({
31
- accessToken: getAccessToken(),
32
- userInfo: {} as UserDetails
33
- })
34
-
35
- const userDetails = computed<UserDetails>(() => state.userInfo)
36
-
37
- const setState: (params: Partial<Record<UserStateKey, UserState[UserStateKey]>>) => void = (params) => {
38
- Object.assign(state, params)
39
- }
40
-
41
- /**
42
- * @Author gx12358
43
- * @DateTime 2022/1/11
44
- * @lastTime 2022/1/11
45
- * @description 登录拦截放行时,设置虚拟角色
46
- */
47
- const setVirtualUserInfo = () => {
48
- auth.changeValue('admin', true)
49
- auth.changeValue('role', defaultUser.roles)
50
- auth.changeValue('ability', defaultUser.permissions)
51
- setState({
52
- userInfo: defaultUser.user as UserDetails
53
- })
54
- }
55
-
56
- /**
57
- * @Author gx12358
58
- * @DateTime 2022/1/11
59
- * @lastTime 2022/1/11
60
- * @description 登录
61
- */
62
- const userLogin = async (params): Promise<boolean> => {
63
- const response: ResponseResult<{ expiresIn: number; }> = await login(params)
64
- const accessToken = response?.data?.[tokenName]
65
- if (accessToken) {
66
- const expiresIn = response?.data?.expiresIn
67
- state.accessToken = accessToken
68
- setAccessToken(accessToken, expiresIn ? expiresIn * 60 * 1000 : 0)
69
- return true
70
- }
71
- return false
72
- }
73
-
74
- const updateUserInfo = async () => {
75
- const response: ResponseResult<UserInfo> = await getUserInfo()
76
- const { user, roles, permissions } = response?.data || {} as UserInfo
77
- if (response && user && isObject(user)) {
78
- if (user.userName && roles && Array.isArray(roles)) {
79
- auth.changeValue('role', roles)
80
- auth.changeValue('ability', permissions)
81
-
82
- setState({
83
- userInfo: cloneDeep(user)
84
- })
85
- notification.success({
86
- message: `欢迎登录${state.userInfo?.userName}`,
87
- description: `${timeFix()}!`
88
- })
89
- }
90
- }
91
- }
92
-
93
- /**
94
- * @Author gx12358
95
- * @DateTime 2022/1/11
96
- * @lastTime 2022/1/11
97
- * @description 获取用户信息
98
- */
99
- const checkUserPremission = async () => {
100
- if (loginInterception)
101
- await updateUserInfo()
102
- else setVirtualUserInfo()
103
- return Object.keys(state.userInfo).length
104
- }
105
-
106
- const resetPermissions = () => {
107
- state.accessToken = ''
108
- removeAccessToken()
109
- auth.changeValue('admin', false)
110
- auth.changeValue('role', [])
111
- auth.changeValue('ability', [])
112
- routes.resetRoute()
113
- tabsRouter.blankingTabs()
114
- }
115
-
116
- /**
117
- * @Author gx12358
118
- * @DateTime 2022/5/15
119
- * @lastTime 2022/5/15
120
- * @description 用户退出登录
121
- */
122
- const userLogut = async () => {
123
- await logout()
124
- resetPermissions()
125
- }
126
-
127
- return {
128
- ...toRefs(state),
129
- userDetails,
130
- userLogin,
131
- userLogut,
132
- setState,
133
- resetPermissions,
134
- checkUserPremission
135
- }
136
- })
@@ -1,80 +0,0 @@
1
- import { defaultSettings } from '@gx-config'
2
- import {
3
- delCookie,
4
- getStorage,
5
- removeStorage,
6
- setCookie,
7
- setStorage
8
- } from '@/utils/storage'
9
-
10
- const { storage, tokenTableName } = defaultSettings
11
-
12
- /**
13
- * @Author gx12358
14
- * @DateTime 2021/12/27
15
- * @lastTime 2021/12/27
16
- * @description 获取accessToken
17
- */
18
- export function getAccessToken() {
19
- return getStorage({ key: tokenTableName, type: storage || 'localStorage' })
20
- }
21
-
22
- /**
23
- * @author gx12358 2539306317@qq.com
24
- * @description 存储accessToken
25
- * @param accessToken
26
- * @returns {void|*}
27
- */
28
- export function setAccessToken(accessToken: string, expired?: number) {
29
- if (storage) {
30
- if (storage === 'localStorage') {
31
- return setStorage({
32
- key: tokenTableName,
33
- value: accessToken,
34
- expired
35
- })
36
- } else if (storage === 'sessionStorage') {
37
- return setStorage({
38
- key: tokenTableName,
39
- value: accessToken,
40
- expired,
41
- type: 'session'
42
- })
43
- } else if (storage === 'cookie') {
44
- return setCookie(tokenTableName, accessToken, expired)
45
- } else {
46
- return setStorage({
47
- key: tokenTableName,
48
- value: accessToken,
49
- expired
50
- })
51
- }
52
- } else {
53
- return setStorage({
54
- key: tokenTableName,
55
- value: accessToken,
56
- expired
57
- })
58
- }
59
- }
60
-
61
- /**
62
- * @author gx12358 2539306317@qq.com
63
- * @description 移除accessToken
64
- * @returns {void|Promise<void>}
65
- */
66
- export function removeAccessToken() {
67
- if (storage) {
68
- if (storage === 'localStorage') {
69
- return removeStorage(tokenTableName)
70
- } else if (storage === 'sessionStorage') {
71
- return removeStorage(tokenTableName, 'session')
72
- } else if (storage === 'cookie') {
73
- return delCookie(tokenTableName)
74
- } else {
75
- return removeStorage(tokenTableName)
76
- }
77
- } else {
78
- return removeStorage(tokenTableName)
79
- }
80
- }
@@ -1,101 +0,0 @@
1
- export default class Base64 {
2
- _keyStr: string
3
-
4
- constructor() {
5
- this._keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
6
- }
7
-
8
- _utf8_encode(string: string) {
9
- string = string.replace(/\r\n/g, '\n')
10
- let utftext = ''
11
- for (let n = 0; n < string.length; n++) {
12
- const c = string.charCodeAt(n)
13
- if (c < 128) {
14
- utftext += String.fromCharCode(c)
15
- } else if ((c > 127) && (c < 2048)) {
16
- utftext += String.fromCharCode((c >> 6) | 192)
17
- utftext += String.fromCharCode((c & 63) | 128)
18
- } else {
19
- utftext += String.fromCharCode((c >> 12) | 224)
20
- utftext += String.fromCharCode(((c >> 6) & 63) | 128)
21
- utftext += String.fromCharCode((c & 63) | 128)
22
- }
23
- }
24
- return utftext
25
- }
26
-
27
- _utf8_decode(utftext: string) {
28
- let string = ''
29
- let i = 0
30
- let c = 0
31
- let c1 = 0
32
- let c2 = 0
33
- while (i < utftext.length) {
34
- c = utftext.charCodeAt(i)
35
- if (c < 128) {
36
- string += String.fromCharCode(c)
37
- i++
38
- } else if ((c > 191) && (c < 224)) {
39
- c1 = utftext.charCodeAt(i + 1)
40
- string += String.fromCharCode(((c & 31) << 6) | (c1 & 63))
41
- i += 2
42
- } else {
43
- c1 = utftext.charCodeAt(i + 1)
44
- c2 = utftext.charCodeAt(i + 2)
45
- string += String.fromCharCode(((c & 15) << 12) | ((c1 & 63) << 6) | (c2 & 63))
46
- i += 3
47
- }
48
- }
49
- return string
50
- }
51
-
52
- encode(input: string) {
53
- let output = ''
54
- let chr1, chr2, chr3, enc1, enc2, enc3, enc4
55
- let i = 0
56
- input = this._utf8_encode(input)
57
- while (i < input.length) {
58
- chr1 = input.charCodeAt(i++)
59
- chr2 = input.charCodeAt(i++)
60
- chr3 = input.charCodeAt(i++)
61
- enc1 = chr1 >> 2
62
- enc2 = ((chr1 & 3) << 4) | (chr2 >> 4)
63
- enc3 = ((chr2 & 15) << 2) | (chr3 >> 6)
64
- enc4 = chr3 & 63
65
- if (Number.isNaN(chr2)) {
66
- enc3 = enc4 = 64
67
- } else if (Number.isNaN(chr3)) {
68
- enc4 = 64
69
- }
70
- output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(
71
- enc3) + this._keyStr.charAt(enc4)
72
- }
73
- return output
74
- }
75
-
76
- decode(input: string) {
77
- let output = ''
78
- let chr1, chr2, chr3
79
- let enc1, enc2, enc3, enc4
80
- let i = 0
81
- input = input.replace(/[^A-Za-z0-9+/=]/g, '')
82
- while (i < input.length) {
83
- enc1 = this._keyStr.indexOf(input.charAt(i++))
84
- enc2 = this._keyStr.indexOf(input.charAt(i++))
85
- enc3 = this._keyStr.indexOf(input.charAt(i++))
86
- enc4 = this._keyStr.indexOf(input.charAt(i++))
87
- chr1 = (enc1 << 2) | (enc2 >> 4)
88
- chr2 = ((enc2 & 15) << 4) | (enc3 >> 2)
89
- chr3 = ((enc3 & 3) << 6) | enc4
90
- output = output + String.fromCharCode(chr1)
91
- if (enc3 !== 64) {
92
- output = output + String.fromCharCode(chr2)
93
- }
94
- if (enc4 !== 64) {
95
- output = output + String.fromCharCode(chr3)
96
- }
97
- }
98
- output = this._utf8_decode(output)
99
- return output
100
- }
101
- }