@gx-design-vue/create-gx-cli 0.1.20 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/README.md +1 -4
  2. package/package.json +5 -3
  3. package/template-mobile-vant-cli/.editorconfig +19 -0
  4. package/template-mobile-vant-cli/.env +3 -0
  5. package/template-mobile-vant-cli/.env.development +17 -0
  6. package/template-mobile-vant-cli/.env.pro +28 -0
  7. package/template-mobile-vant-cli/.env.production +31 -0
  8. package/template-mobile-vant-cli/.eslintignore +15 -0
  9. package/template-mobile-vant-cli/.prettierignore +9 -0
  10. package/template-mobile-vant-cli/README.md +1 -0
  11. package/template-mobile-vant-cli/commitlint.config.cjs +32 -0
  12. package/template-mobile-vant-cli/config/default/defaultSettings.ts +70 -0
  13. package/template-mobile-vant-cli/config/default/network.ts +10 -0
  14. package/template-mobile-vant-cli/config/default/proxy.ts +50 -0
  15. package/template-mobile-vant-cli/config/default/theme.ts +3 -0
  16. package/template-mobile-vant-cli/config/index.ts +11 -0
  17. package/template-mobile-vant-cli/eslint.config.js +58 -0
  18. package/template-mobile-vant-cli/index.html +25 -0
  19. package/template-mobile-vant-cli/internal/vite-config/generate/generateModifyVars.ts +7 -0
  20. package/template-mobile-vant-cli/internal/vite-config/rollupOptions/index.ts +22 -0
  21. package/template-mobile-vant-cli/internal/vite-config/util/hash.ts +17 -0
  22. package/template-mobile-vant-cli/internal/vite-config/util/index.ts +132 -0
  23. package/template-mobile-vant-cli/internal/vite-config/vite/cdn.ts +65 -0
  24. package/template-mobile-vant-cli/internal/vite-config/vite/optimizer.ts +26 -0
  25. package/template-mobile-vant-cli/internal/vite-config/vite/plugin/appConfig.ts +91 -0
  26. package/template-mobile-vant-cli/internal/vite-config/vite/plugin/autoImport.ts +28 -0
  27. package/template-mobile-vant-cli/internal/vite-config/vite/plugin/compress.ts +31 -0
  28. package/template-mobile-vant-cli/internal/vite-config/vite/plugin/html.ts +32 -0
  29. package/template-mobile-vant-cli/internal/vite-config/vite/plugin/index.ts +74 -0
  30. package/template-mobile-vant-cli/internal/vite-config/vite/plugin/visualizer.ts +14 -0
  31. package/template-mobile-vant-cli/internal/vite-config/vite/plugin/viteNotice.ts +40 -0
  32. package/template-mobile-vant-cli/mock/config/permissions.ts +15 -0
  33. package/template-mobile-vant-cli/mock/config/user/id.ts +5 -0
  34. package/template-mobile-vant-cli/mock/config/user/index.ts +96 -0
  35. package/template-mobile-vant-cli/mock/index.ts +55 -0
  36. package/template-mobile-vant-cli/mock/routers/table/index.fake.ts +22 -0
  37. package/template-mobile-vant-cli/mock/routers/user/account.fake.ts +52 -0
  38. package/template-mobile-vant-cli/mock/routers/user/index.fake.ts +46 -0
  39. package/template-mobile-vant-cli/mock/utils/crypto.ts +21 -0
  40. package/template-mobile-vant-cli/mock/utils/table.ts +96 -0
  41. package/template-mobile-vant-cli/mock/utils/util.ts +91 -0
  42. package/template-mobile-vant-cli/package.json +74 -0
  43. package/template-mobile-vant-cli/public/css/default.css +54 -0
  44. package/template-mobile-vant-cli/public/favicon.ico +0 -0
  45. package/template-mobile-vant-cli/src/App.vue +8 -0
  46. package/template-mobile-vant-cli/src/assets/logo.png +0 -0
  47. package/template-mobile-vant-cli/src/components/PageContainer/ProSkeleton.tsx +29 -0
  48. package/template-mobile-vant-cli/src/components/PageContainer/index.tsx +207 -0
  49. package/template-mobile-vant-cli/src/components/PageContainer/style.module.less +17 -0
  50. package/template-mobile-vant-cli/src/components/TabsMenu/index.vue +45 -0
  51. package/template-mobile-vant-cli/src/core/gx-design/index.ts +7 -0
  52. package/template-mobile-vant-cli/src/core/index.ts +5 -0
  53. package/template-mobile-vant-cli/src/design/color.less +1 -0
  54. package/template-mobile-vant-cli/src/design/config.less +5 -0
  55. package/template-mobile-vant-cli/src/design/index.less +3 -0
  56. package/template-mobile-vant-cli/src/design/mixin.less +65 -0
  57. package/template-mobile-vant-cli/src/design/reset.less +39 -0
  58. package/template-mobile-vant-cli/src/design/root.less +3 -0
  59. package/template-mobile-vant-cli/src/design/vant/index.less +0 -0
  60. package/template-mobile-vant-cli/src/hooks/web/index.ts +5 -0
  61. package/template-mobile-vant-cli/src/hooks/web/usePageLoading.ts +56 -0
  62. package/template-mobile-vant-cli/src/layout/BasicLayout/index.vue +18 -0
  63. package/template-mobile-vant-cli/src/layout/BasicLayout/style.less +3 -0
  64. package/template-mobile-vant-cli/src/layout/UserLayout/index.vue +18 -0
  65. package/template-mobile-vant-cli/src/layout/UserLayout/style.module.less +36 -0
  66. package/template-mobile-vant-cli/src/main.ts +34 -0
  67. package/template-mobile-vant-cli/src/pages/Account/details.vue +13 -0
  68. package/template-mobile-vant-cli/src/pages/Account/index.vue +102 -0
  69. package/template-mobile-vant-cli/src/pages/Home/index.vue +71 -0
  70. package/template-mobile-vant-cli/src/pages/user/login/index.vue +76 -0
  71. package/template-mobile-vant-cli/src/plugins/dayjs/index.ts +3 -0
  72. package/template-mobile-vant-cli/src/plugins/index.ts +2 -0
  73. package/template-mobile-vant-cli/src/router/guard/index.ts +18 -0
  74. package/template-mobile-vant-cli/src/router/guard/permissions.ts +41 -0
  75. package/template-mobile-vant-cli/src/router/guard/stateGuard.ts +10 -0
  76. package/template-mobile-vant-cli/src/router/index.ts +31 -0
  77. package/template-mobile-vant-cli/src/router/routes/index.ts +46 -0
  78. package/template-mobile-vant-cli/src/router/routes/modules/dataSource.ts +32 -0
  79. package/template-mobile-vant-cli/src/services/index.ts +31 -0
  80. package/template-mobile-vant-cli/src/services/userCenter/account.ts +42 -0
  81. package/template-mobile-vant-cli/src/services/userCenter/index.ts +28 -0
  82. package/template-mobile-vant-cli/src/store/index.ts +20 -0
  83. package/template-mobile-vant-cli/src/store/modules/global.ts +23 -0
  84. package/template-mobile-vant-cli/src/store/modules/user.ts +107 -0
  85. package/template-mobile-vant-cli/src/utils/accessToken.ts +97 -0
  86. package/template-mobile-vant-cli/src/utils/crypto/index.ts +56 -0
  87. package/template-mobile-vant-cli/src/utils/env.ts +50 -0
  88. package/template-mobile-vant-cli/src/utils/pageTitle.ts +20 -0
  89. package/template-mobile-vant-cli/src/utils/request/XHR.ts +137 -0
  90. package/template-mobile-vant-cli/src/utils/request/axiosCancel.ts +69 -0
  91. package/template-mobile-vant-cli/src/utils/request/checkStatus.ts +25 -0
  92. package/template-mobile-vant-cli/src/utils/request/index.ts +155 -0
  93. package/template-mobile-vant-cli/src/utils/request/typings.ts +171 -0
  94. package/template-mobile-vant-cli/src/utils/storage.ts +215 -0
  95. package/template-mobile-vant-cli/src/utils/util.ts +27 -0
  96. package/template-mobile-vant-cli/src/utils/validate.ts +211 -0
  97. package/template-mobile-vant-cli/tsconfig.json +50 -0
  98. package/template-mobile-vant-cli/types/auto-imports.d.ts +80 -0
  99. package/template-mobile-vant-cli/types/components.d.ts +7 -0
  100. package/template-mobile-vant-cli/types/config.d.ts +56 -0
  101. package/template-mobile-vant-cli/types/global.d.ts +80 -0
  102. package/template-mobile-vant-cli/types/mock.d.ts +34 -0
  103. package/template-mobile-vant-cli/types/module.d.ts +61 -0
  104. package/template-mobile-vant-cli/types/response.d.ts +17 -0
  105. package/template-mobile-vant-cli/types/system.d.ts +58 -0
  106. package/template-mobile-vant-cli/types/vant-import.d.ts +25 -0
  107. package/template-mobile-vant-cli/unocss.config.ts +161 -0
  108. package/template-mobile-vant-cli/vite.config.ts +142 -0
  109. package/template-mobile-vant-html/README.md +4 -0
  110. package/template-mobile-vant-html/css/global.css +293 -0
  111. package/template-mobile-vant-html/css/global.css.map +1 -0
  112. package/template-mobile-vant-html/css/global.less +293 -0
  113. package/template-mobile-vant-html/css/index.css +20 -0
  114. package/template-mobile-vant-html/css/index.css.map +1 -0
  115. package/template-mobile-vant-html/css/index.less +21 -0
  116. package/template-mobile-vant-html/image/disconnected.svg +60 -0
  117. package/template-mobile-vant-html/image/empty.svg +52 -0
  118. package/template-mobile-vant-html/image/error.svg +53 -0
  119. package/template-mobile-vant-html/image/loading.svg +1 -0
  120. package/template-mobile-vant-html/index.html +91 -0
  121. package/template-mobile-vant-html/js/index.js +29 -0
  122. package/template-mobile-vant-html/js/plugin/day.min.js +1 -0
  123. package/template-mobile-vant-html/js/plugin/fastclick.js +730 -0
  124. package/template-mobile-vant-html/js/plugin/jquery.min.js +2 -0
  125. package/template-mobile-vant-html/js/plugin/rem.js +28 -0
  126. package/template-mobile-vant-html/js/utils/appUtil.js +70 -0
  127. package/template-mobile-vant-html/js/utils/config.js +3 -0
  128. package/template-mobile-vant-html/js/utils/request.js +61 -0
  129. package/template-mobile-vant-html/js/utils/utils.js +65 -0
  130. package/template-mobile-vant-html/js/utils/validate.js +292 -0
  131. package/template-vite-project/.env +5 -0
  132. package/template-vite-project/.env.development +5 -0
  133. package/template-vite-project/.env.pro +5 -0
  134. package/template-vite-project/.env.production +5 -0
  135. package/template-vite-project/README.md +5 -0
  136. package/template-vite-project/_gitignore +24 -0
  137. package/template-vite-project/index.html +46 -0
  138. package/template-vite-project/internal/proxy/index.ts +47 -0
  139. package/template-vite-project/internal/vite/generate/generateModifyVars.ts +9 -0
  140. package/template-vite-project/internal/vite/rollupOptions/index.ts +18 -0
  141. package/template-vite-project/internal/vite/util/hash.ts +17 -0
  142. package/template-vite-project/internal/vite/util/index.ts +132 -0
  143. package/template-vite-project/internal/vite/vite/cdn.ts +65 -0
  144. package/template-vite-project/internal/vite/vite/plugin/appConfig.ts +91 -0
  145. package/template-vite-project/internal/vite/vite/plugin/autoImport.ts +21 -0
  146. package/template-vite-project/internal/vite/vite/plugin/compress.ts +31 -0
  147. package/template-vite-project/internal/vite/vite/plugin/html.ts +24 -0
  148. package/template-vite-project/internal/vite/vite/plugin/index.ts +72 -0
  149. package/template-vite-project/internal/vite/vite/plugin/visualizer.ts +14 -0
  150. package/template-vite-project/internal/vite/vite/plugin/viteNotice.ts +40 -0
  151. package/template-vite-project/node_modules/.bin/cross-env +21 -0
  152. package/template-vite-project/node_modules/.bin/cross-env-shell +21 -0
  153. package/template-vite-project/node_modules/.bin/esbuild +21 -0
  154. package/template-vite-project/node_modules/.bin/jiti +21 -0
  155. package/template-vite-project/node_modules/.bin/lessc +21 -0
  156. package/template-vite-project/node_modules/.bin/parser +21 -0
  157. package/template-vite-project/node_modules/.bin/rollup +21 -0
  158. package/template-vite-project/node_modules/.bin/terser +21 -0
  159. package/template-vite-project/node_modules/.bin/tsc +21 -0
  160. package/template-vite-project/node_modules/.bin/tsserver +21 -0
  161. package/template-vite-project/node_modules/.bin/vite +21 -0
  162. package/template-vite-project/node_modules/.bin/vue-tsc +21 -0
  163. package/template-vite-project/node_modules/.bin/yaml +21 -0
  164. package/template-vite-project/package.json +38 -0
  165. package/template-vite-project/public/css/index.css +89 -0
  166. package/template-vite-project/public/css/normalize.css +396 -0
  167. package/template-vite-project/public/vite.svg +1 -0
  168. package/template-vite-project/src/App.vue +30 -0
  169. package/template-vite-project/src/assets/vue.svg +1 -0
  170. package/template-vite-project/src/components/HelloWorld.vue +41 -0
  171. package/template-vite-project/src/design/config.less +0 -0
  172. package/template-vite-project/src/design/index.less +0 -0
  173. package/template-vite-project/src/main.ts +14 -0
  174. package/template-vite-project/src/utils/env.ts +50 -0
  175. package/template-vite-project/tsconfig.app.json +59 -0
  176. package/template-vite-project/tsconfig.json +7 -0
  177. package/template-vite-project/tsconfig.node.json +28 -0
  178. package/template-vite-project/types/global.d.ts +33 -0
  179. package/template-vite-project/unocss.config.ts +208 -0
  180. package/template-vite-project/vite.config.ts +88 -0
@@ -0,0 +1,96 @@
1
+ import { getRandomNumber } from '@gx-design-vue/pro-utils'
2
+ import dayjs from 'dayjs'
3
+ import { cloneDeep } from 'lodash-es'
4
+ import Mockjs from 'mockjs'
5
+ import { getArraryList } from './util'
6
+
7
+ export interface ListItem {
8
+ createTime: string | null;
9
+ id: number;
10
+ }
11
+
12
+ export interface ListSearchParams {
13
+ pageNum?: number;
14
+ pageSize?: number;
15
+ sord?: 'asc' | 'desc';
16
+ sidx?: 'createTime';
17
+ }
18
+
19
+ export function initContent<T>(
20
+ max,
21
+ callbackParams?: (key: number) => Omit<T, 'id' | 'createTime'> & Partial<ListItem>
22
+ ): (Omit<T, 'id' | 'createTime'> & ListItem)[] {
23
+ const mockParams = (index: number) => ({
24
+ id: index + 1,
25
+ uuid: getRandomNumber().uuid(10),
26
+ createTime: dayjs().format('YYYY-MM-DD HH:mm:ss')
27
+ }) as any
28
+ const list: (T & ListItem)[] = getArraryList(max, index => mockParams(index))
29
+
30
+ return list.map((item, index) => {
31
+ return {
32
+ ...item,
33
+ createTime: dayjs()
34
+ .subtract(Mockjs.Random.integer(3, 60), 'day')
35
+ .subtract(Mockjs.Random.integer(2, 6), 'hour')
36
+ .subtract(Mockjs.Random.integer(1, 59), 'minute')
37
+ .subtract(Mockjs.Random.integer(1, 59), 'second')
38
+ .format('YYYY-MM-DD HH:mm:ss'),
39
+ ...callbackParams?.(index)
40
+ }
41
+ })
42
+ }
43
+
44
+ export function handlePageList<T>(
45
+ dataSource: T[],
46
+ { pageNum, pageSize, callBack }: {
47
+ pageNum: number;
48
+ pageSize: number;
49
+ callBack?: (data: T[]) => T[]
50
+ }
51
+ ): T[] {
52
+ if (callBack)
53
+ dataSource = callBack?.(dataSource)
54
+ return cloneDeep(dataSource).filter(
55
+ (_, sort) => (sort < pageNum * pageSize) && (sort >= pageSize * (pageNum - 1))
56
+ )
57
+ }
58
+
59
+ export function compareToMaxTime(obj1, obj2, key, type: 0 | 1 = 0) {
60
+ const val1 = obj1[key]
61
+ const val2 = obj2[key]
62
+ let result = 0
63
+ if (dayjs(val1).isBefore(dayjs(val2))) {
64
+ result = type === 0 ? -1 : 0
65
+ } else if (dayjs(val1).isAfter(dayjs(val2))) {
66
+ result = type === 0 ? 0 : (-1)
67
+ }
68
+ return result
69
+ }
70
+
71
+ export function postDataSource<T>(
72
+ dataSource: (Omit<T, 'id' | 'createTime'> & ListItem)[],
73
+ type: 'delete' | 'add' | 'update' = 'update',
74
+ options?: { key?: string; params: Partial<(Omit<T, 'id' | 'createTime'> & ListItem)> }
75
+ ) {
76
+ if (type === 'update') {
77
+ dataSource = dataSource.map((item: any) => {
78
+ // @ts-ignore
79
+ if (options?.params?.[options.key] === item[options?.key])
80
+ return { ...item, ...options?.params }
81
+ return item
82
+ })
83
+ }
84
+ if (type === 'add') {
85
+ dataSource.unshift({
86
+ ...options?.params as (Omit<T, 'id' | 'createTime'> & ListItem),
87
+ id: dataSource.length + 1
88
+ })
89
+ }
90
+ if (type === 'delete') {
91
+ // @ts-ignore
92
+ dataSource = dataSource.filter(item => options?.params?.[options.key] !== item[options?.key])
93
+ }
94
+
95
+ return dataSource
96
+ }
@@ -0,0 +1,91 @@
1
+ import Mockjs from 'mockjs'
2
+ import { defaultSettings } from '@gx-config'
3
+ import { deepMerge, isObject, getRandomNumber } from '@gx-design-vue/pro-utils'
4
+ import { toLower } from 'lodash-es'
5
+ import { tokenAccount, userList } from '../config/user'
6
+ import userIds from '../config/user/id'
7
+ import { Decrypt, Encrypt } from './crypto'
8
+
9
+ const { mock, token } = defaultSettings
10
+
11
+ export function handleRandomImage(width = 50, height = 50) {
12
+ return `https://picsum.photos/${width}/${height}?random=${getRandomNumber().uuid(10)}`
13
+ }
14
+
15
+ export function getMobile() {
16
+ const mobile_prefix = [ '134', '135', '136', '137', '138', '139', '150', '151',
17
+ '152', '157', '158', '159', '130', '131', '132', '155', '156', '133', '153' ]
18
+ return getMockRandowList(mobile_prefix) + Mockjs.mock(/\d{8}/)
19
+ }
20
+
21
+ export function getTokenBuUserId(token) {
22
+ return Number(Object.keys(tokenAccount).find(item => tokenAccount[item] === token))
23
+ }
24
+
25
+ export function getToken(headers: RequestHeater): string | undefined {
26
+ return headers?.[toLower(token.name)]
27
+ }
28
+
29
+ export function tokenByUserInfo(token): UserDetails {
30
+ return Decrypt(token)
31
+ }
32
+
33
+ export function createrToken(token) {
34
+ const userInfo = userList.find(item => item.user?.userId === getTokenBuUserId(token))
35
+ return Encrypt({ userId: userInfo?.user?.userId })
36
+ }
37
+
38
+ export function checkToken(token) {
39
+ if (mock.checkToken === -1) return true
40
+ if (token) {
41
+ if (mock.checkToken === 0) return true
42
+
43
+ const useInfo: UserDetails = tokenByUserInfo(token)
44
+ return useInfo ? useInfo?.userId && userIds.some(item => useInfo?.userId === item.id) : false
45
+ }
46
+ return false
47
+ }
48
+
49
+ export const checkBackDataFun = (
50
+ config: Partial<ResponseResult>,
51
+ token: string,
52
+ merageRoot?: boolean
53
+ ): ResponseResult => {
54
+ let result: Partial<ResponseResult> = {
55
+ code: 200,
56
+ data: null
57
+ }
58
+ if (isObject(config)) {
59
+ const { data } = config
60
+ if (merageRoot) {
61
+ result = deepMerge(result, config, {
62
+ omitEmpty: false,
63
+ omitNil: false
64
+ })
65
+ } else {
66
+ result.data = config
67
+ }
68
+ if (data) {
69
+ result.data = data
70
+ }
71
+ } else {
72
+ result.data = config as any
73
+ }
74
+
75
+ const invaiteToken = checkToken(token)
76
+
77
+ return deepMerge<ResponseResult>(result as unknown as ResponseResult, {
78
+ code: invaiteToken ? 200 : 401,
79
+ message: invaiteToken
80
+ ? (result.message || result.code) ? 'success' : 'Request failed'
81
+ : 'Invalid token!'
82
+ })
83
+ }
84
+
85
+ export function getArraryList<T>(length: number, callback: (key: number) => T) {
86
+ return Array.from({ length }).map((_, key) => callback(key))
87
+ }
88
+
89
+ export function getMockRandowList<T = any>(data: T[]) {
90
+ return data[Mockjs.Random.integer(0, data.length - 1)] as T
91
+ }
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "gx-vant-mobile",
3
+ "type": "module",
4
+ "version": "0.0.0",
5
+ "scripts": {
6
+ "bootstrap": "pnpm i",
7
+ "dev": "pnpm run start:dev",
8
+ "start:dev": "cross-env VITE_APP_ENV=dev vite",
9
+ "start:pro": "cross-env VITE_APP_ENV=pro vite",
10
+ "build": "vite build",
11
+ "build:pro": "vite build --mode pro",
12
+ "report": "cross-env REPORT=true npm run build",
13
+ "preview": "vite preview",
14
+ "clean:lib": "rimraf pnpm-lock.yaml && rimraf node_modules",
15
+ "lint": "eslint .",
16
+ "lint:fix": "eslint . --fix"
17
+ },
18
+ "dependencies": {
19
+ "@gx-design-vue/pro-hooks": "^0.2.0-beta.54",
20
+ "@gx-design-vue/pro-utils": "^0.2.0-beta.80",
21
+ "@multiavatar/multiavatar": "^1.0.7",
22
+ "@vueuse/core": "^13.1.0",
23
+ "@vueuse/shared": "^13.1.0",
24
+ "axios": "^1.6.7",
25
+ "crypto-js": "^4.1.1",
26
+ "dayjs": "^1.11.13",
27
+ "lodash-es": "^4.17.21",
28
+ "pinia": "^3.0.2",
29
+ "qs": "^6.11.0",
30
+ "unocss": "^66.1.0-beta.12",
31
+ "vant": "^4.9.15",
32
+ "vue": "^3.5.13",
33
+ "vue-router": "^4.5.0"
34
+ },
35
+ "devDependencies": {
36
+ "@antfu/eslint-config": "^4.4.0",
37
+ "@commitlint/cli": "^19.5.0",
38
+ "@commitlint/config-conventional": "^19.5.0",
39
+ "@iconify-json/carbon": "^1.2.5",
40
+ "@types/lodash-es": "^4.17.10",
41
+ "@types/mockjs": "^1.0.10",
42
+ "@types/node": "^22.8.4",
43
+ "@types/qs": "^6.9.7",
44
+ "@unocss/preset-rem-to-px": "^0.65.3",
45
+ "@vant/auto-import-resolver": "^1.2.1",
46
+ "@vitejs/plugin-legacy": "^6.1.0",
47
+ "@vitejs/plugin-vue": "^5.2.3",
48
+ "@vitejs/plugin-vue-jsx": "^4.1.2",
49
+ "autoprefixer": "^10.4.5",
50
+ "bundle-require": "^5.0.0",
51
+ "cross-env": "^7.0.3",
52
+ "husky": "^9.1.6",
53
+ "less": "^4.1.3",
54
+ "mockjs": "^1.1.0",
55
+ "postcss": "^8.4.35",
56
+ "postcss-html": "^1.6.0",
57
+ "postcss-less": "^6.0.0",
58
+ "postcss-mobile-forever": "^4.3.1",
59
+ "postcss-pxtorem": "^6.0.0",
60
+ "prettier": "^3.3.3",
61
+ "rimraf": "^6.0.1",
62
+ "rollup-plugin-external-globals": "^0.13.0",
63
+ "rollup-plugin-visualizer": "^5.14.0",
64
+ "typescript": "^5.3.3",
65
+ "unplugin-auto-import": "^0.19.0",
66
+ "unplugin-turbo-console": "^1.10.4",
67
+ "unplugin-vue-components": "^0.28.0",
68
+ "vite": "^6.2.6",
69
+ "vite-plugin-compression": "0.5.1",
70
+ "vite-plugin-fake-server": "^2.1.4",
71
+ "vite-plugin-html": "^3.2.2",
72
+ "vue-tsc": "^2.1.6"
73
+ }
74
+ }
@@ -0,0 +1,54 @@
1
+ :root {
2
+ --van-base-font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Segoe UI, Arial, Roboto, "PingFang SC", "miui", "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
3
+ }
4
+
5
+ body {
6
+ font-family: var(--van-base-font);
7
+ }
8
+
9
+ .gx-toast-loading {
10
+ position: fixed;
11
+ top: 0;
12
+ left: 0;
13
+ width: 100%;
14
+ height: 100%;
15
+ display: flex;
16
+ justify-content: center;
17
+ align-items: center;
18
+ text-align: center;
19
+ z-index: 9999999999;
20
+ }
21
+ .gx-toast-loading .gx-toast-loading-cont {
22
+ display: flex;
23
+ flex-direction: column;
24
+ justify-content: center;
25
+ align-items: center;
26
+ box-sizing: content-box;
27
+ width: min(23.467vw, 140.8px);
28
+ min-height: min(23.467vw, 140.8px);
29
+ max-width: 70%;
30
+ padding: min(4.267vw, 25.6px);
31
+ border-radius: min(2.133vw, 12.8px);
32
+ background-clip: padding-box;
33
+ color: #fff;
34
+ background-color: rgba(58, 58, 58, 0.9);
35
+ font-size: min(3.733vw, 22.4px);
36
+ line-height: min(5.333vw, 32px);
37
+ }
38
+ .gx-toast-loading .gx-toast-loading-cont .gx-toast-svg {
39
+ margin: 0;
40
+ width: min(8vw, 48px);
41
+ height: min(8vw, 48px);
42
+ display: inline-block;
43
+ animation: spinner-anime 1s linear infinite;
44
+ }
45
+ .gx-toast-loading .gx-toast-loading-cont .gx-toast-svg-text {
46
+ display: inline-block;
47
+ margin-top: min(2.133vw, 12.8px);
48
+ }
49
+
50
+ @keyframes spinner-anime {
51
+ 100% {
52
+ transform: rotate(360deg);
53
+ }
54
+ }
@@ -0,0 +1,8 @@
1
+ <template>
2
+ <van-config-provider>
3
+ <router-view />
4
+ </van-config-provider>
5
+ </template>
6
+
7
+ <style lang="less">
8
+ </style>
@@ -0,0 +1,29 @@
1
+ import type { FunctionalComponent } from 'vue'
2
+ import { Skeleton } from 'vant'
3
+ import styles from './style.module.less'
4
+
5
+ import 'vant/es/skeleton/style'
6
+
7
+ const Proskeleton: FunctionalComponent<{ line: number; loading: boolean }> = (props, { slots }) => {
8
+ const renderMapItem = () => {
9
+ const show: any[] = []
10
+ for (let i = 0; i < props.line; i += 1) {
11
+ show.push(
12
+ <div class={styles.skeletonItem}>
13
+ <Skeleton row={3} loading />
14
+ </div>
15
+ )
16
+ }
17
+ return show
18
+ }
19
+
20
+ return (
21
+ <>
22
+ {
23
+ props.loading ? renderMapItem() : <>{ slots.default?.() }</>
24
+ }
25
+ </>
26
+ )
27
+ }
28
+
29
+ export default Proskeleton
@@ -0,0 +1,207 @@
1
+ import type { SetLoadingParams } from '@gx-mobile/hooks/web/usePageLoading'
2
+ import type { NavBarProps } from 'vant'
3
+ import { classNames, getSlot, getSlotVNode, isFunction, VueNode, WithFalse } from '@gx-design-vue/pro-utils'
4
+ import { usePageLoading } from '@gx-mobile/hooks/web'
5
+ import { useScroll } from '@vueuse/core'
6
+ import { Icon, NavBar } from 'vant'
7
+ import { defineComponent, ref, type SlotsType, Teleport, toRefs, watch } from 'vue'
8
+ import ProSkeleton from './ProSkeleton'
9
+ import styles from './style.module.less'
10
+ import 'vant/es/nav-bar/style'
11
+
12
+ export type PageLoadingTpe = 'toast' | 'skeleton'
13
+
14
+ type ChangeLoadingParams<T> = Omit<SetLoadingParams<T>, 'type'> & {
15
+ hiddenSlot?: boolean;
16
+ }
17
+
18
+ const PageContainer = defineComponent({
19
+ name: 'GPageContainer',
20
+ inheritAttrs: false,
21
+ props: {
22
+ loading: {
23
+ type: Boolean as VuePropType<boolean>,
24
+ default: false
25
+ },
26
+ nav: {
27
+ type: [ Boolean, Function, Object, Array ] as VuePropType<WithFalse<VueNode>>,
28
+ default: false
29
+ },
30
+ navProps: Object as VuePropType<NavBarProps>,
31
+ backTop: {
32
+ type: [ Boolean, Function, Object, Array ] as VuePropType<WithFalse<VueNode>>,
33
+ default: false
34
+ },
35
+ wrapperClass: String as VuePropType<string>,
36
+ backTopProps: {
37
+ type: Object as VuePropType<{
38
+ style: CSSProperties;
39
+ count: number;
40
+ }>,
41
+ default: () => ({
42
+ count: 300
43
+ })
44
+ },
45
+ hiddenSlot: {
46
+ type: Boolean as VuePropType<boolean>,
47
+ default: true
48
+ },
49
+ loadingMsg: {
50
+ type: String as VuePropType<string>,
51
+ default: '加载中'
52
+ },
53
+ loadingType: {
54
+ type: String as VuePropType<PageLoadingTpe>,
55
+ default: 'toast'
56
+ },
57
+ bgColor: {
58
+ type: String as VuePropType<string>,
59
+ default: 'var(--van-gray-1)'
60
+ },
61
+ onNavClickLeft: Function as VuePropType<() => void>,
62
+ 'onUpdate:loading': Function as VuePropType<(val: boolean) => void>,
63
+ onScroll: Function as VuePropType<(value: number) => void>
64
+ },
65
+ slots: Object as SlotsType<{
66
+ default(): void
67
+ backTop(): void
68
+ nav(props: NavBarProps): void
69
+ }>,
70
+ emits: [ 'update:loading', 'scroll', 'navClickLeft' ],
71
+ setup(props, { attrs, slots, expose, emit }) {
72
+ const route = useRoute() as unknown as AppRouteModule
73
+ const router = useRouter()
74
+ const { loading: loadingRef, loadingType, loadingMsg, hiddenSlot } = toRefs(props)
75
+
76
+ const backTopEl = ref()
77
+ const viewScrollRoot = ref()
78
+ const initStatus = ref(true)
79
+ const showBackTop = ref(false)
80
+ const hiddenSlotRef = ref(props.hiddenSlot)
81
+
82
+ const navTitle = computed(() => route.meta?.name ?? route.meta?.title as string)
83
+
84
+ const { y } = useScroll(viewScrollRoot, {
85
+ behavior: 'smooth'
86
+ })
87
+
88
+ const [ loading, setLoading ] = usePageLoading({
89
+ defaultType: loadingType.value,
90
+ defaultMessage: loadingMsg.value,
91
+ defaultLoading: loadingRef.value
92
+ })
93
+
94
+ watch(() => loading.value, (val) => {
95
+ if (initStatus.value && val) initStatus.value = false
96
+ emit('update:loading', val)
97
+ }, {
98
+ deep: true,
99
+ immediate: true
100
+ })
101
+
102
+ watch(() => loadingRef.value, (val) => {
103
+ if (loadingType.value === 'toast') {
104
+ setLoading({
105
+ value: val,
106
+ type: loadingType.value,
107
+ message: loadingMsg.value
108
+ })
109
+ } else if (initStatus.value || !val) {
110
+ setLoading({
111
+ value: val,
112
+ type: loadingType.value,
113
+ message: loadingMsg.value
114
+ })
115
+ }
116
+ })
117
+
118
+ watch(() => hiddenSlot.value, (val) => {
119
+ hiddenSlotRef.value = val
120
+ }, {
121
+ immediate: true
122
+ })
123
+
124
+ watch(() => y.value, (val) => {
125
+ showBackTop.value = val > props.backTopProps?.count
126
+ props.onScroll?.(val)
127
+ })
128
+
129
+ onMounted(() => {
130
+ viewScrollRoot.value = document.querySelector('#basic-layout-content')
131
+ backTopEl.value = document.querySelector('#basic-layout-back-top')
132
+ })
133
+
134
+ const changeLoading = ({
135
+ value,
136
+ message,
137
+ hiddenSlot
138
+ }: ChangeLoadingParams<boolean>) => {
139
+ if (loadingType.value === 'toast') {
140
+ hiddenSlotRef.value = !!hiddenSlot
141
+ setLoading({ value, message, type: loadingType.value })
142
+ }
143
+ }
144
+
145
+ function navClickLeft() {
146
+ if (props.onNavClickLeft) {
147
+ props.onNavClickLeft()
148
+ } else {
149
+ router.back()
150
+ }
151
+ }
152
+
153
+ expose({
154
+ toggleLoading: changeLoading,
155
+ setScrollTop: (val: number) => y.value = val
156
+ })
157
+
158
+ return () => {
159
+ const navProps = {
160
+ fixed: true,
161
+ placeholder: true,
162
+ leftArrow: true,
163
+ title: navTitle.value,
164
+ ...(props.navProps || {})
165
+ } as NavBarProps
166
+ const navSlot = getSlot(slots, props, 'nav')
167
+ const backTopRender = getSlotVNode(slots, props, 'backTop')
168
+ return (
169
+ <div class={styles.pageContainer} style={{ backgroundColor: props.bgColor, ...(attrs?.style as any || {}) }}>
170
+ {props.nav !== false && (
171
+ <>
172
+ {isFunction(navSlot)
173
+ ? navSlot?.({ ...navProps })
174
+ : (
175
+ <NavBar{...navProps} onClickLeft={() => navClickLeft()} />
176
+ )}
177
+ </>
178
+ )}
179
+ <div class={classNames(styles.pageContainerWrapper, props.wrapperClass || '')}>
180
+ {
181
+ loadingType.value === 'skeleton'
182
+ ? (
183
+ <ProSkeleton line={3} loading={loading.value}>
184
+ {slots.default?.()}
185
+ </ProSkeleton>
186
+ )
187
+ : ((!loading.value || !hiddenSlotRef.value) && <>{slots.default?.()}</>)
188
+ }
189
+ </div>
190
+ {
191
+ !!backTopEl.value && showBackTop.value && props.backTop !== false && (
192
+ <Teleport to="#basic-layout-back-top">
193
+ {backTopRender || (
194
+ <div class={styles.pageBackTop} onClick={() => y.value = 0} style={props.backTopProps?.style}>
195
+ <Icon name="back-top" class="relative top-1.5px" />
196
+ </div>
197
+ )}
198
+ </Teleport>
199
+ )
200
+ }
201
+ </div>
202
+ )
203
+ }
204
+ }
205
+ })
206
+
207
+ export default PageContainer
@@ -0,0 +1,17 @@
1
+ .pageContainer {
2
+ width: 100%;
3
+ min-height: calc(100vh - var(--van-tabbar-height));
4
+ padding: 15px;
5
+
6
+ .pageContainerWrapper {
7
+ position: relative;
8
+ }
9
+
10
+ .skeletonItem + .skeletonItem {
11
+ margin-top: 50px;
12
+ }
13
+ }
14
+
15
+ .pageBackTop {
16
+ --at-apply: rd-50\% overflow-hidden flex-center bg-[#4187f2] text-20px text-[#fff] w-45px h-45px right-20px bottom-60px absolute z-100;
17
+ }
@@ -0,0 +1,45 @@
1
+ <script setup lang="ts">
2
+ import { cloneDeep } from 'lodash-es'
3
+
4
+ const route = useRoute() as unknown as AppRouteModule
5
+ const router = useRouter()
6
+
7
+ function getMenuState() {
8
+ const menuState = {
9
+ data: [] as AppRouteModule[],
10
+ map: new Map<string, AppRouteModule>()
11
+ }
12
+ router.getRoutes().forEach((item: AppRouteModule) => {
13
+ if (item.meta?.isMenu) {
14
+ menuState.data.push(item)
15
+ menuState.map.set(item.name as string, item)
16
+ }
17
+ })
18
+ return cloneDeep(menuState)
19
+ }
20
+
21
+ const menuState = reactive(getMenuState())
22
+
23
+ const selectKey = computed<string>(() => route.meta?.menuSelectKey ?? route.name as string)
24
+
25
+ const handleSelect = path => router.push(path)
26
+ </script>
27
+
28
+ <template>
29
+ <van-tabbar :model-value="selectKey" placeholder>
30
+ <van-tabbar-item
31
+ v-for="item in menuState.data"
32
+ :key="item.name"
33
+ replace
34
+ :name="item.name as string"
35
+ :icon="item.meta?.icon"
36
+ @click="handleSelect(item.path)"
37
+ >
38
+ {{ item.meta?.name ?? item.meta?.title }}
39
+ </van-tabbar-item>
40
+ </van-tabbar>
41
+ </template>
42
+
43
+ <style scoped lang="less">
44
+
45
+ </style>
@@ -0,0 +1,7 @@
1
+ import PageContainer from '@/components/PageContainer'
2
+
3
+ const vantDesign = (app) => {
4
+ app.component('g-page-container', PageContainer)
5
+ }
6
+
7
+ export default vantDesign
@@ -0,0 +1,5 @@
1
+ import gxDesign from './gx-design'
2
+
3
+ export function setupGlobCommon(app) {
4
+ gxDesign(app)
5
+ }
@@ -0,0 +1 @@
1
+ /* 文字颜色相关 */
@@ -0,0 +1,5 @@
1
+ @import (reference) 'color.less';
2
+ @import (reference) 'mixin.less';
3
+
4
+ @gx-prefix: gx;
5
+ @gx-prefix-pro: ~'@{gx-prefix}-pro';
@@ -0,0 +1,3 @@
1
+ @import './root';
2
+ @import './reset';
3
+ @import './vant/index';