create-bubbles 0.1.8 → 0.1.10
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/dist/index.js +3 -2
- package/package.json +1 -1
- package/template-nextjs-vinext-eslint/.dockerignore +3 -0
- package/template-nextjs-vinext-eslint/.vscode/settings.json +53 -0
- package/template-nextjs-vinext-eslint/Dockerfile +21 -0
- package/template-nextjs-vinext-eslint/README.md +100 -0
- package/template-nextjs-vinext-eslint/commitlint.config.js +1 -0
- package/template-nextjs-vinext-eslint/docker-compose.yaml +22 -0
- package/template-nextjs-vinext-eslint/eslint.config.js +20 -0
- package/template-nextjs-vinext-eslint/lefthook.yml +11 -0
- package/template-nextjs-vinext-eslint/next.config.ts +8 -0
- package/template-nextjs-vinext-eslint/nginx.conf +14 -0
- package/template-nextjs-vinext-eslint/package.json +50 -0
- package/template-nextjs-vinext-eslint/pnpm-workspace.yaml +7 -0
- package/template-nextjs-vinext-eslint/public/file.svg +1 -0
- package/template-nextjs-vinext-eslint/public/globe.svg +1 -0
- package/template-nextjs-vinext-eslint/public/logo-white.svg +128 -0
- package/template-nextjs-vinext-eslint/public/next.svg +1 -0
- package/template-nextjs-vinext-eslint/public/vercel.svg +1 -0
- package/template-nextjs-vinext-eslint/public/window.svg +1 -0
- package/template-nextjs-vinext-eslint/src/app/_components/Header/header.module.css +0 -0
- package/template-nextjs-vinext-eslint/src/app/_components/Header/header.tsx +7 -0
- package/template-nextjs-vinext-eslint/src/app/_components/Main/index.tsx +13 -0
- package/template-nextjs-vinext-eslint/src/app/antd-provider.tsx +30 -0
- package/template-nextjs-vinext-eslint/src/app/icon.svg +26 -0
- package/template-nextjs-vinext-eslint/src/app/layout.tsx +71 -0
- package/template-nextjs-vinext-eslint/src/app/page.module.css +141 -0
- package/template-nextjs-vinext-eslint/src/app/page.tsx +43 -0
- package/template-nextjs-vinext-eslint/src/assets/icon/logo-white.svg +128 -0
- package/template-nextjs-vinext-eslint/src/assets/icon/logo.svg +26 -0
- package/template-nextjs-vinext-eslint/src/assets/image/QR.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/banner_1.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/banner_2.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/banner_3.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/banner_4.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/banner_top.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/icon_title_left.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/icon_title_right.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/img.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_COCT.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/207/347/247/221.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/205/264.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/206/266/345/273/272/345/267/245.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/233/275/344/270/255/351/223/201.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/233/275/344/272/224/345/206/266.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/233/275/344/272/244/351/200/232/345/273/272/350/256/276.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/233/275/345/273/272/344/270/232.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/233/275/345/273/272/347/255/221/347/247/221/345/255/246/351/231/242.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/233/275/347/224/265/345/273/272.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/233/275/351/223/201/345/273/272.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/345/256/234/351/200/232/344/270/226/347/272/252.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/346/225/260/347/273/264/347/251/272/351/227/264.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/346/226/260/346/230/212/350/276/260/345/273/272/350/256/276.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/346/236/227/345/220/214/346/243/252/345/233/275/351/231/205.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/346/270/235/351/232/206/351/233/206/345/233/242.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/347/273/264/345/241/224/347/247/221/346/212/200.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/350/205/276/350/256/257.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/350/265/233/350/277/252/344/277/241/346/201/257.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/207/215/345/272/206/344/272/244/351/200/232/345/244/247/345/255/246.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/207/215/345/272/206/344/272/244/351/200/232/350/201/214/344/270/232/345/255/246/351/231/242.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/207/215/345/272/206/345/244/247/345/255/246.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/207/215/345/272/206/345/267/245/345/225/206/350/201/214/344/270/232/345/255/246/351/231/242.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/207/215/345/272/206/345/267/245/347/250/213/350/201/214/344/270/232/346/212/200/346/234/257/345/255/246/351/231/242.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/207/215/345/272/206/345/273/272/345/267/245.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/230/277/351/207/214/344/272/221.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/231/206/345/206/233/345/206/233/345/214/273/345/244/247/345/255/246.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/276/231/346/271/226.png +0 -0
- package/template-nextjs-vinext-eslint/src/styles/globals.css +47 -0
- package/template-nextjs-vinext-eslint/src/types/vite-env.d.ts +18 -0
- package/template-nextjs-vinext-eslint/src/utils/env.ts +14 -0
- package/template-nextjs-vinext-eslint/src/utils/index.ts +0 -0
- package/template-nextjs-vinext-eslint/src/utils/request/core/index.ts +182 -0
- package/template-nextjs-vinext-eslint/src/utils/request/core/utils.ts +30 -0
- package/template-nextjs-vinext-eslint/src/utils/request/index.ts +48 -0
- package/template-nextjs-vinext-eslint/tsconfig.json +34 -0
- package/template-nextjs-vinext-eslint/uno.config.ts +10 -0
- package/template-nextjs-vinext-eslint/vite.config.ts +8 -0
- package/template-taro-vue-eslint/.env +3 -0
- package/template-taro-vue-eslint/.env.development +3 -2
- package/template-taro-vue-eslint/.env.production +3 -2
- package/template-taro-vue-eslint/config/dev.ts +18 -1
- package/template-taro-vue-eslint/config/release.ts +6 -14
- package/template-taro-vue-eslint/eslint.config.mjs +5 -0
- package/template-taro-vue-eslint/package.json +5 -3
- package/template-taro-vue-eslint/src/api/common/upload.ts +53 -0
- package/template-taro-vue-eslint/src/app.config.ts +11 -3
- package/template-taro-vue-eslint/src/app.ts +3 -3
- package/template-taro-vue-eslint/src/assets/image/.gitkeep +0 -0
- package/template-taro-vue-eslint/src/pages/example/upload/index.config.ts +3 -0
- package/template-taro-vue-eslint/src/pages/example/upload/index.module.scss +4 -0
- package/template-taro-vue-eslint/src/pages/example/upload/index.vue +71 -0
- package/template-taro-vue-eslint/src/pages/index/index.vue +64 -11
- package/template-taro-vue-eslint/src/styles/index.css +1 -0
- package/template-taro-vue-eslint/src/styles/nut-theme.css +4 -0
- package/template-taro-vue-eslint/src/utils/env.ts +11 -4
- package/template-taro-vue-eslint/src/utils/index.ts +40 -0
- package/template-taro-vue-eslint/src/utils/request/core/index.ts +2 -1
- package/template-taro-vue-eslint/src/utils/request/index.ts +31 -2
- package/template-taro-vue-eslint/types/components.d.ts +1 -1
- package/template-taro-vue-eslint/unocss.config.ts +1 -1
- package/template-taro-vue-eslint/key/private.wxac3f99d8814754aa.key +0 -27
- package/template-taro-vue-eslint/src/app.css +0 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/207/347/247/221.png
ADDED
|
Binary file
|
package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/205/264.png
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/350/205/276/350/256/257.png
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/276/231/346/271/226.png
ADDED
|
Binary file
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--background: #ffffff;
|
|
3
|
+
--foreground: #171717;
|
|
4
|
+
|
|
5
|
+
/* Brand tokens */
|
|
6
|
+
--brand-blue: #146ae1;
|
|
7
|
+
--brand-blue-dark: #0f52b0;
|
|
8
|
+
--brand-amber: #fdc23a;
|
|
9
|
+
--brand-text: #1a1a2e;
|
|
10
|
+
--brand-text-secondary: #555;
|
|
11
|
+
--brand-bg-light: #f5f8ff;
|
|
12
|
+
--brand-border: #e0e8f5;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
html {
|
|
16
|
+
scroll-behavior: smooth;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
body {
|
|
20
|
+
max-width: 100vw;
|
|
21
|
+
overflow-x: hidden;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
body {
|
|
25
|
+
color: var(--foreground);
|
|
26
|
+
background: var(--background);
|
|
27
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
28
|
+
-webkit-font-smoothing: antialiased;
|
|
29
|
+
-moz-osx-font-smoothing: grayscale;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
* {
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
padding: 0;
|
|
35
|
+
margin: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
a {
|
|
39
|
+
color: inherit;
|
|
40
|
+
text-decoration: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@media (prefers-color-scheme: dark) {
|
|
44
|
+
html {
|
|
45
|
+
color-scheme: dark;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
declare module '*.svg?react' {
|
|
4
|
+
import type { FC, SVGProps } from 'react'
|
|
5
|
+
|
|
6
|
+
const ReactComponent: FC<SVGProps<SVGSVGElement>>
|
|
7
|
+
export default ReactComponent
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare module '*.svg' {
|
|
11
|
+
const src: string
|
|
12
|
+
export default src
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare module '*/png' {
|
|
16
|
+
const src: string
|
|
17
|
+
export default src
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 环境变量工具
|
|
3
|
+
* 所有环境变量通过 import.meta.env 读取,在此统一导出。
|
|
4
|
+
* 在 .env.local / .env.production 中配置对应变量。
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** API 基础域名,例如 https://api.example.com */
|
|
8
|
+
export const apiUrl: string = import.meta.env.VITE_API_URL ?? ''
|
|
9
|
+
|
|
10
|
+
/** 普通接口路径前缀,例如 api */
|
|
11
|
+
export const apiAffix: string = import.meta.env.VITE_API_AFFIX ?? 'api'
|
|
12
|
+
|
|
13
|
+
/** 上传接口路径前缀,例如 upload */
|
|
14
|
+
export const uploadApiAffix: string = import.meta.env.VITE_UPLOAD_API_AFFIX ?? 'upload'
|
|
File without changes
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AlovaGlobalCacheAdapter,
|
|
3
|
+
AlovaOptions,
|
|
4
|
+
AlovaRequestAdapter,
|
|
5
|
+
GlobalCacheConfig,
|
|
6
|
+
StatesExport,
|
|
7
|
+
StatesHook,
|
|
8
|
+
} from 'alova'
|
|
9
|
+
import type { FetchRequestInit } from 'alova/fetch'
|
|
10
|
+
import { createAlova } from 'alova'
|
|
11
|
+
import adapterFetch from 'alova/fetch'
|
|
12
|
+
import { deepMergeObject, isReadableStream } from './utils'
|
|
13
|
+
|
|
14
|
+
// ---- 支持的适配器联合类型 ----
|
|
15
|
+
type SupportedRequestConfig = FetchRequestInit
|
|
16
|
+
type SupportedResponse = Response
|
|
17
|
+
type SupportedResponseHeader = Headers
|
|
18
|
+
|
|
19
|
+
interface StatusMap {
|
|
20
|
+
success?: number
|
|
21
|
+
unAuthorized?: number
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface CodeMap {
|
|
25
|
+
success?: number[]
|
|
26
|
+
unAuthorized?: number[]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface BaseRequestOption<
|
|
30
|
+
RC extends SupportedRequestConfig = SupportedRequestConfig,
|
|
31
|
+
RE extends SupportedResponse = SupportedResponse,
|
|
32
|
+
RH extends SupportedResponseHeader = SupportedResponseHeader,
|
|
33
|
+
SE extends StatesExport<any> = StatesExport<any>,
|
|
34
|
+
> {
|
|
35
|
+
baseUrl?: string
|
|
36
|
+
timeout?: number
|
|
37
|
+
commonHeaders?: Record<string, string | (() => string)>
|
|
38
|
+
statusMap?: StatusMap
|
|
39
|
+
isWrapped?: boolean
|
|
40
|
+
cacheFor?: GlobalCacheConfig<any>
|
|
41
|
+
cacheLogger?: boolean
|
|
42
|
+
codeMap?: CodeMap
|
|
43
|
+
responseDataKey?: string
|
|
44
|
+
responseMessageKey?: string
|
|
45
|
+
isTransformResponse?: boolean
|
|
46
|
+
isShowSuccessMessage?: boolean
|
|
47
|
+
successDefaultMessage?: string
|
|
48
|
+
isShowErrorMessage?: boolean
|
|
49
|
+
errorDefaultMessage?: string
|
|
50
|
+
statesHook?: StatesHook<SE>
|
|
51
|
+
successMessageFunc?: (message: string) => void
|
|
52
|
+
errorMessageFunc?: (message: string) => void
|
|
53
|
+
unAuthorizedResponseFunc?: () => void
|
|
54
|
+
requestAdapter?: AlovaRequestAdapter<RC, RE, RH>
|
|
55
|
+
storageAdapter?: AlovaGlobalCacheAdapter
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** method.meta 中可按请求覆盖的字段 */
|
|
59
|
+
export interface RequestMeta {
|
|
60
|
+
isTransformResponse?: boolean
|
|
61
|
+
isShowSuccessMessage?: boolean
|
|
62
|
+
isShowErrorMessage?: boolean
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function getMetaFlag(meta: Record<string, any> | undefined, key: string, fallback: boolean): boolean {
|
|
66
|
+
if (meta && typeof meta[key] === 'boolean')
|
|
67
|
+
return meta[key]
|
|
68
|
+
return fallback
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function createInstance<
|
|
72
|
+
RC extends SupportedRequestConfig = SupportedRequestConfig,
|
|
73
|
+
RE extends SupportedResponse = SupportedResponse,
|
|
74
|
+
RH extends SupportedResponseHeader = SupportedResponseHeader,
|
|
75
|
+
>(option: BaseRequestOption<RC, RE, RH>) {
|
|
76
|
+
const defaultOption: BaseRequestOption = {
|
|
77
|
+
baseUrl: '/',
|
|
78
|
+
timeout: undefined,
|
|
79
|
+
statusMap: { success: 200, unAuthorized: 401 },
|
|
80
|
+
isWrapped: true,
|
|
81
|
+
cacheFor: null,
|
|
82
|
+
cacheLogger: true,
|
|
83
|
+
codeMap: { success: [200], unAuthorized: [401] },
|
|
84
|
+
responseDataKey: 'data',
|
|
85
|
+
responseMessageKey: 'message',
|
|
86
|
+
isTransformResponse: true,
|
|
87
|
+
isShowSuccessMessage: false,
|
|
88
|
+
successDefaultMessage: '操作成功',
|
|
89
|
+
isShowErrorMessage: true,
|
|
90
|
+
errorDefaultMessage: '服务异常',
|
|
91
|
+
requestAdapter: adapterFetch() as AlovaRequestAdapter<any, any, any>,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const config = deepMergeObject(defaultOption as any, option as any) as Required<
|
|
95
|
+
Pick<BaseRequestOption, 'statusMap' | 'codeMap' | 'responseDataKey' | 'responseMessageKey'>
|
|
96
|
+
> & BaseRequestOption<RC, RE, RH>
|
|
97
|
+
|
|
98
|
+
const alovaOptions: AlovaOptions<{
|
|
99
|
+
Responded: any
|
|
100
|
+
Transformed: any
|
|
101
|
+
RequestConfig: RC
|
|
102
|
+
Response: RE
|
|
103
|
+
ResponseHeader: RH
|
|
104
|
+
L1Cache: AlovaGlobalCacheAdapter
|
|
105
|
+
L2Cache: AlovaGlobalCacheAdapter
|
|
106
|
+
StatesExport: StatesExport<any>
|
|
107
|
+
}> = {
|
|
108
|
+
baseURL: config.baseUrl,
|
|
109
|
+
timeout: config.timeout,
|
|
110
|
+
cacheFor: config.cacheFor as any,
|
|
111
|
+
cacheLogger: config.cacheLogger,
|
|
112
|
+
statesHook: config.statesHook,
|
|
113
|
+
l2Cache: config.storageAdapter,
|
|
114
|
+
requestAdapter: config.requestAdapter!,
|
|
115
|
+
beforeRequest: async (method) => {
|
|
116
|
+
for (const [key, value] of Object.entries(config.commonHeaders ?? {})) {
|
|
117
|
+
method.config.headers[key] = typeof value === 'function' ? value() : value
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
responded: {
|
|
121
|
+
onSuccess: async (response, method) => {
|
|
122
|
+
const meta = method.meta as Record<string, any> | undefined
|
|
123
|
+
const shouldTransform = getMetaFlag(meta, 'isTransformResponse', config.isTransformResponse ?? true)
|
|
124
|
+
const showSuccess = getMetaFlag(meta, 'isShowSuccessMessage', config.isShowSuccessMessage ?? false)
|
|
125
|
+
const showError = getMetaFlag(meta, 'isShowErrorMessage', config.isShowErrorMessage ?? true)
|
|
126
|
+
const isWrapped = getMetaFlag(meta, 'isWrapped', config.isWrapped ?? true)
|
|
127
|
+
|
|
128
|
+
if (!shouldTransform)
|
|
129
|
+
return response
|
|
130
|
+
|
|
131
|
+
// 兼容 fetch (status) 和 Taro (statusCode)
|
|
132
|
+
const status = (response as any).statusCode ?? (response as any).status
|
|
133
|
+
// 兼容 fetch (body 是 ReadableStream) 和 Taro (data 直接可用)
|
|
134
|
+
const data
|
|
135
|
+
= (response as any)?.body && isReadableStream((response as any).body)
|
|
136
|
+
? await (response as Response).json()
|
|
137
|
+
: (response as any).data ?? response
|
|
138
|
+
|
|
139
|
+
if (status !== config.statusMap.success) {
|
|
140
|
+
if (config.statusMap.unAuthorized === status)
|
|
141
|
+
config.unAuthorizedResponseFunc?.()
|
|
142
|
+
if (showError)
|
|
143
|
+
config.errorMessageFunc?.(config.errorDefaultMessage ?? '服务异常')
|
|
144
|
+
return Promise.reject(response)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (!isWrapped || (isWrapped === undefined || !config.isWrapped)) {
|
|
148
|
+
if (showSuccess)
|
|
149
|
+
config.successMessageFunc?.(config.successDefaultMessage ?? '操作成功')
|
|
150
|
+
return data
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const code = data?.code
|
|
154
|
+
const responseData = data?.[config.responseDataKey]
|
|
155
|
+
const responseMessage = data?.[config.responseMessageKey]
|
|
156
|
+
|
|
157
|
+
if (!config.codeMap.success?.includes(+code)) {
|
|
158
|
+
if (config.codeMap.unAuthorized?.includes(+code)) {
|
|
159
|
+
config.unAuthorizedResponseFunc?.()
|
|
160
|
+
return Promise.reject(response)
|
|
161
|
+
}
|
|
162
|
+
if (showError)
|
|
163
|
+
config.errorMessageFunc?.(responseMessage ?? config.errorDefaultMessage ?? '服务异常')
|
|
164
|
+
return Promise.reject(response)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (showSuccess)
|
|
168
|
+
config.successMessageFunc?.(responseMessage ?? config.successDefaultMessage)
|
|
169
|
+
return responseData
|
|
170
|
+
},
|
|
171
|
+
onError: (error, method) => {
|
|
172
|
+
const meta = method.meta as Record<string, any> | undefined
|
|
173
|
+
const showError = getMetaFlag(meta, 'isShowErrorMessage', config.isShowErrorMessage ?? true)
|
|
174
|
+
if (showError)
|
|
175
|
+
config.errorMessageFunc?.(config.errorDefaultMessage ?? error.message)
|
|
176
|
+
return Promise.reject(error)
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return createAlova(alovaOptions)
|
|
182
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function deepMergeObject<T = any>(source: T, target: Partial<T>): T {
|
|
2
|
+
const isObject = (obj: any): obj is Record<string, any> =>
|
|
3
|
+
obj && typeof obj === 'object' && !Array.isArray(obj)
|
|
4
|
+
|
|
5
|
+
const merge = (src: any, tgt: any): any => {
|
|
6
|
+
const result = { ...src }
|
|
7
|
+
if (isObject(result) && isObject(tgt)) {
|
|
8
|
+
Object.keys(tgt).forEach((key) => {
|
|
9
|
+
if (isObject(tgt[key])) {
|
|
10
|
+
result[key] = merge(result[key] || {}, tgt[key])
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
result[key] = tgt[key]
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
return result
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return merge(source, target)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 判断一个变量是不是可读流
|
|
25
|
+
*/
|
|
26
|
+
export function isReadableStream(data: unknown): boolean {
|
|
27
|
+
if (typeof ReadableStream === 'undefined')
|
|
28
|
+
return false
|
|
29
|
+
return data instanceof ReadableStream
|
|
30
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { FetchRequestInit } from 'alova/fetch'
|
|
2
|
+
import { message } from 'antd'
|
|
3
|
+
import { apiAffix, apiUrl, uploadApiAffix } from '@/utils/env'
|
|
4
|
+
import { createInstance } from './core'
|
|
5
|
+
|
|
6
|
+
export const moduleUrl = {
|
|
7
|
+
LJSD: 'bee/single-track',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const alovaRequest = createInstance<FetchRequestInit, Response, Headers>({
|
|
11
|
+
baseUrl: `${apiUrl}/${apiAffix}`,
|
|
12
|
+
statusMap: { success: 200, unAuthorized: 401 },
|
|
13
|
+
codeMap: { success: [200] },
|
|
14
|
+
responseDataKey: 'data',
|
|
15
|
+
responseMessageKey: 'msg',
|
|
16
|
+
commonHeaders: {},
|
|
17
|
+
successMessageFunc: (msg) => {
|
|
18
|
+
message.success(msg)
|
|
19
|
+
},
|
|
20
|
+
errorMessageFunc: (msg) => {
|
|
21
|
+
message.error(msg)
|
|
22
|
+
},
|
|
23
|
+
unAuthorizedResponseFunc: () => {
|
|
24
|
+
message.warning('登录过期或未登录')
|
|
25
|
+
window.location.href = '/login'
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
export default alovaRequest
|
|
30
|
+
|
|
31
|
+
export const alovaUploadRequest = createInstance<FetchRequestInit, Response, Headers>({
|
|
32
|
+
baseUrl: `${apiUrl}/${uploadApiAffix}`,
|
|
33
|
+
statusMap: { success: 200, unAuthorized: 401 },
|
|
34
|
+
codeMap: { success: [200] },
|
|
35
|
+
responseDataKey: 'data',
|
|
36
|
+
responseMessageKey: 'msg',
|
|
37
|
+
commonHeaders: {},
|
|
38
|
+
successMessageFunc: (msg) => {
|
|
39
|
+
message.success(msg)
|
|
40
|
+
},
|
|
41
|
+
errorMessageFunc: (msg) => {
|
|
42
|
+
message.error(msg)
|
|
43
|
+
},
|
|
44
|
+
unAuthorizedResponseFunc: () => {
|
|
45
|
+
message.warning('登录过期或未登录')
|
|
46
|
+
window.location.href = '/login'
|
|
47
|
+
},
|
|
48
|
+
})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"incremental": true,
|
|
4
|
+
"target": "ES2017",
|
|
5
|
+
"jsx": "react-jsx",
|
|
6
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
7
|
+
"module": "esnext",
|
|
8
|
+
"moduleResolution": "bundler",
|
|
9
|
+
"paths": {
|
|
10
|
+
"@/*": ["./src/*"]
|
|
11
|
+
},
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"allowJs": true,
|
|
14
|
+
"strict": true,
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
"esModuleInterop": true,
|
|
17
|
+
"isolatedModules": true,
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
"plugins": [
|
|
20
|
+
{
|
|
21
|
+
"name": "next"
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"include": [
|
|
26
|
+
".next/types/**/*.ts",
|
|
27
|
+
".next/dev/types/**/*.ts",
|
|
28
|
+
"./src/types/vite-env.d.ts",
|
|
29
|
+
"**/*.ts",
|
|
30
|
+
"**/*.tsx",
|
|
31
|
+
"**/*.mts"
|
|
32
|
+
],
|
|
33
|
+
"exclude": ["node_modules"]
|
|
34
|
+
}
|
|
@@ -6,5 +6,22 @@ export default {
|
|
|
6
6
|
stats: true,
|
|
7
7
|
},
|
|
8
8
|
mini: {},
|
|
9
|
-
h5: {
|
|
9
|
+
h5: {
|
|
10
|
+
devServer: {
|
|
11
|
+
open: false,
|
|
12
|
+
port: 9970,
|
|
13
|
+
proxy: {
|
|
14
|
+
[`/${process.env.TARO_APP_API_AFFIX}`]: {
|
|
15
|
+
target: process.env.TARO_APP_API_URL,
|
|
16
|
+
changeOrigin: true,
|
|
17
|
+
secure: false,
|
|
18
|
+
},
|
|
19
|
+
[`/${process.env.TARO_APP_UPLOAD_API_AFFIX}`]: {
|
|
20
|
+
target: process.env.TARO_APP_API_URL,
|
|
21
|
+
changeOrigin: true,
|
|
22
|
+
secure: false,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
10
27
|
} satisfies UserConfigExport<'webpack5'>
|
|
@@ -2,7 +2,6 @@ import { execSync } from 'node:child_process'
|
|
|
2
2
|
import * as fs from 'node:fs'
|
|
3
3
|
import * as path from 'node:path'
|
|
4
4
|
import process from 'node:process'
|
|
5
|
-
import { devtools } from 'vue'
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* 获取package.json中的版本号
|
|
@@ -13,8 +12,7 @@ function getPackageVersion(): string {
|
|
|
13
12
|
const packageContent = fs.readFileSync(packagePath, 'utf8')
|
|
14
13
|
const packageData = JSON.parse(packageContent)
|
|
15
14
|
return packageData.version || '1.0.0'
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
15
|
+
} catch {
|
|
18
16
|
console.warn('⚠️ 获取package.json版本号失败,使用默认版本 1.0.0')
|
|
19
17
|
return '1.0.0'
|
|
20
18
|
}
|
|
@@ -27,8 +25,7 @@ function getLatestCommitMessage(): string {
|
|
|
27
25
|
try {
|
|
28
26
|
const message = execSync('git log -1 --pretty=%B', { encoding: 'utf8' }).trim()
|
|
29
27
|
return message || '版本更新'
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
28
|
+
} catch {
|
|
32
29
|
console.warn('⚠️ 获取Git提交信息失败,使用默认描述')
|
|
33
30
|
return '版本更新'
|
|
34
31
|
}
|
|
@@ -40,8 +37,7 @@ function getLatestCommitMessage(): string {
|
|
|
40
37
|
function getCurrentBranch(): string {
|
|
41
38
|
try {
|
|
42
39
|
return execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim()
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
40
|
+
} catch {
|
|
45
41
|
return 'unknown'
|
|
46
42
|
}
|
|
47
43
|
}
|
|
@@ -52,8 +48,7 @@ function getCurrentBranch(): string {
|
|
|
52
48
|
function getCommitAuthor(): string {
|
|
53
49
|
try {
|
|
54
50
|
return execSync('git log -1 --pretty=%an', { encoding: 'utf8' }).trim()
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
51
|
+
} catch {
|
|
57
52
|
return 'unknown'
|
|
58
53
|
}
|
|
59
54
|
}
|
|
@@ -85,12 +80,9 @@ export async function CIPluginFn() {
|
|
|
85
80
|
*/
|
|
86
81
|
return {
|
|
87
82
|
weapp: {
|
|
88
|
-
appid:
|
|
89
|
-
process.env.TARO_APP_MODE === 'development' ? 'wxac3f99d8814754aa' : 'wxac3f99d8814754aa',
|
|
83
|
+
appid: process.env.TARO_APP_MODE === 'development' ? 'abc' : 'abc',
|
|
90
84
|
privateKeyPath:
|
|
91
|
-
process.env.TARO_APP_MODE === 'development'
|
|
92
|
-
? 'key/private.wxac3f99d8814754aa.key'
|
|
93
|
-
: 'key/private.wxac3f99d8814754aa.key',
|
|
85
|
+
process.env.TARO_APP_MODE === 'development' ? 'key/private.abc.key' : 'key/private.abc.key',
|
|
94
86
|
devToolsInstallPath: `C:\\Program Files (x86)\\Tencent\\微信web开发者工具`,
|
|
95
87
|
},
|
|
96
88
|
// tt: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
2
|
+
"name": "bubbles-project",
|
|
3
3
|
"version": "1.0.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "vue-taro-eslint",
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
"framework": "Vue3"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"prepare": "lefthook install",
|
|
15
14
|
"new": "taro new",
|
|
16
15
|
"build:weapp": "taro build --type weapp --open",
|
|
17
16
|
"build:swan": "taro build --type swan",
|
|
18
17
|
"build:alipay": "taro build --type alipay",
|
|
19
18
|
"build:tt": "taro build --type tt",
|
|
20
19
|
"build:h5": "taro build --type h5",
|
|
20
|
+
"build:h5:prod": "taro build --type h5 --mode production",
|
|
21
21
|
"build:rn": "taro build --type rn",
|
|
22
22
|
"build:qq": "taro build --type qq",
|
|
23
23
|
"build:jd": "taro build --type jd",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dev:qq": "npm run build:qq -- --watch",
|
|
32
32
|
"dev:jd": "npm run build:jd -- --watch",
|
|
33
33
|
"dev:harmony-hybrid": "npm run build:harmony-hybrid -- --watch",
|
|
34
|
-
"
|
|
34
|
+
"prepare": "lefthook install",
|
|
35
35
|
"lint": "eslint",
|
|
36
36
|
"lint:fix": "eslint --fix"
|
|
37
37
|
},
|
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
"alova": "^3.5.0",
|
|
70
70
|
"pinia": "^3.0.4",
|
|
71
71
|
"pinia-plugin-persistedstate": "^4.7.1",
|
|
72
|
+
"spark-md5": "^3.0.2",
|
|
72
73
|
"vue": "^3.0.0"
|
|
73
74
|
},
|
|
74
75
|
"devDependencies": {
|
|
@@ -87,6 +88,7 @@
|
|
|
87
88
|
"@types/minimatch": "^5",
|
|
88
89
|
"@types/node": "^18",
|
|
89
90
|
"@types/webpack-env": "^1.13.6",
|
|
91
|
+
"@unocss/eslint-plugin": "^66.6.2",
|
|
90
92
|
"@unocss/webpack": "0.58.9",
|
|
91
93
|
"@vue/babel-plugin-jsx": "^1.2.2",
|
|
92
94
|
"@vue/compiler-sfc": "^3.0.0",
|