@gx-design-vue/create-gx-cli 0.0.1

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 (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +22 -0
  3. package/bin/create-gx-cli +4 -0
  4. package/package.json +31 -0
  5. package/src/cli.js +78 -0
  6. package/src/main.js +75 -0
  7. package/template-mobile-ts/.editorconfig +19 -0
  8. package/template-mobile-ts/.env.development +19 -0
  9. package/template-mobile-ts/.env.pro +19 -0
  10. package/template-mobile-ts/.env.production +19 -0
  11. package/template-mobile-ts/.eslintignore +16 -0
  12. package/template-mobile-ts/.eslintrc.js +64 -0
  13. package/template-mobile-ts/.prettierignore +9 -0
  14. package/template-mobile-ts/.stylelintignore +3 -0
  15. package/template-mobile-ts/README.md +16 -0
  16. package/template-mobile-ts/build/cdn.ts +5 -0
  17. package/template-mobile-ts/build/optimizer.ts +18 -0
  18. package/template-mobile-ts/build/plugin/autoImport.ts +26 -0
  19. package/template-mobile-ts/build/plugin/html.ts +26 -0
  20. package/template-mobile-ts/build/plugin/index.ts +38 -0
  21. package/template-mobile-ts/build/plugin/mock.ts +20 -0
  22. package/template-mobile-ts/index.html +24 -0
  23. package/template-mobile-ts/mock/_createProductionServer.ts +19 -0
  24. package/template-mobile-ts/mock/api/index.ts +66 -0
  25. package/template-mobile-ts/mock/utils.ts +9 -0
  26. package/template-mobile-ts/package.json +57 -0
  27. package/template-mobile-ts/pnpm-lock.yaml +3890 -0
  28. package/template-mobile-ts/postcss.config.js +11 -0
  29. package/template-mobile-ts/prettier.config.js +18 -0
  30. package/template-mobile-ts/public/favicon.ico +0 -0
  31. package/template-mobile-ts/public/js/flexible.js +44 -0
  32. package/template-mobile-ts/src/App.vue +5 -0
  33. package/template-mobile-ts/src/components/PageContainer/ProSkeleton.tsx +30 -0
  34. package/template-mobile-ts/src/components/PageContainer/index.tsx +113 -0
  35. package/template-mobile-ts/src/components/PageContainer/style.module.less +14 -0
  36. package/template-mobile-ts/src/core/gx-design/index.ts +7 -0
  37. package/template-mobile-ts/src/core/index.ts +12 -0
  38. package/template-mobile-ts/src/core/vant-design/index.ts +9 -0
  39. package/template-mobile-ts/src/design/index.less +3 -0
  40. package/template-mobile-ts/src/design/reset.less +155 -0
  41. package/template-mobile-ts/src/design/root.less +3 -0
  42. package/template-mobile-ts/src/design/vant.less +2 -0
  43. package/template-mobile-ts/src/global.less +1 -0
  44. package/template-mobile-ts/src/hooks/web/index.ts +5 -0
  45. package/template-mobile-ts/src/hooks/web/usePageLoading.ts +58 -0
  46. package/template-mobile-ts/src/layout/BasicLayout.vue +16 -0
  47. package/template-mobile-ts/src/layout/basicLayout.less +11 -0
  48. package/template-mobile-ts/src/main.ts +25 -0
  49. package/template-mobile-ts/src/router/index.ts +25 -0
  50. package/template-mobile-ts/src/router/routes.ts +20 -0
  51. package/template-mobile-ts/src/router/typings.ts +8 -0
  52. package/template-mobile-ts/src/services/index.ts +31 -0
  53. package/template-mobile-ts/src/store/index.ts +17 -0
  54. package/template-mobile-ts/src/store/modules/global.ts +33 -0
  55. package/template-mobile-ts/src/utils/cryptoJS.ts +25 -0
  56. package/template-mobile-ts/src/utils/index.ts +52 -0
  57. package/template-mobile-ts/src/utils/pageTitle.ts +12 -0
  58. package/template-mobile-ts/src/utils/request.ts +105 -0
  59. package/template-mobile-ts/src/utils/util.ts +32 -0
  60. package/template-mobile-ts/src/utils/validate.ts +292 -0
  61. package/template-mobile-ts/src/views/home.vue +82 -0
  62. package/template-mobile-ts/stylelint.config.js +106 -0
  63. package/template-mobile-ts/tsconfig.json +43 -0
  64. package/template-mobile-ts/types/auto-imports.d.ts +61 -0
  65. package/template-mobile-ts/types/components.d.ts +17 -0
  66. package/template-mobile-ts/types/global.d.ts +20 -0
  67. package/template-mobile-ts/types/gx-components.d.ts +13 -0
  68. package/template-mobile-ts/types/module.d.ts +9 -0
  69. package/template-mobile-ts/types/response.d.ts +12 -0
  70. package/template-mobile-ts/vite.config.ts +100 -0
  71. package/template-vue-ts/.vscode/extensions.json +3 -0
  72. package/template-vue-ts/README.md +18 -0
  73. package/template-vue-ts/index.html +13 -0
  74. package/template-vue-ts/package.json +20 -0
  75. package/template-vue-ts/public/vite.svg +1 -0
  76. package/template-vue-ts/src/App.vue +30 -0
  77. package/template-vue-ts/src/assets/vue.svg +1 -0
  78. package/template-vue-ts/src/components/HelloWorld.vue +38 -0
  79. package/template-vue-ts/src/main.ts +5 -0
  80. package/template-vue-ts/src/style.css +81 -0
  81. package/template-vue-ts/src/vite-env.d.ts +1 -0
  82. package/template-vue-ts/tsconfig.json +18 -0
  83. package/template-vue-ts/tsconfig.node.json +9 -0
  84. package/template-vue-ts/vite.config.ts +7 -0
@@ -0,0 +1,33 @@
1
+ import { reactive, toRefs } from 'vue'
2
+ import { defineStore } from 'pinia'
3
+ import { deepCopy } from '@/utils/util'
4
+
5
+ /**
6
+ * @Author gx12358
7
+ * @DateTime 2022/1/11
8
+ * @lastTime 2022/1/11
9
+ * @description store-global 全局属性
10
+ */
11
+ export interface GlobalState {
12
+ title: string; // app 应用名
13
+ tokenName?: string; // 请求header token key值
14
+ token?: string; // app token
15
+ }
16
+
17
+ type GlobalStateKey = keyof GlobalState
18
+
19
+ export const useStoreGlobal = defineStore('global', () => {
20
+ const state = reactive<GlobalState>({
21
+ title: 'gx-design-mobile',
22
+ tokenName: 'token'
23
+ })
24
+
25
+ const setGlobalData: (params: Partial<Record<GlobalStateKey, GlobalState[GlobalStateKey]>>) => void = (params) => {
26
+ Object.assign(state, deepCopy(params))
27
+ }
28
+
29
+ return {
30
+ ...toRefs(state),
31
+ setGlobalData
32
+ }
33
+ })
@@ -0,0 +1,25 @@
1
+ import CryptoJS from 'crypto-js'
2
+
3
+ // AES加密
4
+ export function encryptByAES(data) {
5
+ let AESKey = 'hj7x89H$yuBI0456' // 此处为密钥
6
+ let key = CryptoJS.enc.Utf8.parse(AESKey)
7
+ let cipherText = CryptoJS.AES.encrypt(data, key, {
8
+ mode: CryptoJS.mode.ECB,
9
+ padding: CryptoJS.pad.Pkcs7
10
+ })
11
+ return cipherText.toString()
12
+ }
13
+
14
+ // AES解密
15
+ export function decryptedByAES(data) {
16
+ let AESKey = 'hj7x89H$yuBI0456' // 此处为密钥
17
+ const key = CryptoJS.enc.Utf8.parse(AESKey) // 通过密钥获取128位的key
18
+ const encryptedHexStr = CryptoJS.enc.Base64.parse(data) // 解码base64编码结果
19
+ const encryptedBase64Str = CryptoJS.enc.Base64.stringify(encryptedHexStr)
20
+ const decryptedData = CryptoJS.AES.decrypt(encryptedBase64Str, key, {
21
+ mode: CryptoJS.mode.ECB,
22
+ padding: CryptoJS.pad.Pkcs7
23
+ })
24
+ return decryptedData.toString(CryptoJS.enc.Utf8)
25
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @Author gx12358
3
+ * @DateTime 2022/4/1
4
+ * @lastTime 2022/4/1
5
+ * @description 环境:开发
6
+ */
7
+ export function isDev(): boolean {
8
+ const DEV = typeViteEnv('VITE_USE_MODE') === 'development'
9
+ return DEV
10
+ }
11
+
12
+ /**
13
+ * @Author gx12358
14
+ * @DateTime 2022/4/1
15
+ * @lastTime 2022/4/1
16
+ * @description 环境:测试
17
+ */
18
+ export function isTest(): boolean {
19
+ const PRO = typeViteEnv('VITE_USE_MODE') === 'test'
20
+ return PRO
21
+ }
22
+
23
+ /**
24
+ * @Author gx12358
25
+ * @DateTime 2022/4/1
26
+ * @lastTime 2022/4/1
27
+ * @description 环境:正式
28
+ */
29
+ export function isPro(): boolean {
30
+ return typeViteEnv('VITE_USE_MODE') === 'production'
31
+ }
32
+
33
+ /**
34
+ * @Author gx12358
35
+ * @DateTime 2022/4/1
36
+ * @lastTime 2022/4/1
37
+ * @description 环境:测试、正式
38
+ */
39
+ export function isBuild(): boolean {
40
+ return typeViteEnv('VITE_USE_MODE') !== 'development'
41
+ }
42
+
43
+ export function typeViteEnv(key: ViteEnvKey) {
44
+ let value = import.meta.env[key]
45
+ if (value) {
46
+ value = value.replace(/\\n/g, '\n')
47
+
48
+ value = value === 'true' ? true : value === 'false' ? false : value
49
+ }
50
+
51
+ return value
52
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @author gx12358 2539306317@qq.com
3
+ * @description 设置标题
4
+ * @param pageTitle
5
+ * @returns {string}
6
+ */
7
+ export default function getPageTitle(title: string, pageTitle: string) {
8
+ let newTitles: any = []
9
+ if (pageTitle) newTitles.push(pageTitle)
10
+ if (title) newTitles.push(title)
11
+ return newTitles.join('-')
12
+ }
@@ -0,0 +1,105 @@
1
+ import type { AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios'
2
+ import axios, { Axios, AxiosPromise } from 'axios'
3
+ import qs from 'qs'
4
+ import { Toast } from 'vant'
5
+ import { useStoreGlobal } from '@gx-vuex'
6
+ import { tansParams } from '@/utils/util'
7
+ import { checkURL } from '@/utils/validate'
8
+
9
+ export interface CreateAxiosOptions extends AxiosRequestConfig {
10
+ headers?: any;
11
+ isMock?: boolean;
12
+ customize?: boolean;
13
+ carryToken?: boolean;
14
+ ignoreCancelToken?: boolean;
15
+ }
16
+
17
+ export interface GAxiosInstance extends Axios {
18
+ (config: CreateAxiosOptions): AxiosPromise<ResponseResult>;
19
+
20
+ (url: string, config?: CreateAxiosOptions): AxiosPromise<ResponseResult>;
21
+ }
22
+
23
+ let loadingInstance
24
+
25
+ /**
26
+ * @author gx12358 2539306317@qq.com
27
+ * @description axios初始化
28
+ */
29
+ const instance: GAxiosInstance = axios.create({
30
+ timeout: 100000,
31
+ headers: {
32
+ 'Content-Type': 'application/json;charset=UTF-8'
33
+ }
34
+ })
35
+ /**
36
+ * @author gx12358 2539306317@qq.com
37
+ * @description axios请求拦截器
38
+ */
39
+ instance.interceptors.request.use(
40
+ (config: CreateAxiosOptions) => {
41
+ const global = useStoreGlobal()
42
+
43
+ // get请求映射params参数
44
+ if (config.method === 'get' && config.params) {
45
+ let url = config.url + '?' + tansParams(config.params)
46
+ url = url.slice(0, -1)
47
+ config.params = {}
48
+ config.url = url
49
+ }
50
+
51
+ if (!checkURL(config.url)) {
52
+ if (config.isMock) {
53
+ config.url = `/mock-server${config.url}`
54
+ } else {
55
+ config.url = `${import.meta.env.VITE_BASE_URL}/${config.url}`
56
+ }
57
+ }
58
+
59
+ if (global.token && global.tokenName)
60
+ (config).headers[global.tokenName] = global.token
61
+
62
+ if (
63
+ config.data &&
64
+ config.headers['Content-Type'] ===
65
+ 'application/x-www-form-urlencoded;charset=UTF-8'
66
+ )
67
+ config.data = qs.stringify(config.data)
68
+
69
+ return config
70
+ },
71
+ (error: Error | AxiosError) => {
72
+ return Promise.reject(error)
73
+ }
74
+ )
75
+ /**
76
+ * @author gx12358 2539306317@qq.com
77
+ * @description axios响应拦截器
78
+ */
79
+ instance.interceptors.response.use(
80
+ (response: AxiosResponse) => {
81
+ if (loadingInstance) loadingInstance.close()
82
+ const { data, config } = response
83
+ const { code} = data as ResponseResult
84
+ // 操作正常Code数组
85
+ const codeVerificationArray = [ 200, 0 ]
86
+ // 是否操作正常
87
+ if ((config as CreateAxiosOptions).customize)
88
+ return data
89
+ else if (codeVerificationArray.includes(code))
90
+ return data
91
+ else {
92
+ Toast.fail(`服务器出错!`)
93
+ return Promise.resolve(false)
94
+ }
95
+ },
96
+ (_: AxiosError): Promise<ResponseResult | boolean> => {
97
+ if (loadingInstance) loadingInstance.close()
98
+ Toast.fail(`服务器出错!`)
99
+ return Promise.resolve(false)
100
+ }
101
+ )
102
+
103
+ const request: (opt?: CreateAxiosOptions) => Promise<ResponseResult> = async (opt) => await instance.request(opt)
104
+
105
+ export default request
@@ -0,0 +1,32 @@
1
+ export function deepCopy(data) {
2
+ return JSON.parse(JSON.stringify(data))
3
+ }
4
+
5
+ /**
6
+ * @Author gx12358
7
+ * @DateTime 2021/11/3
8
+ * @lastTime 2021/11/3
9
+ * @description get参数处理
10
+ */
11
+ export function tansParams(params) {
12
+ let result = ''
13
+ for (const propName of Object.keys(params)) {
14
+ const value = params[propName]
15
+ const part = encodeURIComponent(propName) + '='
16
+ if (value !== null && typeof (value) !== 'undefined' && value !== '') {
17
+ if (typeof value === 'object') {
18
+ for (const key of Object.keys(value)) {
19
+ if (value[key] !== null && typeof (value[key]) !== 'undefined') {
20
+ const params = propName + '[' + key + ']'
21
+ const subPart = encodeURIComponent(params) + '='
22
+ result += subPart + encodeURIComponent(value[key]) + '&'
23
+ }
24
+ }
25
+ } else {
26
+ result += part + encodeURIComponent(value) + '&'
27
+ }
28
+ }
29
+ }
30
+ return result
31
+ }
32
+
@@ -0,0 +1,292 @@
1
+ const toString = Object.prototype.toString
2
+
3
+ export function is(val: unknown, type: string) {
4
+ return toString.call(val) === `[object ${type}]`
5
+ }
6
+
7
+ export const isClient = typeof window !== 'undefined'
8
+
9
+ export const noop = () => {}
10
+
11
+ /**
12
+ * @author gx12358 2539306317@qq.com
13
+ * @description 判读是否为外链
14
+ * @param path
15
+ * @returns {boolean}
16
+ */
17
+ export 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
+ export 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
+ export function isNumber(val: unknown) {
38
+ return typeof val === 'number'
39
+ }
40
+
41
+ /**
42
+ * @author gx12358 2539306317@qq.com
43
+ * @description 判断是否是名称
44
+ * @param value
45
+ * @returns {boolean}
46
+ */
47
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export function isString(value) {
114
+ return typeof value === 'string' || value instanceof String
115
+ }
116
+
117
+ export function isBoolean(val: unknown): val is boolean {
118
+ return is(val, 'Boolean')
119
+ }
120
+
121
+ export function isFunction(func: any) {
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
+ export 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
+ export function isObject(val: any): val is Record<any, any> {
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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export function isJSONStr(str: any) {
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
+ export 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,82 @@
1
+ <template>
2
+ <g-pro-page-container
3
+ ref="pageContainer"
4
+ v-model:loading="loading"
5
+ :loadingMsg="loadingMsg"
6
+ :hiddenSlot="hiddenSlot"
7
+ >
8
+ <van-swipe class="my-swipe">
9
+ <van-swipe-item>1</van-swipe-item>
10
+ <van-swipe-item>2</van-swipe-item>
11
+ </van-swipe>
12
+ <div style="display: flex;flex-direction: column;gap: 20px;">
13
+ <p>以下刷新只针对toast</p>
14
+ <van-button @click="init(true)">刷新(隐藏子组件)</van-button>
15
+ <van-button @click="init(false)">刷新(不隐藏子组件)</van-button>
16
+ <van-button @click="changeLoading('切换中')">切换loading提示语</van-button>
17
+ <van-button @click="toggleLoading(true)">刷新-调用方法-隐藏</van-button>
18
+ <van-button @click="toggleLoading(false)">刷新-调用方法-不隐藏</van-button>
19
+ <van-button @click="toggleLoading(false, '切换中')">刷新-调用方法-不隐藏-切换提示语</van-button>
20
+ </div>
21
+ </g-pro-page-container>
22
+ </template>
23
+
24
+ <script setup lang="ts">
25
+ import { isBoolean } from '@/utils/validate'
26
+
27
+ const loading = ref(false)
28
+ const pageContainer = ref()
29
+ const loadingMsg = ref('加载中')
30
+ const hiddenSlot = ref(true)
31
+
32
+ onMounted(() => {
33
+ init()
34
+ })
35
+
36
+ const init = (val?: boolean) => {
37
+ loadingMsg.value = '加载中'
38
+ loading.value = true
39
+
40
+ if (isBoolean(val)) hiddenSlot.value = val
41
+
42
+ setTimeout(() => {
43
+ loading.value = false
44
+ }, 1000)
45
+ }
46
+
47
+ const changeLoading = (message: string) => {
48
+ loadingMsg.value = message
49
+ loading.value = true
50
+ hiddenSlot.value = false
51
+
52
+ setTimeout(() => {
53
+ loading.value = false
54
+ }, 1000)
55
+ }
56
+
57
+ const toggleLoading = (hiddenSlot: boolean, message?: string) => {
58
+ pageContainer.value?.toggleLoading({
59
+ value: true,
60
+ hiddenSlot,
61
+ message
62
+ })
63
+
64
+ setTimeout(() => {
65
+ pageContainer.value?.toggleLoading({
66
+ value: false,
67
+ hiddenSlot
68
+ })
69
+ }, 1000)
70
+ }
71
+
72
+ </script>
73
+
74
+ <style lang="less" scoped>
75
+ .my-swipe .van-swipe-item {
76
+ color: #fff;
77
+ font-size: 20px;
78
+ line-height: 150px;
79
+ text-align: center;
80
+ background-color: #39a9ed;
81
+ }
82
+ </style>