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

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 +28 -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,292 @@
1
+ const toString = Object.prototype.toString
2
+
3
+ function is(val, type) {
4
+ return toString.call(val) === `[object ${type}]`
5
+ }
6
+
7
+ const isClient = typeof window !== 'undefined'
8
+
9
+ const noop = () => {}
10
+
11
+ /**
12
+ * @author gx12358 2539306317@qq.com
13
+ * @description 判读是否为外链
14
+ * @param path
15
+ * @returns {boolean}
16
+ */
17
+ function isExternal(path) {
18
+ return /^(https?:|mailto:|tel:)/.test(path)
19
+ }
20
+
21
+ /**
22
+ * @author gx12358 2539306317@qq.com
23
+ * @description 校验密码是否小于6位
24
+ * @param value
25
+ * @returns {boolean}
26
+ */
27
+ function isPassword(value) {
28
+ return value.length >= 6
29
+ }
30
+
31
+ /**
32
+ * @author gx12358 2539306317@qq.com
33
+ * @description 判断是否为数字
34
+ * @param value
35
+ * @returns {boolean}
36
+ */
37
+ function isNumber(val) {
38
+ return typeof val === 'number'
39
+ }
40
+
41
+ /**
42
+ * @author gx12358 2539306317@qq.com
43
+ * @description 判断是否是名称
44
+ * @param value
45
+ * @returns {boolean}
46
+ */
47
+ function isName(value) {
48
+ const reg = /^[\u4e00-\u9fa5a-zA-Z0-9]+$/
49
+ return reg.test(value)
50
+ }
51
+
52
+ /**
53
+ * @author gx12358 2539306317@qq.com
54
+ * @description 判断是否为IP
55
+ * @param ip
56
+ * @returns {boolean}
57
+ */
58
+ function isIP(ip) {
59
+ const reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
60
+ return reg.test(ip)
61
+ }
62
+
63
+ /**
64
+ * @author gx12358 2539306317@qq.com
65
+ * @description 判断是否是传统网站
66
+ * @param url
67
+ * @returns {boolean}
68
+ */
69
+ function isUrl(url) {
70
+ const reg = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/
71
+ return reg.test(url)
72
+ }
73
+
74
+ /**
75
+ * @author gx12358 2539306317@qq.com
76
+ * @description 判断是否是小写字母
77
+ * @param value
78
+ * @returns {boolean}
79
+ */
80
+ function isLowerCase(value) {
81
+ const reg = /^[a-z]+$/
82
+ return reg.test(value)
83
+ }
84
+
85
+ /**
86
+ * @author gx12358 2539306317@qq.com
87
+ * @description 判断是否是大写字母
88
+ * @param value
89
+ * @returns {boolean}
90
+ */
91
+ function isUpperCase(value) {
92
+ const reg = /^[A-Z]+$/
93
+ return reg.test(value)
94
+ }
95
+
96
+ /**
97
+ * @author gx12358 2539306317@qq.com
98
+ * @description 判断是否是大写字母开头
99
+ * @param value
100
+ * @returns {boolean}
101
+ */
102
+ function isAlphabets(value) {
103
+ const reg = /^[A-Za-z]+$/
104
+ return reg.test(value)
105
+ }
106
+
107
+ /**
108
+ * @author gx12358 2539306317@qq.com
109
+ * @description 判断是否是字符串
110
+ * @param value
111
+ * @returns {boolean}
112
+ */
113
+ function isString(value) {
114
+ return typeof value === 'string' || value instanceof String
115
+ }
116
+
117
+ function isBoolean(val){
118
+ return is(val, 'Boolean')
119
+ }
120
+
121
+ function isFunction(func) {
122
+ return (typeof func === 'function' || Object.prototype.toString.call(func) === '[object Function]')
123
+ }
124
+
125
+ /**
126
+ * @author gx12358 2539306317@qq.com
127
+ * @description 判断是否是数组
128
+ * @param arg
129
+ * @returns {arg is any[]|boolean}
130
+ */
131
+ function isArray(arg) {
132
+ if (typeof Array.isArray === 'undefined') {
133
+ return Object.prototype.toString.call(arg) === '[object Array]'
134
+ }
135
+ return Array.isArray(arg)
136
+ }
137
+
138
+ /**
139
+ * @Author gaoxiang
140
+ * @DateTime 2019/11/29
141
+ * @lastTime 2019/11/29
142
+ * @description 是否是对象
143
+ */
144
+ function isObject(val) {
145
+ return val !== null && is(val, 'Object')
146
+ }
147
+
148
+ /**
149
+ * @author gx12358 2539306317@qq.com
150
+ * @description 判断是否是端口号
151
+ * @param value
152
+ * @returns {boolean}
153
+ */
154
+ function isPort(value) {
155
+ const reg = /^([0-9]|[1-9]\d|[1-9]\d{2}|[1-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/
156
+ return reg.test(value)
157
+ }
158
+
159
+ /**
160
+ * @author gx12358 2539306317@qq.com
161
+ * @description 判断是否是手机号
162
+ * @param value
163
+ * @returns {boolean}
164
+ */
165
+ function isPhone(value) {
166
+ const reg = /^1\d{10}$/
167
+ return reg.test(value)
168
+ }
169
+
170
+ /**
171
+ * @author gx12358 2539306317@qq.com
172
+ * @description 判断是否是身份证号(第二代)
173
+ * @param value
174
+ * @returns {boolean}
175
+ */
176
+ function isIdCard(value) {
177
+ const reg = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
178
+ return reg.test(value)
179
+ }
180
+
181
+ /**
182
+ * @author gx12358 2539306317@qq.com
183
+ * @description 判断是否是邮箱
184
+ * @param value
185
+ * @returns {boolean}
186
+ */
187
+ function isEmail(value) {
188
+ const reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
189
+ return reg.test(value)
190
+ }
191
+
192
+ /**
193
+ * @author gx12358 2539306317@qq.com
194
+ * @description 判断是否中文
195
+ * @param value
196
+ * @returns {boolean}
197
+ */
198
+ function isChina(value) {
199
+ const reg = /^[\u4E00-\u9FA5]{2,4}$/
200
+ return reg.test(value)
201
+ }
202
+
203
+ /**
204
+ * @author gx12358 2539306317@qq.com
205
+ * @description 判断是否为空
206
+ * @param value
207
+ * @returns {boolean}
208
+ */
209
+ function isBlank(value) {
210
+ return (
211
+ value == null ||
212
+ false ||
213
+ value === '' ||
214
+ value.trim() === '' ||
215
+ value.toLocaleLowerCase().trim() === 'null'
216
+ )
217
+ }
218
+
219
+ /**
220
+ * @author gx12358 2539306317@qq.com
221
+ * @description 判断是否为固话
222
+ * @param value
223
+ * @returns {boolean}
224
+ */
225
+ function isTel(value) {
226
+ const reg = /^(400|800)([0-9\\-]{7,10})|(([0-9]{4}|[0-9]{3})([- ])?)?([0-9]{7,8})(([- 转])*([0-9]{1,4}))?$/
227
+ return reg.test(value)
228
+ }
229
+
230
+ /**
231
+ * @author gx12358 2539306317@qq.com
232
+ * @description 判断经度 -180.0~+180.0(整数部分为0~180,必须输入1到5位小数)
233
+ * @param value
234
+ * @returns {boolean}
235
+ */
236
+ function isLongitude(value) {
237
+ const reg = /^[-|+]?(0?\d{1,2}\.\d{1,5}|1[0-7]?\d{1}\.\d{1,5}|180\.0{1,5})$/
238
+ return reg.test(value)
239
+ }
240
+
241
+ /**
242
+ * @author gx12358 2539306317@qq.com
243
+ * @description 判断纬度 -90.0~+90.0(整数部分为0~90,必须输入1到5位小数)
244
+ * @param value
245
+ * @returns {boolean}
246
+ */
247
+ function isLatitude(value) {
248
+ const reg = /^[-|+]?([0-8]?\d{1}\.\d{1,5}|90\.0{1,5})$/
249
+ return reg.test(value)
250
+ }
251
+
252
+ /**
253
+ * @author gx12358 2539306317@qq.com
254
+ * @description rtsp校验,只要有rtsp://
255
+ * @param value
256
+ * @returns {boolean}
257
+ */
258
+ function isRTSP(value) {
259
+ const reg = /^rtsp:\/\/([a-z]{0,10}:.{0,10}@)?(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
260
+ const reg1 = /^rtsp:\/\/([a-z]{0,10}:.{0,10}@)?(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5]):[0-9]{1,5}/
261
+ const reg2 = /^rtsp:\/\/([a-z]{0,10}:.{0,10}@)?(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\//
262
+ return reg.test(value) || reg1.test(value) || reg2.test(value)
263
+ }
264
+
265
+ /**
266
+ * @Author gaoxiang
267
+ * @DateTime 2020/11/4
268
+ * @lastTime 2020/11/4
269
+ * @description 判断是否是JSON字符串
270
+ */
271
+ function isJSONStr(str) {
272
+ if (typeof str === 'string') {
273
+ try {
274
+ const obj = JSON.parse(str)
275
+ if (typeof obj === 'object' && obj) {
276
+ return true
277
+ } else {
278
+ return false
279
+ }
280
+ } catch (e) {
281
+ return false
282
+ }
283
+ }
284
+ return false
285
+ }
286
+
287
+ function checkURL(URL) {
288
+ const str = URL,
289
+ Expression = /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/,
290
+ objExp = new RegExp(Expression)
291
+ return objExp.test(str)
292
+ }
@@ -0,0 +1,5 @@
1
+ # proxy 代理的api 前缀
2
+ VITE_PROXY_PREFIX = /devApi
3
+
4
+ # api前缀
5
+ VITE_BASE_URL=/api
@@ -0,0 +1,5 @@
1
+ # 实际执行环境 development
2
+ VITE_NODE_ENV= development
3
+
4
+ # environment 代码环境
5
+ VITE_USE_MODE = development
@@ -0,0 +1,5 @@
1
+ # 项目启动执行环境
2
+ VITE_NODE_ENV= production
3
+
4
+ # 代码运行环境
5
+ VITE_USE_MODE = pro
@@ -0,0 +1,5 @@
1
+ # 项目启动执行环境
2
+ VITE_NODE_ENV= production
3
+
4
+ # 代码运行环境
5
+ VITE_USE_MODE = production
@@ -0,0 +1,5 @@
1
+ # Vue 3 + TypeScript + Vite
2
+
3
+ This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
4
+
5
+ Learn more about the recommended Project Setup and IDE Support in the [Vue Docs TypeScript Guide](https://vuejs.org/guide/typescript/overview.html#project-setup).
@@ -0,0 +1,24 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ dist
12
+ dist-ssr
13
+ *.local
14
+
15
+ # Editor directories and files
16
+ .vscode/*
17
+ !.vscode/extensions.json
18
+ .idea
19
+ .DS_Store
20
+ *.suo
21
+ *.ntvs*
22
+ *.njsproj
23
+ *.sln
24
+ *.sw?
@@ -0,0 +1,46 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <meta
7
+ name="viewport"
8
+ content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
9
+ />
10
+ <title>VITE VUE PROJECT</title>
11
+ <link rel="icon" href="/vite.svg" type="image/x-icon" />
12
+ <link rel="stylesheet" href="/css/normalize.css">
13
+ <link rel="stylesheet" href="/css/index.css">
14
+ </head>
15
+ <body>
16
+ <div id="app">
17
+ <div class="gx-app-loading">
18
+ <div class="page-loading-warp">
19
+ <div class="gx-spin gx-spin-spinning">
20
+ <span class="gx-spin-dot gx-spin-dot-spin">
21
+ <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}>
22
+ <defs>
23
+ <filter id="svgSpinnersGooeyBalls20">
24
+ <feGaussianBlur in="SourceGraphic" result="y" stdDeviation="1" />
25
+ <feColorMatrix in="y" result="z" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -7" />
26
+ <feBlend in="SourceGraphic" in2="z" />
27
+ </filter>
28
+ </defs>
29
+ <g filter="url(#svgSpinnersGooeyBalls20)">
30
+ <circle cx="5" cy="12" r="4" fill="currentColor"><animate attributeName="cx" calcMode="spline" dur="2s" keySplines=".36,.62,.43,.99;.79,0,.58,.57" repeatCount="indefinite" values="5;8;5" /></circle>
31
+ <circle cx="19" cy="12" r="4" fill="currentColor"><animate attributeName="cx" calcMode="spline" dur="2s" keySplines=".36,.62,.43,.99;.79,0,.58,.57" repeatCount="indefinite" values="19;16;19" /></circle>
32
+ <animateTransform attributeName="transform" dur="0.75s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12" />
33
+ </g>
34
+ </svg>
35
+ </span>
36
+ </div>
37
+ <div class="page-loading-warp_message">
38
+ <p class="page-loading_title">正在加载资源</p>
39
+ <p class="page-loading_sub_title">初次加载资源可能需要较多时间,请耐心等候</p>
40
+ </div>
41
+ </div>
42
+ </div>
43
+ </div>
44
+ <script type="module" src="/src/main.ts"></script>
45
+ </body>
46
+ </html>
@@ -0,0 +1,47 @@
1
+ /**
2
+ * 在生产环境 代理是无法生效的,所以这里没有生产环境的配置
3
+ * The agent cannot take effect in the production environment
4
+ * so there is no configuration of the production environment
5
+ * For details, please see
6
+ * https://pro.ant.design/docs/deploy
7
+ */
8
+ import type { ProxyOptions } from 'vite'
9
+ import { isObject, isString } from '@gx-design-vue/pro-utils'
10
+
11
+ type ProxyTargetList = ProxyOptions & { rewrite: (path: string) => string }
12
+
13
+ const target: string | Record<string, any> = 'http://127.0.0.1:3000'
14
+
15
+ export function createProxy(prefix) {
16
+ const ret = {
17
+ dev: {},
18
+ test: {},
19
+ pre: {}
20
+ }
21
+
22
+ if (isObject(target)) {
23
+ Object.keys(target).forEach((str) => {
24
+ const proxy = {
25
+ target: `${target[str]}`,
26
+ changeOrigin: true,
27
+ ws: true,
28
+ rewrite: path => path.replace(new RegExp(`^${str}`), '')
29
+ } as ProxyTargetList
30
+
31
+ ret.dev[str] = proxy
32
+ ret.test[str] = proxy
33
+ ret.pre[str] = proxy
34
+ })
35
+ } else if (isString(target)) {
36
+ const proxy = {
37
+ target: `${target}`,
38
+ changeOrigin: true,
39
+ ws: true,
40
+ rewrite: path => path.replace(new RegExp(`^${prefix}`), '')
41
+ }
42
+ ret.dev[prefix] = proxy
43
+ ret.test[prefix] = proxy
44
+ ret.pre[prefix] = proxy
45
+ }
46
+ return ret
47
+ }
@@ -0,0 +1,9 @@
1
+ import { resolve } from 'node:path'
2
+
3
+ export function generateModifyVars() {
4
+ const modifyVarsParams = {
5
+ hack: `true; @import (reference) "${resolve('src/design/config.less')}";`
6
+ }
7
+
8
+ return modifyVarsParams
9
+ }
@@ -0,0 +1,18 @@
1
+ import type { RollupOptions } from 'rollup'
2
+ import { pathResolve } from '../util'
3
+
4
+ export default function (): RollupOptions {
5
+ return {
6
+ input: {
7
+ index: pathResolve('index.html')
8
+ },
9
+ // 静态资源分类打包
10
+ output: {
11
+ chunkFileNames: 'static/js/[name]-[hash].js',
12
+ entryFileNames: 'static/js/[name]-[hash].js',
13
+ assetFileNames: 'static/[ext]/[name]-[hash].[ext]'
14
+ },
15
+ external: [],
16
+ plugins: []
17
+ }
18
+ }
@@ -0,0 +1,17 @@
1
+ import { createHash } from 'node:crypto'
2
+
3
+ function createContentHash(content: string, hashLSize = 12) {
4
+ const hash = createHash('sha256').update(content)
5
+ return hash.digest('hex').slice(0, hashLSize)
6
+ }
7
+
8
+ function strToHex(str: string) {
9
+ const result: string[] = []
10
+ for (let i = 0; i < str.length; ++i) {
11
+ const hex = str.charCodeAt(i).toString(16)
12
+ result.push((`000${hex}`).slice(-4))
13
+ }
14
+ return result.join('').toUpperCase()
15
+ }
16
+
17
+ export { createContentHash, strToHex }
@@ -0,0 +1,132 @@
1
+ import fs from 'node:fs'
2
+ import path, { resolve } from 'node:path'
3
+ import dotenv from 'dotenv'
4
+
5
+ export const rootPath = process.cwd()
6
+
7
+ export function pathResolve(dir: string) {
8
+ return resolve(process.cwd(), '.', dir)
9
+ }
10
+
11
+ /**
12
+ * Whether to generate package preview
13
+ */
14
+ export function isReportMode(): boolean {
15
+ return process.env.REPORT === 'true'
16
+ }
17
+
18
+ // Read all environment variable configuration files to process.env
19
+ export function wrapperEnv(envConf: Recordable): ViteEnv {
20
+ const ret: any = {}
21
+
22
+ for (const envName of Object.keys(envConf)) {
23
+ let realName = envConf[envName].replace(/\\n/g, '\n')
24
+ realName = realName === 'true' ? true : realName === 'false' ? false : realName
25
+
26
+ ret[envName] = realName
27
+ process.env[envName] = realName
28
+ }
29
+ return ret
30
+ }
31
+
32
+ /**
33
+ * 获取当前环境下生效的配置文件名
34
+ */
35
+ function getConfFiles() {
36
+ const script = process.env.npm_lifecycle_script
37
+ const reg = new RegExp('--mode ([a-z]+)')
38
+ const result = reg.exec(script as string) as any
39
+ if (result) {
40
+ const mode = result[1] as string
41
+ return [ '.env', `.env.${mode}` ]
42
+ }
43
+ return [ '.env', '.env.production' ]
44
+ }
45
+
46
+ /**
47
+ * Get the environment variables starting with the specified prefix
48
+ * @param match prefix
49
+ * @param confFiles ext
50
+ */
51
+ export function getEnvConfig(confFiles = getConfFiles()): Partial<ViteEnv> {
52
+ let envConfig: Partial<ViteEnv> = {}
53
+ confFiles.forEach((item) => {
54
+ try {
55
+ const env = dotenv.parse(fs.readFileSync(path.resolve(process.cwd(), item)))
56
+ envConfig = { ...envConfig, ...env }
57
+ } catch (e) {
58
+ console.error(`Error in parsing ${item}`, e)
59
+ }
60
+ })
61
+ return envConfig
62
+ }
63
+
64
+ /**
65
+ * Get user root directory
66
+ * @param dir file path
67
+ */
68
+ export function getRootPath(...dir: string[]) {
69
+ return path.resolve(process.cwd(), ...dir)
70
+ }
71
+
72
+ export function getDefaultPath(supportTs = true) {
73
+ return path.resolve(process.cwd(), `src/main.${supportTs ? 'ts' : 'js'}`)
74
+ }
75
+
76
+ export function fileExists(f: string) {
77
+ try {
78
+ fs.accessSync(f, fs.constants.W_OK)
79
+ return true
80
+ // eslint-disable-next-line unused-imports/no-unused-vars
81
+ } catch (error) {
82
+ return false
83
+ }
84
+ }
85
+
86
+ function q(t) {
87
+ return t.reduce((n, e) => n + e)
88
+ }
89
+
90
+ function Gt(t, n?: number) {
91
+ if (t === 0)
92
+ return '0 Bytes'
93
+ const e = 1024
94
+ const r = n || 2
95
+ const o = [ 'Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' ]
96
+ const s = Math.floor(Math.log(t) / Math.log(e))
97
+ return `${Number.parseFloat((t / e ** s).toFixed(r))} ${o[s]}`
98
+ }
99
+
100
+ const ot: number[] = []
101
+
102
+ export function getPackageSize({ folder, callBack, format = !0 }) {
103
+ fs.readdir(folder, (err, files) => {
104
+ if (err)
105
+ throw err
106
+
107
+ let index = 0
108
+ const callBacks = () => {
109
+ if (++index === files.length) {
110
+ callBack(format ? Gt(q(ot)) : q(ot))
111
+ }
112
+ }
113
+
114
+ files.forEach((p) => {
115
+ fs.stat(`${folder}/${p}`, (err, stat) => {
116
+ if (err)
117
+ throw err
118
+ if (stat.isFile()) {
119
+ ot.push(stat.size)
120
+ callBacks()
121
+ } else {
122
+ getPackageSize({
123
+ folder: `${folder}/${p}`,
124
+ callBack: callBacks
125
+ })
126
+ }
127
+ })
128
+ })
129
+
130
+ files.length === 0 && callBack(0)
131
+ })
132
+ }
@@ -0,0 +1,65 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+ import { defaultSettings } from '../../../config'
4
+
5
+ const { cdn } = defaultSettings
6
+
7
+ const { modules = [], url = '' } = cdn
8
+
9
+ function getModuleVersion(name: string): string {
10
+ const pwd = process.cwd()
11
+ const pkgFile = path.join(pwd, 'node_modules', name, 'package.json')
12
+ if (fs.existsSync(pkgFile)) {
13
+ const pkgJson = JSON.parse(fs.readFileSync(pkgFile, 'utf8'))
14
+ return pkgJson.version
15
+ }
16
+
17
+ return ''
18
+ }
19
+
20
+ function isFullPath(path: string) {
21
+ return path.startsWith('http:') || path.startsWith('https:') || path.startsWith('//')
22
+ }
23
+
24
+ function renderUrl(data: CdnModuleList & {
25
+ version: string
26
+ }) {
27
+ const { path } = data
28
+ if (isFullPath(path))
29
+ return path
30
+ return url.replace(/\{name\}/g, data.name)
31
+ .replace(/\{version\}/g, data.version)
32
+ .replace(/\{path\}/g, path)
33
+ }
34
+
35
+ function getCdnModuleFiles() {
36
+ return modules.map((m) => {
37
+ const version = getModuleVersion(m.name)
38
+ if (!version) {
39
+ throw new Error(`modules: ${m.name} package.json file does not exist`)
40
+ }
41
+
42
+ let css = m.css || [] as string[]
43
+ if (!Array.isArray(css) && css) {
44
+ css = [ css ]
45
+ }
46
+
47
+ return {
48
+ js: renderUrl({
49
+ ...m,
50
+ version
51
+ }),
52
+ css
53
+ }
54
+ })
55
+ }
56
+
57
+ export function getExternalMap() {
58
+ const externalMap = {}
59
+ modules.forEach((v) => {
60
+ externalMap[v.name] = v.globalName
61
+ })
62
+ return externalMap
63
+ }
64
+
65
+ export default getCdnModuleFiles()