@gx-design-vue/create-gx-cli 0.1.14 → 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.
- package/package.json +1 -1
- package/src/cli.js +7 -4
- package/src/main.js +7 -7
- package/template-mobile-vant-cli/.env +3 -0
- package/template-mobile-vant-cli/.env.development +4 -6
- package/template-mobile-vant-cli/.env.pro +16 -7
- package/template-mobile-vant-cli/.env.production +21 -9
- package/template-mobile-vant-cli/commitlint.config.cjs +32 -0
- package/template-mobile-vant-cli/config/default/defaultSettings.ts +70 -0
- package/template-mobile-vant-cli/config/default/network.ts +10 -0
- package/template-mobile-vant-cli/config/default/proxy.ts +50 -0
- package/template-mobile-vant-cli/config/default/theme.ts +3 -0
- package/template-mobile-vant-cli/config/index.ts +11 -0
- package/template-mobile-vant-cli/eslint.config.js +10 -2
- package/template-mobile-vant-cli/index.html +22 -21
- package/template-mobile-vant-cli/{build → internal/vite-config/generate}/generateModifyVars.ts +1 -1
- package/template-mobile-vant-cli/internal/vite-config/rollupOptions/index.ts +22 -0
- package/template-mobile-vant-cli/internal/vite-config/util/hash.ts +17 -0
- package/template-mobile-vant-cli/internal/vite-config/util/index.ts +132 -0
- package/template-mobile-vant-cli/internal/vite-config/vite/cdn.ts +65 -0
- package/template-mobile-vant-cli/{build → internal/vite-config/vite}/optimizer.ts +9 -1
- package/template-mobile-vant-cli/internal/vite-config/vite/plugin/appConfig.ts +91 -0
- package/template-mobile-vant-cli/{build → internal/vite-config/vite}/plugin/autoImport.ts +7 -3
- package/template-mobile-vant-cli/internal/vite-config/vite/plugin/compress.ts +31 -0
- package/template-mobile-vant-cli/internal/vite-config/vite/plugin/html.ts +32 -0
- package/template-mobile-vant-cli/internal/vite-config/vite/plugin/index.ts +74 -0
- package/template-mobile-vant-cli/internal/vite-config/vite/plugin/visualizer.ts +14 -0
- package/template-mobile-vant-cli/internal/vite-config/vite/plugin/viteNotice.ts +40 -0
- package/template-mobile-vant-cli/mock/config/permissions.ts +15 -0
- package/template-mobile-vant-cli/mock/config/user/id.ts +5 -0
- package/template-mobile-vant-cli/mock/config/user/index.ts +96 -0
- package/template-mobile-vant-cli/mock/index.ts +55 -0
- package/template-mobile-vant-cli/mock/routers/table/index.fake.ts +22 -0
- package/template-mobile-vant-cli/mock/routers/user/account.fake.ts +52 -0
- package/template-mobile-vant-cli/mock/routers/user/index.fake.ts +46 -0
- package/template-mobile-vant-cli/mock/utils/crypto.ts +21 -0
- package/template-mobile-vant-cli/mock/utils/table.ts +96 -0
- package/template-mobile-vant-cli/mock/utils/util.ts +91 -0
- package/template-mobile-vant-cli/package.json +51 -34
- package/template-mobile-vant-cli/public/css/default.css +54 -0
- package/template-mobile-vant-cli/src/App.vue +6 -2
- package/template-mobile-vant-cli/src/assets/logo.png +0 -0
- package/template-mobile-vant-cli/src/components/PageContainer/ProSkeleton.tsx +1 -1
- package/template-mobile-vant-cli/src/components/PageContainer/index.tsx +108 -16
- package/template-mobile-vant-cli/src/components/PageContainer/style.module.less +5 -2
- package/template-mobile-vant-cli/src/components/TabsMenu/index.vue +45 -0
- package/template-mobile-vant-cli/src/core/gx-design/index.ts +1 -1
- package/template-mobile-vant-cli/src/core/index.ts +0 -7
- package/template-mobile-vant-cli/src/design/color.less +1 -0
- package/template-mobile-vant-cli/src/design/config.less +5 -0
- package/template-mobile-vant-cli/src/design/index.less +1 -1
- package/template-mobile-vant-cli/src/design/mixin.less +65 -0
- package/template-mobile-vant-cli/src/design/reset.less +16 -132
- package/template-mobile-vant-cli/src/hooks/web/usePageLoading.ts +7 -9
- package/template-mobile-vant-cli/src/layout/{BasicLayout.vue → BasicLayout/index.vue} +3 -1
- package/template-mobile-vant-cli/src/layout/BasicLayout/style.less +3 -0
- package/template-mobile-vant-cli/src/layout/UserLayout/index.vue +18 -0
- package/template-mobile-vant-cli/src/layout/UserLayout/style.module.less +36 -0
- package/template-mobile-vant-cli/src/main.ts +16 -9
- package/template-mobile-vant-cli/src/pages/Account/details.vue +13 -0
- package/template-mobile-vant-cli/src/pages/Account/index.vue +102 -0
- package/template-mobile-vant-cli/src/pages/{home.vue → Home/index.vue} +5 -5
- package/template-mobile-vant-cli/src/pages/user/login/index.vue +74 -0
- package/template-mobile-vant-cli/src/plugins/dayjs/index.ts +3 -0
- package/template-mobile-vant-cli/src/plugins/index.ts +2 -0
- package/template-mobile-vant-cli/src/router/guard/index.ts +18 -0
- package/template-mobile-vant-cli/src/router/guard/permissions.ts +41 -0
- package/template-mobile-vant-cli/src/router/guard/stateGuard.ts +10 -0
- package/template-mobile-vant-cli/src/router/index.ts +21 -15
- package/template-mobile-vant-cli/src/router/routes/index.ts +46 -0
- package/template-mobile-vant-cli/src/router/routes/modules/dataSource.ts +32 -0
- package/template-mobile-vant-cli/src/services/userCenter/account.ts +42 -0
- package/template-mobile-vant-cli/src/services/userCenter/index.ts +28 -0
- package/template-mobile-vant-cli/src/store/index.ts +4 -1
- package/template-mobile-vant-cli/src/store/modules/global.ts +6 -13
- package/template-mobile-vant-cli/src/store/modules/user.ts +107 -0
- package/template-mobile-vant-cli/src/utils/accessToken.ts +97 -0
- package/template-mobile-vant-cli/src/utils/crypto/index.ts +3 -4
- package/template-mobile-vant-cli/src/utils/env.ts +2 -2
- package/template-mobile-vant-cli/src/utils/pageTitle.ts +12 -6
- package/template-mobile-vant-cli/src/utils/request/XHR.ts +9 -11
- package/template-mobile-vant-cli/src/utils/request/axiosCancel.ts +5 -5
- package/template-mobile-vant-cli/src/utils/request/checkStatus.ts +18 -2
- package/template-mobile-vant-cli/src/utils/request/index.ts +36 -23
- package/template-mobile-vant-cli/src/utils/storage.ts +49 -32
- package/template-mobile-vant-cli/src/utils/validate.ts +31 -36
- package/template-mobile-vant-cli/tsconfig.json +17 -9
- package/template-mobile-vant-cli/types/auto-imports.d.ts +18 -2
- package/template-mobile-vant-cli/types/components.d.ts +2 -7
- package/template-mobile-vant-cli/types/config.d.ts +56 -0
- package/template-mobile-vant-cli/types/global.d.ts +62 -21
- package/template-mobile-vant-cli/types/mock.d.ts +34 -0
- package/template-mobile-vant-cli/types/module.d.ts +33 -0
- package/template-mobile-vant-cli/types/response.d.ts +3 -1
- package/template-mobile-vant-cli/types/system.d.ts +58 -0
- package/template-mobile-vant-cli/types/vant-import.d.ts +16 -5
- package/template-mobile-vant-cli/unocss.config.ts +120 -66
- package/template-mobile-vant-cli/vite.config.ts +78 -81
- package/template-mobile-vant-cli/build/cdn.ts +0 -5
- package/template-mobile-vant-cli/build/plugin/html.ts +0 -26
- package/template-mobile-vant-cli/build/plugin/index.ts +0 -42
- package/template-mobile-vant-cli/build/plugin/mock.ts +0 -14
- package/template-mobile-vant-cli/build/plugin/viteMock/client.ts +0 -88
- package/template-mobile-vant-cli/build/plugin/viteMock/createMockServer.ts +0 -271
- package/template-mobile-vant-cli/build/plugin/viteMock/index.ts +0 -69
- package/template-mobile-vant-cli/build/plugin/viteMock/types.ts +0 -48
- package/template-mobile-vant-cli/build/plugin/viteMock/utils.ts +0 -48
- package/template-mobile-vant-cli/build/script/postBuild.ts +0 -14
- package/template-mobile-vant-cli/mock/_createProductionServer.ts +0 -19
- package/template-mobile-vant-cli/mock/utils.ts +0 -9
- package/template-mobile-vant-cli/postcss.config.cjs +0 -8
- package/template-mobile-vant-cli/prettier.config.cjs +0 -18
- package/template-mobile-vant-cli/public/js/flexible.js +0 -44
- package/template-mobile-vant-cli/src/core/vant-design/index.ts +0 -4
- package/template-mobile-vant-cli/src/design/vant.less +0 -2
- package/template-mobile-vant-cli/src/global.less +0 -1
- package/template-mobile-vant-cli/src/layout/basicLayout.less +0 -11
- package/template-mobile-vant-cli/src/router/routes.ts +0 -20
- package/template-mobile-vant-cli/src/router/typings.ts +0 -8
- package/template-mobile-vant-cli/src/settings/index.ts +0 -10
- package/template-mobile-vant-cli/src/utils/crypto/base64.ts +0 -101
- package/template-mobile-vant-cli/types/ant-design-import.d.ts +0 -13
- package/template-mobile-vant-cli/types/plugins-auto-import.d.ts +0 -14
- /package/template-mobile-vant-cli/{mock/datasSource/api/index.ts → src/design/vant/index.less} +0 -0
@@ -1,14 +1,11 @@
|
|
1
1
|
import type { AxiosError } from 'axios'
|
2
|
+
import type { GAxiosInstance, GAxiosOptions, GAxiosResponse } from './typings'
|
3
|
+
import { isFunction } from '@gx-design-vue/pro-utils'
|
2
4
|
import axios from 'axios'
|
3
5
|
import { cloneDeep } from 'lodash-es'
|
4
6
|
import qs from 'qs'
|
5
|
-
import { isFunction } from '@gx-design-vue/pro-utils'
|
6
|
-
import type { GAxiosInstance, GAxiosOptions, GAxiosResponse } from './typings'
|
7
|
-
import { ContentTypeEnum, RequestEnum } from './typings'
|
8
7
|
import { AxiosCanceler } from './axiosCancel'
|
9
|
-
|
10
|
-
export const getPendingUrl = (config: GAxiosOptions) => config.cancelKey || [ config.method, config.url ].join(
|
11
|
-
'&')
|
8
|
+
import { ContentTypeEnum, RequestEnum } from './typings'
|
12
9
|
|
13
10
|
/**
|
14
11
|
* @Author gx12358
|
@@ -99,8 +96,8 @@ export class GAxios {
|
|
99
96
|
}
|
100
97
|
}
|
101
98
|
|
102
|
-
request<T = ResponseResult | boolean>(config
|
103
|
-
let conf
|
99
|
+
request<T = ResponseResult | boolean>(config?: GAxiosOptions): Promise<T> {
|
100
|
+
let conf = cloneDeep(config || {} as GAxiosOptions)
|
104
101
|
|
105
102
|
const opt: GAxiosOptions = Object.assign({}, this.options, conf)
|
106
103
|
|
@@ -117,10 +114,11 @@ export class GAxios {
|
|
117
114
|
.then((res: GAxiosResponse) => {
|
118
115
|
if (transformResponseHook && isFunction(transformResponseHook)) {
|
119
116
|
try {
|
120
|
-
const ret = transformResponseHook(res, config)
|
117
|
+
const ret = transformResponseHook(res, config || {})
|
121
118
|
resolve(ret)
|
122
|
-
} catch (
|
123
|
-
|
119
|
+
} catch (error) {
|
120
|
+
console.error('request-error', error)
|
121
|
+
resolve(false as unknown as Promise<T>)
|
124
122
|
return
|
125
123
|
}
|
126
124
|
return
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { Canceler } from 'axios'
|
2
|
-
import axios from 'axios'
|
3
|
-
import { isFunction } from '@gx-design-vue/pro-utils'
|
4
2
|
import type { GAxiosOptions } from './typings'
|
3
|
+
import { isFunction } from '@gx-design-vue/pro-utils'
|
4
|
+
import axios from 'axios'
|
5
5
|
|
6
6
|
export const getPendingUrl = (
|
7
7
|
config: GAxiosOptions,
|
@@ -15,12 +15,12 @@ export class AxiosCanceler {
|
|
15
15
|
constructor(ignoreCancel?: boolean) {
|
16
16
|
this.pendingMap = new Map<string, Canceler>()
|
17
17
|
|
18
|
-
this.ignoreCancelToken = ignoreCancel
|
18
|
+
this.ignoreCancelToken = !!ignoreCancel
|
19
19
|
}
|
20
20
|
|
21
21
|
/**
|
22
22
|
* Add request
|
23
|
-
* @param {
|
23
|
+
* @param {object} config
|
24
24
|
*/
|
25
25
|
addPending(config: GAxiosOptions) {
|
26
26
|
!this.ignoreCancelToken && this.removePending(config)
|
@@ -46,7 +46,7 @@ export class AxiosCanceler {
|
|
46
46
|
|
47
47
|
/**
|
48
48
|
* Removal request
|
49
|
-
* @param {
|
49
|
+
* @param {object} config
|
50
50
|
*/
|
51
51
|
removePending(config: GAxiosOptions, key?: string) {
|
52
52
|
const url = getPendingUrl(config, key)
|
@@ -1,9 +1,25 @@
|
|
1
|
+
import { router } from '@/router'
|
2
|
+
import { useStoreUser } from '@/store'
|
3
|
+
import { showToast } from 'vant'
|
4
|
+
|
1
5
|
/**
|
2
6
|
* @author gx12358 2539306317@qq.com
|
3
7
|
* @description 处理code异常
|
4
8
|
* @param {*} code
|
5
9
|
* @param {*} msg
|
6
10
|
*/
|
7
|
-
export const handleCode = (
|
8
|
-
|
11
|
+
export const handleCode = (code: number, msg: string) => {
|
12
|
+
const user = useStoreUser()
|
13
|
+
switch (code) {
|
14
|
+
case 401:
|
15
|
+
user.resetPermissions()
|
16
|
+
router.push({ path: '/user/login' })
|
17
|
+
break
|
18
|
+
default:
|
19
|
+
showToast({
|
20
|
+
type: 'fail',
|
21
|
+
message: msg || '后端接口异常'
|
22
|
+
})
|
23
|
+
break
|
24
|
+
}
|
9
25
|
}
|
@@ -1,16 +1,18 @@
|
|
1
|
-
import {
|
2
|
-
import
|
3
|
-
import {
|
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 {
|
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 {
|
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,
|
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
|
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
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
80
|
+
const { name } = token
|
81
|
+
const user = useStoreUser()
|
80
82
|
const carryToken = isBoolean(config.carryToken) ? config.carryToken : true
|
81
|
-
if (
|
82
|
-
config.headers
|
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
|
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
|
-
|
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':
|
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()
|
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 {
|
3
|
-
import {
|
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
|
-
|
41
|
-
type = '
|
42
|
-
|
43
|
-
}: {
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
|
75
|
-
|
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?:
|
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)
|
90
|
-
result)
|
91
|
-
|
92
|
-
|
93
|
-
|
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(
|
103
|
-
|
104
|
-
|
105
|
-
|
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 = /^(
|
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
|
-
|
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-
|
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 = /^(
|
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.-]+(
|
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-
|
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 = /^(
|
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|
|
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)
|
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
|
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
|
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}@)?(
|
184
|
-
const reg1 = /^rtsp:\/\/([a-z]{0,10}:.{0,10}@)?(
|
185
|
-
const reg2 = /^rtsp:\/\/([a-z]{0,10}:.{0,10}@)?(
|
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
|
-
|
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-
|
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
|
-
"
|
37
|
-
"
|
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", "
|
49
|
+
"exclude": ["node_modules", "dist", "**/*.js"]
|
42
50
|
}
|
@@ -1,4 +1,9 @@
|
|
1
|
-
|
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
|
-
|
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
|
-
|
5
|
+
GPageContainer: typeof PageContainer
|
11
6
|
}
|
12
7
|
}
|