@gx-design-vue/create-gx-cli 0.1.12 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. package/bin/create-gx-cli +3 -2
  2. package/package.json +4 -4
  3. package/src/cli.js +9 -7
  4. package/src/git.js +8 -5
  5. package/src/main.js +29 -16
  6. package/template-mobile-vant-cli/package.json +5 -5
  7. package/template-gx-design-thin/.editorconfig +0 -19
  8. package/template-gx-design-thin/.env +0 -4
  9. package/template-gx-design-thin/.env.development +0 -15
  10. package/template-gx-design-thin/.env.production +0 -28
  11. package/template-gx-design-thin/.eslintignore +0 -16
  12. package/template-gx-design-thin/.prettierignore +0 -9
  13. package/template-gx-design-thin/LICENSE +0 -21
  14. package/template-gx-design-thin/README.md +0 -112
  15. package/template-gx-design-thin/build/constant.ts +0 -1
  16. package/template-gx-design-thin/build/generate/generateModifyVars.ts +0 -14
  17. package/template-gx-design-thin/build/rollupOptions/index.ts +0 -22
  18. package/template-gx-design-thin/build/util/hash.ts +0 -17
  19. package/template-gx-design-thin/build/util/index.ts +0 -131
  20. package/template-gx-design-thin/build/vite/cdn.ts +0 -63
  21. package/template-gx-design-thin/build/vite/optimizer.ts +0 -26
  22. package/template-gx-design-thin/build/vite/plugin/appConfig.ts +0 -91
  23. package/template-gx-design-thin/build/vite/plugin/autoImport.ts +0 -26
  24. package/template-gx-design-thin/build/vite/plugin/compress.ts +0 -31
  25. package/template-gx-design-thin/build/vite/plugin/html.ts +0 -39
  26. package/template-gx-design-thin/build/vite/plugin/index.ts +0 -75
  27. package/template-gx-design-thin/build/vite/plugin/mock.ts +0 -14
  28. package/template-gx-design-thin/build/vite/plugin/pwa.ts +0 -31
  29. package/template-gx-design-thin/build/vite/plugin/visualizer.ts +0 -14
  30. package/template-gx-design-thin/build/vite/plugin/viteMock/client.ts +0 -88
  31. package/template-gx-design-thin/build/vite/plugin/viteMock/createMockServer.ts +0 -271
  32. package/template-gx-design-thin/build/vite/plugin/viteMock/index.ts +0 -69
  33. package/template-gx-design-thin/build/vite/plugin/viteMock/types.ts +0 -48
  34. package/template-gx-design-thin/build/vite/plugin/viteMock/utils.ts +0 -48
  35. package/template-gx-design-thin/build/vite/plugin/viteNotice.ts +0 -40
  36. package/template-gx-design-thin/commitlint.config.cjs +0 -32
  37. package/template-gx-design-thin/config/default/defaultSettings.ts +0 -78
  38. package/template-gx-design-thin/config/default/network.ts +0 -10
  39. package/template-gx-design-thin/config/default/proxy.ts +0 -47
  40. package/template-gx-design-thin/config/default/theme.ts +0 -3
  41. package/template-gx-design-thin/config/index.ts +0 -11
  42. package/template-gx-design-thin/eslint.config.js +0 -51
  43. package/template-gx-design-thin/index.html +0 -42
  44. package/template-gx-design-thin/mock/_createProductionServer.ts +0 -19
  45. package/template-gx-design-thin/mock/_util.ts +0 -33
  46. package/template-gx-design-thin/mock/config/menu.ts +0 -21
  47. package/template-gx-design-thin/mock/config/user.ts +0 -123
  48. package/template-gx-design-thin/mock/datasSource/system/menu.ts +0 -10
  49. package/template-gx-design-thin/mock/datasSource/user/account.ts +0 -30
  50. package/template-gx-design-thin/mock/datasSource/user/index.ts +0 -47
  51. package/template-gx-design-thin/mock/util/crypto.ts +0 -23
  52. package/template-gx-design-thin/mock/util/table.ts +0 -92
  53. package/template-gx-design-thin/mock/util/utils.ts +0 -73
  54. package/template-gx-design-thin/package.json +0 -129
  55. package/template-gx-design-thin/pnpm-lock.yaml +0 -12575
  56. package/template-gx-design-thin/prettier.config.cjs +0 -18
  57. package/template-gx-design-thin/public/resource/css/index.css +0 -119
  58. package/template-gx-design-thin/public/resource/css/normalize.css +0 -396
  59. package/template-gx-design-thin/public/resource/img/favicon.ico +0 -0
  60. package/template-gx-design-thin/public/resource/img/logo.png +0 -0
  61. package/template-gx-design-thin/public/resource/img/pro_icon.svg +0 -1
  62. package/template-gx-design-thin/public/resource/img/pwa-192x192.png +0 -0
  63. package/template-gx-design-thin/public/resource/img/pwa-512x512.png +0 -0
  64. package/template-gx-design-thin/src/App.vue +0 -42
  65. package/template-gx-design-thin/src/assets/error_images/403.png +0 -0
  66. package/template-gx-design-thin/src/assets/error_images/404.png +0 -0
  67. package/template-gx-design-thin/src/assets/error_images/cloud.png +0 -0
  68. package/template-gx-design-thin/src/assets/login_images/login_background.svg +0 -1
  69. package/template-gx-design-thin/src/assets/logo.png +0 -0
  70. package/template-gx-design-thin/src/assets/menu_font/iconfont.css +0 -94
  71. package/template-gx-design-thin/src/assets/menu_font/iconfont.eot +0 -0
  72. package/template-gx-design-thin/src/assets/menu_font/iconfont.js +0 -1
  73. package/template-gx-design-thin/src/assets/menu_font/iconfont.json +0 -142
  74. package/template-gx-design-thin/src/assets/menu_font/iconfont.svg +0 -1
  75. package/template-gx-design-thin/src/assets/menu_font/iconfont.ttf +0 -0
  76. package/template-gx-design-thin/src/assets/menu_font/iconfont.woff +0 -0
  77. package/template-gx-design-thin/src/assets/menu_font/iconfont.woff2 +0 -0
  78. package/template-gx-design-thin/src/assets/menu_font/index.less +0 -94
  79. package/template-gx-design-thin/src/assets/public_icon/iconfont.css +0 -42
  80. package/template-gx-design-thin/src/assets/public_icon/iconfont.eot +0 -0
  81. package/template-gx-design-thin/src/assets/public_icon/iconfont.js +0 -1
  82. package/template-gx-design-thin/src/assets/public_icon/iconfont.json +0 -51
  83. package/template-gx-design-thin/src/assets/public_icon/iconfont.svg +0 -1
  84. package/template-gx-design-thin/src/assets/public_icon/iconfont.ttf +0 -0
  85. package/template-gx-design-thin/src/assets/public_icon/iconfont.woff +0 -0
  86. package/template-gx-design-thin/src/assets/public_icon/iconfont.woff2 +0 -0
  87. package/template-gx-design-thin/src/assets/public_icon/index.less +0 -42
  88. package/template-gx-design-thin/src/assets/public_images/nodata.svg +0 -1
  89. package/template-gx-design-thin/src/common/global.ts +0 -4
  90. package/template-gx-design-thin/src/components/GDesign/Result/index.tsx +0 -144
  91. package/template-gx-design-thin/src/components/GDesign/Result/style.less +0 -140
  92. package/template-gx-design-thin/src/components/GDesign/utils/index.ts +0 -7
  93. package/template-gx-design-thin/src/components/GlobalLayout/Confirm/index.ts +0 -21
  94. package/template-gx-design-thin/src/components/GlobalLayout/Empty/index.vue +0 -18
  95. package/template-gx-design-thin/src/components/GlobalLayout/RightContent/index.tsx +0 -126
  96. package/template-gx-design-thin/src/components/GlobalLayout/RightContent/style.ts +0 -77
  97. package/template-gx-design-thin/src/components/GlobalLayout/Spin/index.tsx +0 -30
  98. package/template-gx-design-thin/src/components/PageLoading/index.tsx +0 -51
  99. package/template-gx-design-thin/src/components/index.ts +0 -6
  100. package/template-gx-design-thin/src/core/ant-design/index.ts +0 -10
  101. package/template-gx-design-thin/src/core/gx-admin-design/index.ts +0 -6
  102. package/template-gx-design-thin/src/core/gx-design/index.ts +0 -6
  103. package/template-gx-design-thin/src/core/gx-pro-design/index.ts +0 -8
  104. package/template-gx-design-thin/src/core/index.ts +0 -84
  105. package/template-gx-design-thin/src/design/ant-design/index.less +0 -4
  106. package/template-gx-design-thin/src/design/ant-design/layout.less +0 -22
  107. package/template-gx-design-thin/src/design/ant-design/menu.less +0 -48
  108. package/template-gx-design-thin/src/design/ant-design/spin.less +0 -23
  109. package/template-gx-design-thin/src/design/ant-design/tooltip.less +0 -7
  110. package/template-gx-design-thin/src/design/color.less +0 -1
  111. package/template-gx-design-thin/src/design/config.less +0 -5
  112. package/template-gx-design-thin/src/design/imageEditor.less +0 -180
  113. package/template-gx-design-thin/src/design/index.less +0 -95
  114. package/template-gx-design-thin/src/design/mixin.less +0 -65
  115. package/template-gx-design-thin/src/design/normalize.less +0 -391
  116. package/template-gx-design-thin/src/design/root.less +0 -3
  117. package/template-gx-design-thin/src/hooks/core/index.ts +0 -3
  118. package/template-gx-design-thin/src/hooks/core/useRequest/index.ts +0 -118
  119. package/template-gx-design-thin/src/hooks/event/index.ts +0 -3
  120. package/template-gx-design-thin/src/hooks/event/useClipboard.ts +0 -15
  121. package/template-gx-design-thin/src/hooks/web/index.ts +0 -5
  122. package/template-gx-design-thin/src/hooks/web/useThemeStyle.ts +0 -16
  123. package/template-gx-design-thin/src/layout/BasicLayout.vue +0 -123
  124. package/template-gx-design-thin/src/layout/BlankLayout.vue +0 -5
  125. package/template-gx-design-thin/src/layout/ContentView.vue +0 -50
  126. package/template-gx-design-thin/src/layout/IframeView.vue +0 -1
  127. package/template-gx-design-thin/src/layout/UserLayout.vue +0 -7
  128. package/template-gx-design-thin/src/main.ts +0 -34
  129. package/template-gx-design-thin/src/plugins/index.ts +0 -2
  130. package/template-gx-design-thin/src/router/guard/index.ts +0 -83
  131. package/template-gx-design-thin/src/router/guard/permissions.ts +0 -70
  132. package/template-gx-design-thin/src/router/guard/stateGuard.ts +0 -10
  133. package/template-gx-design-thin/src/router/helper/routeHelper.ts +0 -223
  134. package/template-gx-design-thin/src/router/helper/utils.ts +0 -19
  135. package/template-gx-design-thin/src/router/index.ts +0 -31
  136. package/template-gx-design-thin/src/router/routes/index.ts +0 -86
  137. package/template-gx-design-thin/src/router/routes/modules/dataSource.ts +0 -12
  138. package/template-gx-design-thin/src/services/common/index.ts +0 -11
  139. package/template-gx-design-thin/src/services/systemCenter/index.ts +0 -1
  140. package/template-gx-design-thin/src/services/systemCenter/menu.ts +0 -9
  141. package/template-gx-design-thin/src/services/userCenter/account.ts +0 -42
  142. package/template-gx-design-thin/src/services/userCenter/index.ts +0 -28
  143. package/template-gx-design-thin/src/store/index.ts +0 -32
  144. package/template-gx-design-thin/src/store/modules/dict.ts +0 -28
  145. package/template-gx-design-thin/src/store/modules/global.ts +0 -42
  146. package/template-gx-design-thin/src/store/modules/permission.ts +0 -19
  147. package/template-gx-design-thin/src/store/modules/routes.ts +0 -113
  148. package/template-gx-design-thin/src/store/modules/tabsRouter.ts +0 -76
  149. package/template-gx-design-thin/src/store/modules/user.ts +0 -136
  150. package/template-gx-design-thin/src/utils/accessToken.ts +0 -80
  151. package/template-gx-design-thin/src/utils/crypto/base64.ts +0 -101
  152. package/template-gx-design-thin/src/utils/crypto/index.ts +0 -57
  153. package/template-gx-design-thin/src/utils/env.ts +0 -50
  154. package/template-gx-design-thin/src/utils/fetchFile.ts +0 -81
  155. package/template-gx-design-thin/src/utils/index.ts +0 -123
  156. package/template-gx-design-thin/src/utils/pageTitle.ts +0 -20
  157. package/template-gx-design-thin/src/utils/request/XHR.ts +0 -139
  158. package/template-gx-design-thin/src/utils/request/axiosCancel.ts +0 -69
  159. package/template-gx-design-thin/src/utils/request/checkStatus.ts +0 -25
  160. package/template-gx-design-thin/src/utils/request/index.ts +0 -144
  161. package/template-gx-design-thin/src/utils/request/typings.ts +0 -171
  162. package/template-gx-design-thin/src/utils/storage.ts +0 -199
  163. package/template-gx-design-thin/src/utils/uploadFile.ts +0 -27
  164. package/template-gx-design-thin/src/utils/util.ts +0 -198
  165. package/template-gx-design-thin/src/utils/validate.ts +0 -216
  166. package/template-gx-design-thin/src/views/Iframe/index.vue +0 -76
  167. package/template-gx-design-thin/src/views/Page/one.vue +0 -13
  168. package/template-gx-design-thin/src/views/Page/two.vue +0 -13
  169. package/template-gx-design-thin/src/views/exception/403/index.vue +0 -7
  170. package/template-gx-design-thin/src/views/exception/404/index.vue +0 -9
  171. package/template-gx-design-thin/src/views/user/login/index.vue +0 -109
  172. package/template-gx-design-thin/src/views/user/login/style.less +0 -38
  173. package/template-gx-design-thin/tsconfig.json +0 -46
  174. package/template-gx-design-thin/types/ant-design-import.d.ts +0 -99
  175. package/template-gx-design-thin/types/auto-imports.d.ts +0 -81
  176. package/template-gx-design-thin/types/components.d.ts +0 -24
  177. package/template-gx-design-thin/types/config.d.ts +0 -44
  178. package/template-gx-design-thin/types/global.d.ts +0 -97
  179. package/template-gx-design-thin/types/mock.d.ts +0 -16
  180. package/template-gx-design-thin/types/module.d.ts +0 -20
  181. package/template-gx-design-thin/types/response.d.ts +0 -15
  182. package/template-gx-design-thin/unocss.config.ts +0 -101
  183. package/template-gx-design-thin/vite.config.ts +0 -120
  184. package/template-gx-design-thin/yarn.lock +0 -9492
@@ -1,144 +0,0 @@
1
- import { message } from 'ant-design-vue'
2
- import { defaultSettings, network } from '@gx-config'
3
- import { useStoreUser } from '@/store'
4
- import { isDev, typeViteEnv } from '@/utils/env'
5
- import { tansParams } from '@/utils/util'
6
- import { checkURL } from '@/utils/validate'
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'
11
- import { handleCode } from './checkStatus'
12
-
13
- const { tokenName, requestPrefix, mockPrefixUrl } = defaultSettings
14
-
15
- const { requestTimeout, successCode } = network
16
-
17
- const xhtInstance: XhtInstance = {
18
- /**
19
- * @description: 处理响应数据。如果数据不是预期格式,可直接抛出错误
20
- */
21
- transformResponseHook: (res, options) => {
22
- const { customize, isReturnNativeResponse } = options
23
- // 是否返回原生响应头 比如:需要获取响应头时使用该属性
24
- if (isReturnNativeResponse) {
25
- return res
26
- }
27
- // 不进行任何处理,直接返回
28
- // 用于页面代码可能需要直接获取code,data,message这些信息时开启
29
- if (customize) {
30
- return res.data
31
- }
32
- // 错误的时候返回
33
-
34
- const { data }: { data: ResponseResult } = res
35
- if (!data) {
36
- throw new Error('请求出错,请稍候重试')
37
- }
38
- // 这里 code,result,message为 后台统一的字段,需要在 types.ts内修改为项目自己的接口返回格式
39
- const { code, msg = '', message = '' } = data
40
-
41
- const codeVerificationArray = successCode
42
-
43
- // 这里逻辑可以根据项目进行修改
44
- const hasSuccess = codeVerificationArray.includes(code)
45
- if (hasSuccess) {
46
- return data
47
- }
48
-
49
- // 在此处根据自己项目的实际情况对不同的code执行不同的操作
50
- // 如果不希望中断当前请求,请return数据,否则直接抛出异常即可
51
- handleCode(code, message || msg)
52
-
53
- return Promise.resolve(false)
54
- },
55
-
56
- // 请求之前处理config
57
- beforeRequestHook: (config) => {
58
- // get请求映射params参数
59
- if (config.method?.toUpperCase() === RequestEnum.GET && config.params) {
60
- let url = config.url + '?' + tansParams(config.params)
61
- url = url.slice(0, -1)
62
- config.params = {}
63
- config.url = url
64
- }
65
-
66
- if (!checkURL(config.url)) {
67
- if (config.isMock) {
68
- config.url = `${mockPrefixUrl}${config.url}`
69
- } else {
70
- config.url = `${typeViteEnv('VITE_BASE_URL')}${isDev ? requestPrefix || '' : ''}${config.url}`
71
- }
72
- }
73
-
74
- return config
75
- },
76
-
77
- /**
78
- * @description: 请求拦截器处理
79
- */
80
- requestInterceptors: (config) => {
81
- const user = useStoreUser()
82
- const carryToken = isBoolean(config.carryToken) ? config.carryToken : true
83
- if (user.accessToken && carryToken)
84
- config.headers[tokenName] = user.accessToken
85
- return config
86
- },
87
-
88
- /**
89
- * @description: 响应拦截器处理
90
- */
91
- responseInterceptors: (res) => {
92
- return res
93
- },
94
-
95
- /**
96
- * @description: 响应错误处理
97
- */
98
- responseInterceptorsCatch: (_, error) => {
99
- const { response } = error
100
- let errorMessage = error.message || ''
101
- if (error.response && error.response.data) {
102
- const { status } = response
103
- handleCode(status, errorMessage)
104
- return Promise.resolve(false)
105
- } else {
106
- if (errorMessage === 'Network Error') {
107
- errorMessage = '后端接口连接异常'
108
- }
109
- if (errorMessage.includes('timeout')) {
110
- errorMessage = '后端接口请求超时'
111
- }
112
- if (errorMessage.includes('Request failed with status code')) {
113
- const code = errorMessage.substr(errorMessage.length - 3)
114
- errorMessage = '后端接口' + code || '' + '异常'
115
- }
116
- message.error(errorMessage || `后端接口未知异常`)
117
- return Promise.resolve(false)
118
- }
119
- },
120
- /**
121
- * @description: 处理响应错误数据
122
- */
123
- requestCatchHook: () => false
124
- }
125
-
126
- function createXhr(opt?: Partial<GAxiosOptions>) {
127
- return new GAxios({
128
- method: 'get',
129
- timeout: requestTimeout,
130
- headers: {
131
- 'Content-Type': 'application/json;charset=UTF-8'
132
- },
133
- // 忽略重复请求
134
- ignoreCancelToken: true,
135
- // 是否携带token
136
- carryToken: true,
137
- ...xhtInstance,
138
- ...opt
139
- })
140
- }
141
-
142
- const request: <T = any, R = undefined>(opt?: GAxiosOptions) => Promise<ResponseResult<T, R>> = opt => createXhr().request(opt)
143
-
144
- export default request
@@ -1,171 +0,0 @@
1
- import type {
2
- AxiosError,
3
- AxiosInstance,
4
- AxiosInterceptorManager,
5
- AxiosInterceptorOptions,
6
- AxiosPromise,
7
- AxiosRequestConfig,
8
- AxiosResponse,
9
- InternalAxiosRequestConfig,
10
- Method
11
- } from 'axios'
12
-
13
- export interface GAxiosResponse<T = any> extends Omit<AxiosResponse, 'data' | 'config'> {
14
- data: T;
15
- config: Omit<GAxiosOptions, 'headers'>;
16
- }
17
-
18
- export interface CancelOptions {
19
- cancel: (key?: string) => void,
20
- cancelAll: () => void;
21
- reset: () => void
22
- }
23
-
24
- export interface XhtInstance {
25
- /**
26
- * @Author gx12358
27
- * @DateTime 2023/1/6
28
- * @lastTime 2023/1/6
29
- * @description 请求之前处理config
30
- */
31
- beforeRequestHook?: (config: GAxiosOptions) => GAxiosOptions;
32
-
33
- /**
34
- * @Author gx12358
35
- * @DateTime 2023/11/3
36
- * @lastTime 2023/11/3
37
- * @description 请求之前返回cancel函数
38
- */
39
- cancelCallBackHook?: ({ cancel, cancelAll, reset }: CancelOptions) => void;
40
-
41
- /**
42
- * @description: 处理响应数据
43
- */
44
- transformResponseHook?: (res: GAxiosResponse, options: Partial<GAxiosOptions>) => any;
45
-
46
- /**
47
- * @description: 请求失败处理
48
- */
49
- requestCatchHook?: (e: Error) => boolean;
50
-
51
- /**
52
- * @description: 请求之前的拦截器
53
- */
54
- requestInterceptors?: (config: GAxiosOptions) => GAxiosOptions;
55
-
56
- /**
57
- * @description: 请求之后的拦截器
58
- */
59
- responseInterceptors?: (res: GAxiosResponse) => GAxiosResponse;
60
-
61
- /**
62
- * @description: 请求之前的拦截器错误处理
63
- */
64
- requestInterceptorsCatch?: (error: AxiosError) => void;
65
-
66
- /**
67
- * @description: 请求之后的拦截器错误处理
68
- */
69
- responseInterceptorsCatch?: (axiosInstance: GAxiosInstance, error: AxiosError) => void;
70
- }
71
-
72
- export interface GAxiosOptions extends Omit<AxiosRequestConfig, 'headers' | 'method'> {
73
- headers?: Record<string, any>;
74
- method: Method;
75
- isMock?: boolean; // 是否是mock
76
- retry?: boolean; // 是否是重试接口
77
- isReturnNativeResponse?: boolean; // 直接返回response,不作任何处理(包含响应值等基本信息)
78
- customize?: boolean; // 直接返回response.data(接口返回值),错误不做统一提示
79
- carryToken?: boolean; // 是否携带token
80
- prefix?: string; // 接口自定义前缀
81
- ignoreCancelToken?: boolean; // 忽略重复请求
82
- cancelKey?: string; // 取消请求key(用来需要请求)
83
- /**
84
- * @Author gx12358
85
- * @DateTime 2023/1/6
86
- * @lastTime 2023/1/6
87
- * @description 请求之前处理config
88
- */
89
- beforeRequestHook?: XhtInstance['beforeRequestHook'];
90
-
91
- /**
92
- * @Author gx12358
93
- * @DateTime 2023/11/3
94
- * @lastTime 2023/11/3
95
- * @description 请求之前返回cancel函数
96
- */
97
- cancelCallBackHook?: XhtInstance['cancelCallBackHook'];
98
-
99
- /**
100
- * @description: 处理响应数据
101
- */
102
- transformResponseHook?: XhtInstance['transformResponseHook'];
103
-
104
- /**
105
- * @description: 请求失败处理
106
- */
107
- requestCatchHook?: XhtInstance['requestCatchHook'];
108
-
109
- /**
110
- * @description: 请求之前的拦截器
111
- */
112
- requestInterceptors?: XhtInstance['requestInterceptors'];
113
-
114
- /**
115
- * @description: 请求之后的拦截器
116
- */
117
- responseInterceptors?: XhtInstance['responseInterceptors'];
118
-
119
- /**
120
- * @description: 请求之前的拦截器错误处理
121
- */
122
- requestInterceptorsCatch?: XhtInstance['requestInterceptorsCatch'];
123
-
124
- /**
125
- * @description: 请求之后的拦截器错误处理
126
- */
127
- responseInterceptorsCatch?: XhtInstance['responseInterceptorsCatch'];
128
- }
129
-
130
- export interface GAxiosInstance extends Omit<AxiosInstance, 'interceptors'> {
131
- (config: GAxiosOptions): AxiosPromise<ResponseResult>;
132
-
133
- (url: string, config?: GAxiosOptions): AxiosPromise<ResponseResult>;
134
-
135
- interceptors: {
136
- request: Omit<AxiosInterceptorManager<InternalAxiosRequestConfig>, 'use'> & {
137
- use<V>(
138
- onFulfilled?: ((value: V) => V | Promise<V>) | null,
139
- onRejected?: ((error: any) => any) | null,
140
- options?: AxiosInterceptorOptions
141
- ): number;
142
- };
143
- response: Omit<AxiosInterceptorManager<AxiosResponse>, 'use'> & {
144
- use<V>(
145
- onFulfilled?: ((value: V) => V | Promise<V>) | null,
146
- onRejected?: ((error: any) => any) | null,
147
- options?: AxiosInterceptorOptions
148
- ): number;
149
- };
150
- }
151
- }
152
-
153
- /**
154
- * @description: request method
155
- */
156
- export enum RequestEnum {
157
- GET = 'GET',
158
- POST = 'POST',
159
- PUT = 'PUT',
160
- DELETE = 'DELETE',
161
- }
162
-
163
- /**
164
- * @description: contentType
165
- */
166
- export enum ContentTypeEnum {
167
- // json
168
- JSON = 'application/json;charset=UTF-8',
169
- // form-data qs
170
- FORM_URLENCODED = 'application/x-www-form-urlencoded;charset=UTF-8',
171
- }
@@ -1,199 +0,0 @@
1
- import dayjs from 'dayjs'
2
- import { defaultSettings } from '@gx-config'
3
- import { isPro, typeViteEnv } from '@/utils/env'
4
- import { Decrypt, Encrypt } from '@/utils/crypto'
5
- import { isJSONStr } from '@/utils/validate'
6
- import { isObject } from '@gx-design-vue/pro-utils'
7
-
8
- const { shortName } = defaultSettings
9
-
10
- function isEncryption(status: boolean) {
11
- return isPro() ? status : false
12
- }
13
-
14
- function handleStorageValue(value: string) {
15
- if (isJSONStr(value))
16
- return JSON.parse(value)
17
- return value
18
- }
19
-
20
- /**
21
- * @Author gx12358
22
- * @DateTime 2019/12/3
23
- * @lastTime 2019/12/3
24
- * @description 设置Local-key的规则
25
- */
26
- export function getStorageKey(key: string, originKey?: boolean) {
27
- const { pkg } = __APP_INFO__
28
- return originKey ? key : `${shortName}_${pkg.version}_${typeViteEnv('VITE_APP_ENV') === 'dev'
29
- ? 'development'
30
- : typeViteEnv('VITE_USE_MODE')}_${key}`
31
- }
32
-
33
- /**
34
- * @Author gx12358
35
- * @DateTime 2019/12/3
36
- * @lastTime 2019/12/3
37
- * @description 获取Storage
38
- */
39
- export function getStorage({
40
- key,
41
- encryption = true,
42
- type = 'localStorage',
43
- originKey
44
- }: { key: string, encryption?: boolean, type?: SettingConfig['storage'], originKey?: boolean }) {
45
- const storageValue = type === 'localStorage'
46
- ? localStorage.getItem(getStorageKey(key, originKey)) : type === 'sessionStorage'
47
- ? sessionStorage.getItem(getStorageKey(key, originKey))
48
- : getCookie(
49
- getStorageKey(key, originKey))
50
- const result: string | LocalResult = storageValue
51
- ? isEncryption(encryption) ? Decrypt(storageValue) : handleStorageValue(storageValue) : ''
52
- if (result && isObject(result)) {
53
- if (result.expired) {
54
- const expiredStatus = dayjs().diff(dayjs(result.time)) >= result.expired
55
- if (expiredStatus) {
56
- removeStorage(key, type)
57
- return ''
58
- }
59
- }
60
- }
61
- return result?.['value'] || result || ''
62
- }
63
-
64
- /**
65
- * @Author gx12358
66
- * @DateTime 2019/12/3
67
- * @lastTime 2019/12/3
68
- * @description 设置Storage
69
- */
70
- export function setStorage({
71
- key,
72
- value,
73
- expired,
74
- originKey,
75
- encryption = true,
76
- type = 'local'
77
- }: {
78
- key: string;
79
- value: any;
80
- originKey?: boolean;
81
- expired?: number;
82
- encryption?: boolean;
83
- type?: string;
84
- }) {
85
- const result: LocalResult = originKey ? value : {
86
- value,
87
- time: dayjs().format('YYYY-MM-DD HH:mm:ss'),
88
- expired: expired || 0
89
- }
90
- const storageValue = isEncryption(encryption) ? Encrypt(JSON.stringify(result)) : JSON.stringify(
91
- result)
92
- if (type === 'local')
93
- localStorage.setItem(getStorageKey(key, originKey), storageValue)
94
- sessionStorage.setItem(getStorageKey(key, originKey), storageValue)
95
- }
96
-
97
- /**
98
- * @Author gx12358
99
- * @DateTime 2019/12/3
100
- * @lastTime 2019/12/3
101
- * @description 删除Storage
102
- */
103
- export function removeStorage(key: string, type = 'local', originKey?: boolean) {
104
- if (type === 'local')
105
- localStorage.removeItem(getStorageKey(key, originKey))
106
- sessionStorage.removeItem(getStorageKey(key, originKey))
107
- }
108
-
109
- /**
110
- * @Author gx12358
111
- * @DateTime 2019-09-24
112
- * @lastTime 2019-09-24
113
- * @description 获取Cookie-name
114
- */
115
- function getCookies(cname: string) {
116
- const name = `${cname}=`
117
- const decodedCookie = decodeURIComponent(document.cookie)
118
- const ca = decodedCookie.split(';')
119
- for (let i = 0; i < ca.length; i += 1) {
120
- let c = ca[i]
121
- while (c.charAt(0) === ' ') {
122
- c = c.substring(1)
123
- }
124
- if (c.indexOf(name) === 0) {
125
- return decodeURIComponent(c.substring(name.length, c.length))
126
- }
127
- }
128
- return ''
129
- }
130
-
131
- /**
132
- * @Author gx12358
133
- * @DateTime 2019-09-24
134
- * @lastTime 2019-09-24
135
- * @description 获取Cookiedomin
136
- */
137
- function GetCookieDomain() {
138
- let host = location.hostname
139
- 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])$/
140
- if (ip.test(host) === true || host === 'localhost')
141
- return host
142
- const regex = /([^]*).*/
143
- const match = host.match(regex)
144
- if (typeof match !== 'undefined' && match !== null) {
145
- const someIndex = 1
146
- host = match[someIndex]
147
- }
148
- if (typeof host !== 'undefined' && host !== null) {
149
- const strAry = host.split('.')
150
- if (strAry.length > 1) {
151
- host = `${strAry[strAry.length - 2]}.${strAry[strAry.length - 1]}`
152
- }
153
- }
154
- return `.${host}`
155
- }
156
-
157
- /**
158
- * @Author gx12358
159
- * @DateTime 2019-09-24
160
- * @lastTime 2019-09-24
161
- * @description 设置Cookie
162
- */
163
- export function setCookie(cname: string, cvalue: string, exdays?: number) {
164
- const d = new Date()
165
- d.setTime(d.getTime() + (exdays || 365) * 24 * 60 * 60 * 1000)
166
- const expires = `=${d.toUTCString()}`
167
- document.cookie = `${cname}=${encodeURIComponent(
168
- cvalue
169
- )}; expires=${expires}; domain=${GetCookieDomain()}; path=/`
170
- }
171
-
172
- /**
173
- * @Author gx12358
174
- * @DateTime 2019-09-24
175
- * @lastTime 2019-09-24
176
- * @description 获取Cookie
177
- */
178
- export function getCookie(cname: string) {
179
- const result = getCookies(cname)
180
- if (result === '') {
181
- return ''
182
- }
183
- return decodeURIComponent(result)
184
- }
185
-
186
- /**
187
- * @Author gx12358
188
- * @DateTime 2019-09-24
189
- * @lastTime 2019-09-24
190
- * @description 删除Cookie
191
- */
192
- export function delCookie(name: string) {
193
- const exp = new Date()
194
- exp.setTime(exp.getTime() - 1)
195
- const cval = getCookies(name)
196
- if (cval !== null) {
197
- document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; domain=${GetCookieDomain()}; path=/`
198
- }
199
- }
@@ -1,27 +0,0 @@
1
- import dayjs from 'dayjs'
2
- import { getRandomNumber } from '@gx-design-vue/pro-utils'
3
-
4
- /**
5
- * @Author gx12358
6
- * @DateTime 2022/4/22
7
- * @lastTime 2022/4/22
8
- * @description 修改文件名
9
- */
10
- export const createFileName = ({
11
- file,
12
- name
13
- }: {
14
- file: File | string;
15
- name?: string;
16
- }) => {
17
- if (name !== 'image' && name !== 'vod')
18
- return name
19
- const names = file instanceof File ? file.name.split('.') : file.split('.')
20
- const time1 = dayjs().format('YYYYMMDDHH')
21
- const uuid = `${name || 'vod'}/creator/${time1}/${getRandomNumber().uuid(32).toLowerCase()}`
22
- if (names.length > 1) {
23
- return uuid + '.' + names[names.length - 1]
24
- } else {
25
- return uuid
26
- }
27
- }