@gx-design-vue/create-gx-cli 0.1.15 → 0.1.16

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 (123) hide show
  1. package/package.json +1 -1
  2. package/src/main.js +7 -7
  3. package/template-mobile-vant-cli/.env +3 -0
  4. package/template-mobile-vant-cli/.env.development +4 -6
  5. package/template-mobile-vant-cli/.env.pro +16 -7
  6. package/template-mobile-vant-cli/.env.production +21 -9
  7. package/template-mobile-vant-cli/commitlint.config.cjs +32 -0
  8. package/template-mobile-vant-cli/config/default/defaultSettings.ts +70 -0
  9. package/template-mobile-vant-cli/config/default/network.ts +10 -0
  10. package/template-mobile-vant-cli/config/default/proxy.ts +50 -0
  11. package/template-mobile-vant-cli/config/default/theme.ts +3 -0
  12. package/template-mobile-vant-cli/config/index.ts +11 -0
  13. package/template-mobile-vant-cli/eslint.config.js +10 -2
  14. package/template-mobile-vant-cli/index.html +22 -21
  15. package/template-mobile-vant-cli/{build → internal/vite-config/generate}/generateModifyVars.ts +1 -1
  16. package/template-mobile-vant-cli/internal/vite-config/rollupOptions/index.ts +22 -0
  17. package/template-mobile-vant-cli/internal/vite-config/util/hash.ts +17 -0
  18. package/template-mobile-vant-cli/internal/vite-config/util/index.ts +132 -0
  19. package/template-mobile-vant-cli/internal/vite-config/vite/cdn.ts +65 -0
  20. package/template-mobile-vant-cli/{build → internal/vite-config/vite}/optimizer.ts +9 -1
  21. package/template-mobile-vant-cli/internal/vite-config/vite/plugin/appConfig.ts +91 -0
  22. package/template-mobile-vant-cli/{build → internal/vite-config/vite}/plugin/autoImport.ts +7 -3
  23. package/template-mobile-vant-cli/internal/vite-config/vite/plugin/compress.ts +31 -0
  24. package/template-mobile-vant-cli/internal/vite-config/vite/plugin/html.ts +32 -0
  25. package/template-mobile-vant-cli/internal/vite-config/vite/plugin/index.ts +74 -0
  26. package/template-mobile-vant-cli/internal/vite-config/vite/plugin/visualizer.ts +14 -0
  27. package/template-mobile-vant-cli/internal/vite-config/vite/plugin/viteNotice.ts +40 -0
  28. package/template-mobile-vant-cli/mock/config/permissions.ts +15 -0
  29. package/template-mobile-vant-cli/mock/config/user/id.ts +5 -0
  30. package/template-mobile-vant-cli/mock/config/user/index.ts +96 -0
  31. package/template-mobile-vant-cli/mock/index.ts +55 -0
  32. package/template-mobile-vant-cli/mock/routers/table/index.fake.ts +22 -0
  33. package/template-mobile-vant-cli/mock/routers/user/account.fake.ts +52 -0
  34. package/template-mobile-vant-cli/mock/routers/user/index.fake.ts +46 -0
  35. package/template-mobile-vant-cli/mock/utils/crypto.ts +21 -0
  36. package/template-mobile-vant-cli/mock/utils/table.ts +96 -0
  37. package/template-mobile-vant-cli/mock/utils/util.ts +91 -0
  38. package/template-mobile-vant-cli/package.json +51 -34
  39. package/template-mobile-vant-cli/public/css/default.css +54 -0
  40. package/template-mobile-vant-cli/src/App.vue +6 -2
  41. package/template-mobile-vant-cli/src/assets/logo.png +0 -0
  42. package/template-mobile-vant-cli/src/components/PageContainer/ProSkeleton.tsx +1 -1
  43. package/template-mobile-vant-cli/src/components/PageContainer/index.tsx +108 -16
  44. package/template-mobile-vant-cli/src/components/PageContainer/style.module.less +5 -2
  45. package/template-mobile-vant-cli/src/components/TabsMenu/index.vue +45 -0
  46. package/template-mobile-vant-cli/src/core/gx-design/index.ts +1 -1
  47. package/template-mobile-vant-cli/src/core/index.ts +0 -7
  48. package/template-mobile-vant-cli/src/design/color.less +1 -0
  49. package/template-mobile-vant-cli/src/design/config.less +5 -0
  50. package/template-mobile-vant-cli/src/design/index.less +1 -1
  51. package/template-mobile-vant-cli/src/design/mixin.less +65 -0
  52. package/template-mobile-vant-cli/src/design/reset.less +16 -132
  53. package/template-mobile-vant-cli/src/hooks/web/usePageLoading.ts +7 -9
  54. package/template-mobile-vant-cli/src/layout/{BasicLayout.vue → BasicLayout/index.vue} +3 -1
  55. package/template-mobile-vant-cli/src/layout/BasicLayout/style.less +3 -0
  56. package/template-mobile-vant-cli/src/layout/UserLayout/index.vue +18 -0
  57. package/template-mobile-vant-cli/src/layout/UserLayout/style.module.less +36 -0
  58. package/template-mobile-vant-cli/src/main.ts +16 -9
  59. package/template-mobile-vant-cli/src/pages/Account/details.vue +13 -0
  60. package/template-mobile-vant-cli/src/pages/Account/index.vue +102 -0
  61. package/template-mobile-vant-cli/src/pages/{home.vue → Home/index.vue} +5 -5
  62. package/template-mobile-vant-cli/src/pages/user/login/index.vue +74 -0
  63. package/template-mobile-vant-cli/src/plugins/dayjs/index.ts +3 -0
  64. package/template-mobile-vant-cli/src/plugins/index.ts +2 -0
  65. package/template-mobile-vant-cli/src/router/guard/index.ts +18 -0
  66. package/template-mobile-vant-cli/src/router/guard/permissions.ts +41 -0
  67. package/template-mobile-vant-cli/src/router/guard/stateGuard.ts +10 -0
  68. package/template-mobile-vant-cli/src/router/index.ts +21 -15
  69. package/template-mobile-vant-cli/src/router/routes/index.ts +46 -0
  70. package/template-mobile-vant-cli/src/router/routes/modules/dataSource.ts +32 -0
  71. package/template-mobile-vant-cli/src/services/userCenter/account.ts +42 -0
  72. package/template-mobile-vant-cli/src/services/userCenter/index.ts +28 -0
  73. package/template-mobile-vant-cli/src/store/index.ts +4 -1
  74. package/template-mobile-vant-cli/src/store/modules/global.ts +6 -13
  75. package/template-mobile-vant-cli/src/store/modules/user.ts +107 -0
  76. package/template-mobile-vant-cli/src/utils/accessToken.ts +97 -0
  77. package/template-mobile-vant-cli/src/utils/crypto/index.ts +3 -4
  78. package/template-mobile-vant-cli/src/utils/env.ts +2 -2
  79. package/template-mobile-vant-cli/src/utils/pageTitle.ts +12 -6
  80. package/template-mobile-vant-cli/src/utils/request/XHR.ts +9 -11
  81. package/template-mobile-vant-cli/src/utils/request/axiosCancel.ts +5 -5
  82. package/template-mobile-vant-cli/src/utils/request/checkStatus.ts +18 -2
  83. package/template-mobile-vant-cli/src/utils/request/index.ts +36 -23
  84. package/template-mobile-vant-cli/src/utils/storage.ts +49 -32
  85. package/template-mobile-vant-cli/src/utils/validate.ts +31 -36
  86. package/template-mobile-vant-cli/tsconfig.json +17 -9
  87. package/template-mobile-vant-cli/types/auto-imports.d.ts +18 -2
  88. package/template-mobile-vant-cli/types/components.d.ts +2 -7
  89. package/template-mobile-vant-cli/types/config.d.ts +56 -0
  90. package/template-mobile-vant-cli/types/global.d.ts +62 -21
  91. package/template-mobile-vant-cli/types/mock.d.ts +34 -0
  92. package/template-mobile-vant-cli/types/module.d.ts +33 -0
  93. package/template-mobile-vant-cli/types/response.d.ts +3 -1
  94. package/template-mobile-vant-cli/types/system.d.ts +58 -0
  95. package/template-mobile-vant-cli/types/vant-import.d.ts +16 -5
  96. package/template-mobile-vant-cli/unocss.config.ts +120 -66
  97. package/template-mobile-vant-cli/vite.config.ts +78 -81
  98. package/template-mobile-vant-cli/build/cdn.ts +0 -5
  99. package/template-mobile-vant-cli/build/plugin/html.ts +0 -26
  100. package/template-mobile-vant-cli/build/plugin/index.ts +0 -42
  101. package/template-mobile-vant-cli/build/plugin/mock.ts +0 -14
  102. package/template-mobile-vant-cli/build/plugin/viteMock/client.ts +0 -88
  103. package/template-mobile-vant-cli/build/plugin/viteMock/createMockServer.ts +0 -271
  104. package/template-mobile-vant-cli/build/plugin/viteMock/index.ts +0 -69
  105. package/template-mobile-vant-cli/build/plugin/viteMock/types.ts +0 -48
  106. package/template-mobile-vant-cli/build/plugin/viteMock/utils.ts +0 -48
  107. package/template-mobile-vant-cli/build/script/postBuild.ts +0 -14
  108. package/template-mobile-vant-cli/mock/_createProductionServer.ts +0 -19
  109. package/template-mobile-vant-cli/mock/utils.ts +0 -9
  110. package/template-mobile-vant-cli/postcss.config.cjs +0 -8
  111. package/template-mobile-vant-cli/prettier.config.cjs +0 -18
  112. package/template-mobile-vant-cli/public/js/flexible.js +0 -44
  113. package/template-mobile-vant-cli/src/core/vant-design/index.ts +0 -4
  114. package/template-mobile-vant-cli/src/design/vant.less +0 -2
  115. package/template-mobile-vant-cli/src/global.less +0 -1
  116. package/template-mobile-vant-cli/src/layout/basicLayout.less +0 -11
  117. package/template-mobile-vant-cli/src/router/routes.ts +0 -20
  118. package/template-mobile-vant-cli/src/router/typings.ts +0 -8
  119. package/template-mobile-vant-cli/src/settings/index.ts +0 -10
  120. package/template-mobile-vant-cli/src/utils/crypto/base64.ts +0 -101
  121. package/template-mobile-vant-cli/types/ant-design-import.d.ts +0 -13
  122. package/template-mobile-vant-cli/types/plugins-auto-import.d.ts +0 -14
  123. /package/template-mobile-vant-cli/{mock/datasSource/api/index.ts → src/design/vant/index.less} +0 -0
@@ -1,16 +1,18 @@
1
- import { showFailToast } from 'vant'
2
- import settings from '@/settings'
3
- import { useStoreGlobal } from '@/store'
4
- import { isDev } from '@/utils/env'
1
+ import type { GAxiosOptions, XhtInstance } from './typings'
2
+ import { useStoreUser } from '@/store'
3
+ import { isDev, typeViteEnv } from '@/utils/env'
5
4
  import { tansParams } from '@/utils/util'
6
5
  import { checkURL } from '@/utils/validate'
6
+ import { defaultSettings, network } from '@gx-config'
7
7
  import { isBoolean } from '@gx-design-vue/pro-utils'
8
- import { GAxios } from './XHR'
9
- import type { GAxiosOptions, XhtInstance } from './typings'
10
- import { RequestEnum } from './typings'
8
+ import { showToast } from 'vant'
11
9
  import { handleCode } from './checkStatus'
10
+ import { RequestEnum } from './typings'
11
+ import { GAxios } from './XHR'
12
12
 
13
- const { requestPrefix, successCode, requestTimeout, tokenName, contentType } = settings
13
+ const { token, mock } = defaultSettings
14
+
15
+ const { requestTimeout, successCode } = network
14
16
 
15
17
  const xhtInstance: XhtInstance = {
16
18
  /**
@@ -34,7 +36,7 @@ const xhtInstance: XhtInstance = {
34
36
  throw new Error('请求出错,请稍候重试')
35
37
  }
36
38
  // 这里 code,result,message为 后台统一的字段,需要在 types.ts内修改为项目自己的接口返回格式
37
- const { code, msg = '', message = '' } = data
39
+ const { code, message = '' } = data
38
40
 
39
41
  const codeVerificationArray = successCode
40
42
 
@@ -46,7 +48,7 @@ const xhtInstance: XhtInstance = {
46
48
 
47
49
  // 在此处根据自己项目的实际情况对不同的code执行不同的操作
48
50
  // 如果不希望中断当前请求,请return数据,否则直接抛出异常即可
49
- handleCode(code, message || msg)
51
+ handleCode(code, message)
50
52
 
51
53
  return Promise.resolve(false)
52
54
  },
@@ -62,11 +64,10 @@ const xhtInstance: XhtInstance = {
62
64
  }
63
65
 
64
66
  if (!checkURL(config.url)) {
65
- if (config.isMock) {
66
- config.url = `/mock-server${config.url}`
67
- } else {
68
- config.url = `${import.meta.env.VITE_BASE_URL}${isDev ? requestPrefix || '' : ''}${config.url}`
69
- }
67
+ const isMock = isBoolean(typeViteEnv('VITE_IS_MOCK')) ? typeViteEnv('VITE_IS_MOCK') : config.isMock
68
+ const prefix = isDev() && !isMock ? typeViteEnv('VITE_PROXY_PREFIX') : ''
69
+ const baseUrl = isMock ? mock.prefix : typeViteEnv('VITE_BASE_URL')
70
+ config.url = `${prefix}${baseUrl}${config.url}`
70
71
  }
71
72
 
72
73
  return config
@@ -76,10 +77,18 @@ const xhtInstance: XhtInstance = {
76
77
  * @description: 请求拦截器处理
77
78
  */
78
79
  requestInterceptors: (config) => {
79
- const global = useStoreGlobal()
80
+ const { name } = token
81
+ const user = useStoreUser()
80
82
  const carryToken = isBoolean(config.carryToken) ? config.carryToken : true
81
- if (global.token && carryToken)
82
- config.headers[tokenName] = global.token
83
+ if (user.accessToken && carryToken) {
84
+ if (config.headers) {
85
+ config.headers[name] = user.accessToken
86
+ } else {
87
+ config.headers = {
88
+ [name]: user.accessToken
89
+ }
90
+ }
91
+ }
83
92
  return config
84
93
  },
85
94
 
@@ -93,11 +102,11 @@ const xhtInstance: XhtInstance = {
93
102
  /**
94
103
  * @description: 响应错误处理
95
104
  */
96
- responseInterceptorsCatch: (error: any) => {
105
+ responseInterceptorsCatch: (_, error) => {
97
106
  const { response } = error
98
107
  let errorMessage = error.message || ''
99
108
  if (error.response && error.response.data) {
100
- const { status } = response
109
+ const { status = 404 } = response || {}
101
110
  handleCode(status, errorMessage)
102
111
  return Promise.resolve(false)
103
112
  } else {
@@ -111,7 +120,10 @@ const xhtInstance: XhtInstance = {
111
120
  const code = errorMessage.substr(errorMessage.length - 3)
112
121
  errorMessage = '后端接口' + code || '' + '异常'
113
122
  }
114
- showFailToast({ message: errorMessage || '服务器出错!' })
123
+ showToast({
124
+ type: 'fail',
125
+ message: errorMessage || '后端接口未知异常'
126
+ })
115
127
  return Promise.resolve(false)
116
128
  }
117
129
  },
@@ -126,7 +138,7 @@ function createXhr(opt?: Partial<GAxiosOptions>) {
126
138
  method: 'get',
127
139
  timeout: requestTimeout,
128
140
  headers: {
129
- 'Content-Type': contentType
141
+ 'Content-Type': 'application/json;charset=UTF-8'
130
142
  },
131
143
  // 忽略重复请求
132
144
  ignoreCancelToken: true,
@@ -137,6 +149,7 @@ function createXhr(opt?: Partial<GAxiosOptions>) {
137
149
  })
138
150
  }
139
151
 
140
- const request: <T = any, R = undefined>(opt?: GAxiosOptions) => Promise<ResponseResult<T, R>> = opt => createXhr().request(opt)
152
+ const request: <T = any, R = undefined>(opt?: GAxiosOptions) => Promise<ResponseResult<T, R>> = opt => createXhr()
153
+ .request(opt)
141
154
 
142
155
  export default request
@@ -1,10 +1,7 @@
1
+ import { isJSONStr, isNumber, isObject, isString } from '@gx-design-vue/pro-utils'
1
2
  import dayjs from 'dayjs'
2
- import { isPro, typeViteEnv } from '@/utils/env'
3
- import { Decrypt, Encrypt } from '@/utils/crypto'
4
- import { isJSONStr } from '@/utils/validate'
5
- import { isObject } from '@gx-design-vue/pro-utils'
6
-
7
- export type StorageKey = 'localStorage' | 'sessionStorage' | 'cookie'
3
+ import { Decrypt, Encrypt } from './crypto'
4
+ import { isPro, typeViteEnv } from './env'
8
5
 
9
6
  function isEncryption(status: boolean) {
10
7
  return isPro() ? status : false
@@ -37,27 +34,37 @@ export function getStorageKey(key: string, originKey?: boolean) {
37
34
  */
38
35
  export function getStorage({
39
36
  key,
40
- encryption = true,
41
- type = 'localStorage',
42
- originKey
43
- }: { key: string, encryption?: boolean, type?: StorageKey, originKey?: boolean }) {
44
- const storageValue = type === 'localStorage'
45
- ? localStorage.getItem(getStorageKey(key, originKey)) : type === 'sessionStorage'
46
- ? sessionStorage.getItem(getStorageKey(key, originKey))
47
- : getCookie(
48
- getStorageKey(key, originKey))
37
+ originKey,
38
+ type = 'local',
39
+ encryption = true
40
+ }: {
41
+ key: string;
42
+ encryption?: boolean;
43
+ type?: 'local' | 'cookie' | 'session';
44
+ originKey?: boolean;
45
+ }) {
46
+ const storageValue = type === 'local'
47
+ ? localStorage.getItem(getStorageKey(key, originKey))
48
+ : type === 'session' ? sessionStorage.getItem(getStorageKey(key, originKey)) : getCookie(
49
+ getStorageKey(
50
+ key,
51
+ originKey
52
+ ))
49
53
  const result: string | LocalResult = storageValue
50
- ? isEncryption(encryption) ? Decrypt(storageValue) : handleStorageValue(storageValue) : ''
54
+ ? isEncryption(encryption) ? Decrypt(storageValue) : handleStorageValue(storageValue)
55
+ : ''
51
56
  if (result && isObject(result)) {
52
57
  if (result.expired) {
53
58
  const expiredStatus = dayjs().diff(dayjs(result.time)) >= result.expired
54
59
  if (expiredStatus) {
55
- removeStorage(key, type)
60
+ removeStorage({ key, originKey, type })
56
61
  return ''
57
62
  }
58
63
  }
64
+ } else if (result && isString(result)) {
65
+ return isJSONStr(result) ? JSON.parse(result) : result
59
66
  }
60
- return result?.['value'] || result || ''
67
+ return typeof result === 'string' ? result : result?.['value'] || result || ''
61
68
  }
62
69
 
63
70
  /**
@@ -71,26 +78,27 @@ export function setStorage({
71
78
  value,
72
79
  expired,
73
80
  originKey,
74
- encryption = true,
75
- type = 'local'
81
+ type = 'local',
82
+ encryption = true
76
83
  }: {
77
84
  key: string;
78
85
  value: any;
79
86
  originKey?: boolean;
80
87
  expired?: number;
81
88
  encryption?: boolean;
82
- type?: string;
89
+ type?: 'local' | 'cookie' | 'session';
83
90
  }) {
84
91
  const result: LocalResult = originKey ? value : {
85
92
  value,
86
93
  time: dayjs().format('YYYY-MM-DD HH:mm:ss'),
87
94
  expired: expired || 0
88
95
  }
89
- const storageValue = isEncryption(encryption) ? Encrypt(JSON.stringify(result)) : JSON.stringify(
90
- result)
91
- if (type === 'local')
92
- localStorage.setItem(getStorageKey(key, originKey), storageValue)
93
- sessionStorage.setItem(getStorageKey(key, originKey), storageValue)
96
+ const storageValue = isEncryption(encryption)
97
+ ? Encrypt(JSON.stringify(result))
98
+ : isString(result) || isNumber(result) ? result : JSON.stringify(result)
99
+ if (type === 'local') localStorage.setItem(getStorageKey(key, originKey), storageValue)
100
+ else if (type === 'cookie') setCookie(getStorageKey(key, originKey), storageValue)
101
+ else sessionStorage.setItem(getStorageKey(key, originKey), storageValue)
94
102
  }
95
103
 
96
104
  /**
@@ -99,10 +107,18 @@ export function setStorage({
99
107
  * @lastTime 2019/12/3
100
108
  * @description 删除Storage
101
109
  */
102
- export function removeStorage(key: string, type = 'local', originKey?: boolean) {
103
- if (type === 'local')
104
- localStorage.removeItem(getStorageKey(key, originKey))
105
- sessionStorage.removeItem(getStorageKey(key, originKey))
110
+ export function removeStorage({
111
+ key,
112
+ originKey,
113
+ type = 'local'
114
+ }: {
115
+ key: string;
116
+ originKey?: boolean;
117
+ type?: 'local' | 'cookie' | 'session';
118
+ }) {
119
+ if (type === 'local') localStorage.removeItem(getStorageKey(key, originKey))
120
+ else if (type === 'cookie') delCookie(getStorageKey(key, originKey))
121
+ else sessionStorage.removeItem(getStorageKey(key, originKey))
106
122
  }
107
123
 
108
124
  /**
@@ -135,10 +151,11 @@ function getCookies(cname: string) {
135
151
  */
136
152
  function GetCookieDomain() {
137
153
  let host = location.hostname
138
- const ip = /^(\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])$/
154
+ const ip = /^(?:\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])$/
139
155
  if (ip.test(host) === true || host === 'localhost')
140
156
  return host
141
- const regex = /([^]*).*/
157
+ // eslint-disable-next-line regexp/optimal-quantifier-concatenation
158
+ const regex = /([\s\S]*).*/
142
159
  const match = host.match(regex)
143
160
  if (typeof match !== 'undefined' && match !== null) {
144
161
  const someIndex = 1
@@ -5,7 +5,7 @@
5
5
  * @returns {boolean}
6
6
  */
7
7
  export function isExternal(path) {
8
- return /^(https?:|mailto:|tel:)/.test(path)
8
+ return /^(?:https?:|mailto:|tel:)/.test(path)
9
9
  }
10
10
 
11
11
  /**
@@ -15,7 +15,7 @@ export function isExternal(path) {
15
15
  * @returns {boolean}
16
16
  */
17
17
  export function isName(value) {
18
- const reg = /^[\u4e00-\u9fa5a-zA-Z0-9]+$/
18
+ const reg = /^[\u4e00-\u9fa5a-z0-9]+$/i
19
19
  return reg.test(value)
20
20
  }
21
21
 
@@ -26,7 +26,7 @@ export function isName(value) {
26
26
  * @returns {boolean}
27
27
  */
28
28
  export function isIP(ip) {
29
- 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])$/
29
+ 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])$/
30
30
  return reg.test(ip)
31
31
  }
32
32
 
@@ -37,7 +37,7 @@ export function isIP(ip) {
37
37
  * @returns {boolean}
38
38
  */
39
39
  export function isUrl(url) {
40
- 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.,?'\\+&%$#=~_-]+))*$/
40
+ const reg = /^(?:https?|ftp):\/\/(?:[a-zA-Z0-9.-]+(?::[a-zA-Z0-9.&%$-]+)*@)*(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d?)(?:\.(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)){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}))(?::\d+)*(?:\/(?:$|[\w.,?'\\+&%$#=~-]+))*$/
41
41
  return reg.test(url)
42
42
  }
43
43
 
@@ -70,7 +70,7 @@ export function isUpperCase(value) {
70
70
  * @returns {boolean}
71
71
  */
72
72
  export function isAlphabets(value) {
73
- const reg = /^[A-Za-z]+$/
73
+ const reg = /^[A-Z]+$/i
74
74
  return reg.test(value)
75
75
  }
76
76
 
@@ -81,7 +81,7 @@ export function isAlphabets(value) {
81
81
  * @returns {boolean}
82
82
  */
83
83
  export function isPort(value) {
84
- 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])$/
84
+ const reg = /^(?:\d|[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])$/
85
85
  return reg.test(value)
86
86
  }
87
87
 
@@ -91,6 +91,14 @@ export function isPort(value) {
91
91
  * @param value
92
92
  * @returns {boolean}
93
93
  */
94
+ export function isPhone(
95
+ value: string,
96
+ backReg?: false,
97
+ ): boolean
98
+ export function isPhone(
99
+ value: string,
100
+ backReg?: true,
101
+ ): RegExp
94
102
  export function isPhone(value = '', backReg?: boolean) {
95
103
  const reg = /^1\d{10}$/
96
104
  return backReg ? reg : reg.test(value)
@@ -103,7 +111,7 @@ export function isPhone(value = '', backReg?: boolean) {
103
111
  * @returns {boolean}
104
112
  */
105
113
  export function isIdCard(value) {
106
- 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]$/
114
+ 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-9X]$/i
107
115
  return reg.test(value)
108
116
  }
109
117
 
@@ -113,6 +121,14 @@ export function isIdCard(value) {
113
121
  * @param value
114
122
  * @returns {boolean}
115
123
  */
124
+ export function isEmail(
125
+ value: string,
126
+ backReg?: false,
127
+ ): boolean
128
+ export function isEmail(
129
+ value: string,
130
+ backReg?: true,
131
+ ): RegExp
116
132
  export function isEmail(value = '', backReg?: boolean) {
117
133
  const reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
118
134
  return backReg ? reg : reg.test(value)
@@ -147,7 +163,7 @@ export function isBlank(value) {
147
163
  * @returns {boolean}
148
164
  */
149
165
  export function isTel(value) {
150
- const reg = /^(400|800)([0-9\\-]{7,10})|(([0-9]{4}|[0-9]{3})([- ])?)?([0-9]{7,8})(([- 转])*([0-9]{1,4}))?$/
166
+ const reg = /^(?:400|800)[0-9\\-]{7,10}|(?:(?:\d{4}|\d{3})[- ]?)?\d{7,8}(?:[- 转]*\d{1,4})?$/
151
167
  return reg.test(value)
152
168
  }
153
169
 
@@ -158,7 +174,7 @@ export function isTel(value) {
158
174
  * @returns {boolean}
159
175
  */
160
176
  export function isLongitude(value) {
161
- const reg = /^[-|+]?(0?\d{1,2}\.\d{1,5}|1[0-7]?\d{1}\.\d{1,5}|180\.0{1,5})$/
177
+ const reg = /^[-|+]?(?:0?\d{1,2}\.\d{1,5}|1[0-7]?\d\.\d{1,5}|180\.0{1,5})$/
162
178
  return reg.test(value)
163
179
  }
164
180
 
@@ -169,7 +185,7 @@ export function isLongitude(value) {
169
185
  * @returns {boolean}
170
186
  */
171
187
  export function isLatitude(value) {
172
- const reg = /^[-|+]?([0-8]?\d{1}\.\d{1,5}|90\.0{1,5})$/
188
+ const reg = /^[-|+]?(?:[0-8]?\d\.\d{1,5}|90\.0{1,5})$/
173
189
  return reg.test(value)
174
190
  }
175
191
 
@@ -180,37 +196,16 @@ export function isLatitude(value) {
180
196
  * @returns {boolean}
181
197
  */
182
198
  export function isRTSP(value) {
183
- 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])$/
184
- 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}/
185
- 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])\//
199
+ 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])$/
200
+ 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]):\d{1,5}/
201
+ 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])\//
186
202
  return reg.test(value) || reg1.test(value) || reg2.test(value)
187
203
  }
188
204
 
189
- /**
190
- * @Author gaoxiang
191
- * @DateTime 2020/11/4
192
- * @lastTime 2020/11/4
193
- * @description 判断是否是JSON字符串
194
- */
195
- export function isJSONStr(str: any) {
196
- if (typeof str === 'string') {
197
- try {
198
- const obj = JSON.parse(str)
199
- if (typeof obj === 'object' && obj) {
200
- return true
201
- } else {
202
- return false
203
- }
204
- } catch (e) {
205
- return false
206
- }
207
- }
208
- return false
209
- }
210
-
211
205
  export function checkURL(URL) {
212
206
  const str = URL
213
- const Expression = /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/
207
+ // eslint-disable-next-line regexp/strict
208
+ const Expression = /https?:\/\/(?:[\w-]+\.)+[\w-]+(?:\/[\w- ./?%&=]*)?/
214
209
  const objExp = new RegExp(Expression)
215
210
  return objExp.test(str)
216
211
  }
@@ -3,25 +3,32 @@
3
3
  "target": "ESNext",
4
4
  "module": "ESNext",
5
5
  "moduleResolution": "Node",
6
- "forceConsistentCasingInFileNames": true,
7
- "allowSyntheticDefaultImports": true,
8
- "strictFunctionTypes": false,
9
6
  "jsx": "preserve",
7
+ "jsxImportSource": "vue",
10
8
  "baseUrl": "./",
9
+ "strict": true,
11
10
  "allowJs": true,
12
11
  "sourceMap": true,
13
12
  "esModuleInterop": true,
14
13
  "resolveJsonModule": true,
15
14
  "noUnusedLocals": true,
16
15
  "noUnusedParameters": true,
17
- "experimentalDecorators": true,
18
16
  "lib": ["DOM", "ESNext"],
19
- "types": ["vite/client"],
17
+ "types": ["vite/client", "unplugin-turbo-console/client"],
18
+ "noImplicitAny": false,
20
19
  "skipLibCheck": true,
20
+ "strictFunctionTypes": false,
21
+ "experimentalDecorators": true,
22
+ "allowSyntheticDefaultImports": true,
23
+ "forceConsistentCasingInFileNames": true,
21
24
  "paths": {
22
25
  "@/*": ["src/*"],
26
+ "@gx-mock": ["mock/index.ts"],
27
+ "@gx-mock/*": ["mock/*"],
28
+ "@gx-config": ["config/index.ts"],
29
+ "@gx-vuex": ["src/store/index.ts"],
23
30
  "@gx-mobile/hooks/*": ["src/hooks/*"],
24
- "@gx-vuex": ["src/store/index.ts"]
31
+ "@gx-admin/vite-config/*": ["internal/vite-config/*"],
25
32
  }
26
33
  },
27
34
  "include": [
@@ -33,10 +40,11 @@
33
40
  "src/**/*.vue",
34
41
  "types/*.d.ts",
35
42
  "types/*.ts",
36
- "build/**/*.ts",
37
- "build/**/*.d.ts",
43
+ "internal/**/*.ts",
44
+ "internal/**/*.d.ts",
45
+ "mock/*.ts",
38
46
  "mock/**/*.ts",
39
47
  "vite.config.ts"
40
48
  ],
41
- "exclude": ["node_modules", "tests/server/**/*.ts", "dist", "**/*.js", ".history"]
49
+ "exclude": ["node_modules", "dist", "**/*.js"]
42
50
  }
@@ -1,4 +1,9 @@
1
- // Generated by 'unplugin-auto-import'
1
+ /* eslint-disable */
2
+ /* prettier-ignore */
3
+ // @ts-nocheck
4
+ // noinspection JSUnusedGlobalSymbols
5
+ // Generated by unplugin-auto-import
6
+ // biome-ignore lint: disable
2
7
  export {}
3
8
  declare global {
4
9
  const EffectScope: typeof import('vue')['EffectScope']
@@ -33,12 +38,12 @@ declare global {
33
38
  const onServerPrefetch: typeof import('vue')['onServerPrefetch']
34
39
  const onUnmounted: typeof import('vue')['onUnmounted']
35
40
  const onUpdated: typeof import('vue')['onUpdated']
41
+ const onWatcherCleanup: typeof import('vue')['onWatcherCleanup']
36
42
  const provide: typeof import('vue')['provide']
37
43
  const reactive: typeof import('vue')['reactive']
38
44
  const readonly: typeof import('vue')['readonly']
39
45
  const ref: typeof import('vue')['ref']
40
46
  const resolveComponent: typeof import('vue')['resolveComponent']
41
- const resolveDirective: typeof import('vue')['resolveDirective']
42
47
  const setupStore: typeof import('../src/store/index')['setupStore']
43
48
  const shallowReactive: typeof import('vue')['shallowReactive']
44
49
  const shallowReadonly: typeof import('vue')['shallowReadonly']
@@ -46,19 +51,30 @@ declare global {
46
51
  const toRaw: typeof import('vue')['toRaw']
47
52
  const toRef: typeof import('vue')['toRef']
48
53
  const toRefs: typeof import('vue')['toRefs']
54
+ const toValue: typeof import('vue')['toValue']
49
55
  const triggerRef: typeof import('vue')['triggerRef']
50
56
  const unref: typeof import('vue')['unref']
51
57
  const useAttrs: typeof import('vue')['useAttrs']
52
58
  const useCssModule: typeof import('vue')['useCssModule']
53
59
  const useCssVars: typeof import('vue')['useCssVars']
60
+ const useId: typeof import('vue')['useId']
54
61
  const useLink: typeof import('vue-router')['useLink']
62
+ const useModel: typeof import('vue')['useModel']
55
63
  const useRoute: typeof import('vue-router')['useRoute']
56
64
  const useRouter: typeof import('vue-router')['useRouter']
57
65
  const useSlots: typeof import('vue')['useSlots']
58
66
  const useStore: typeof import('../src/store/index')['useStore']
59
67
  const useStoreGlobal: typeof import('../src/store/index')['useStoreGlobal']
68
+ const useStoreUser: typeof import('../src/store/index')['useStoreUser']
69
+ const useTemplateRef: typeof import('vue')['useTemplateRef']
60
70
  const watch: typeof import('vue')['watch']
61
71
  const watchEffect: typeof import('vue')['watchEffect']
62
72
  const watchPostEffect: typeof import('vue')['watchPostEffect']
63
73
  const watchSyncEffect: typeof import('vue')['watchSyncEffect']
64
74
  }
75
+ // for type re-export
76
+ declare global {
77
+ // @ts-ignore
78
+ export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
79
+ import('vue')
80
+ }
@@ -1,12 +1,7 @@
1
- // generated by unplugin-vue-components
2
- // We suggest you to commit this file into source control
3
- // Read more: https://github.com/vuejs/vue-next/pull/3399
4
- import '@vue/runtime-core'
5
-
6
- export {}
1
+ import PageContainer from '@/components/PageContainer'
7
2
 
8
3
  declare module '@vue/runtime-core' {
9
4
  export interface GlobalComponents {
10
- GProPageContainer: typeof import('./../src/components/PageContainer')['default']
5
+ GPageContainer: typeof PageContainer
11
6
  }
12
7
  }
@@ -0,0 +1,56 @@
1
+ declare interface CdnModuleList {
2
+ name: string;
3
+ globalName: string;
4
+ path: string;
5
+ css?: string;
6
+ }
7
+
8
+ declare interface SettingConfig {
9
+ servive: {
10
+ port: number;
11
+ };
12
+ build: {
13
+ publicPath: string;
14
+ outputDir: string;
15
+ assetsDir: string;
16
+ };
17
+ system: {
18
+ title: string;
19
+ shortName: string;
20
+ titleSeparator: string;
21
+ titleReverse: boolean;
22
+ routerMode: string;
23
+ appInit: {
24
+ loading: false | {
25
+ text: string;
26
+ }
27
+ };
28
+ routesWhiteList: string[];
29
+ loginInterception: boolean;
30
+ loginRSA: boolean;
31
+ };
32
+ cdn: {
33
+ use: boolean;
34
+ url: string;
35
+ modules?: CdnModuleList[]
36
+ };
37
+ proxy: {
38
+ use: boolean;
39
+ target: string | Record<string, any>;
40
+ };
41
+ mock: {
42
+ prefix: string;
43
+ // 0 校验是否有token值 1 校验是否有token值且token时有效的(mock用户) -1 不校验
44
+ checkToken: -1 | 0 | 1;
45
+ };
46
+ token: {
47
+ name: string;
48
+ storage: 'localStorage' | 'sessionStorage' | 'cookie';
49
+ storageName: string;
50
+ };
51
+ }
52
+
53
+ declare interface NetworkConfig {
54
+ requestTimeout: number;
55
+ successCode: (string | number)[];
56
+ }