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
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { isH5, uploadApiAffix } from '@/utils/env'
|
|
2
|
+
import { alovaUploadRequest } from '@/utils/request'
|
|
3
|
+
|
|
4
|
+
interface UploadBaseParams {
|
|
5
|
+
fileMd5: string
|
|
6
|
+
fileSize: number
|
|
7
|
+
filename: string
|
|
8
|
+
companyId: string
|
|
9
|
+
projectId: string
|
|
10
|
+
indexDbId: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface H5UploadParams extends UploadBaseParams {
|
|
14
|
+
file: Blob
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface MpUploadParams extends UploadBaseParams {
|
|
18
|
+
filePath: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type UploadParams = H5UploadParams | MpUploadParams
|
|
22
|
+
|
|
23
|
+
export function uploadFile(data: any) {
|
|
24
|
+
if (isH5) {
|
|
25
|
+
// H5 端用 fetch 发送 FormData,绕过 Taro 适配器的序列化问题
|
|
26
|
+
return fetch(`/${uploadApiAffix}/files/uploadFileAppend`, {
|
|
27
|
+
method: 'POST',
|
|
28
|
+
body: data,
|
|
29
|
+
// headers: {
|
|
30
|
+
// 'Content-Type': 'multipart/form-data',
|
|
31
|
+
// authorization: 'Bearer 9a2d60a8-d9a6-40a3-9b13-4288225d855d',
|
|
32
|
+
// },
|
|
33
|
+
}).then(res => res.json())
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// 小程序端:用 Taro uploadFile 适配器
|
|
37
|
+
const { filePath, fileMd5, fileSize, filename, companyId, projectId, indexDbId } = data
|
|
38
|
+
return alovaUploadRequest.Post(`/files/uploadFileAppend`, {
|
|
39
|
+
name: 'file',
|
|
40
|
+
filePath,
|
|
41
|
+
fileMd5,
|
|
42
|
+
fileSize,
|
|
43
|
+
filename,
|
|
44
|
+
companyId,
|
|
45
|
+
projectId,
|
|
46
|
+
indexDbId,
|
|
47
|
+
}, {
|
|
48
|
+
requestType: 'upload',
|
|
49
|
+
fileName: filename,
|
|
50
|
+
meta: { isWrapped: false },
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
export default defineAppConfig({
|
|
2
2
|
pages: [
|
|
3
|
-
'pages/index/index'
|
|
3
|
+
'pages/index/index',
|
|
4
|
+
],
|
|
5
|
+
subPackages: [
|
|
6
|
+
{
|
|
7
|
+
root: 'pages/example',
|
|
8
|
+
pages: [
|
|
9
|
+
'upload/index',
|
|
10
|
+
],
|
|
11
|
+
},
|
|
4
12
|
],
|
|
5
13
|
window: {
|
|
6
14
|
backgroundTextStyle: 'light',
|
|
7
15
|
navigationBarBackgroundColor: '#fff',
|
|
8
16
|
navigationBarTitleText: 'WeChat',
|
|
9
|
-
navigationBarTextStyle: 'black'
|
|
10
|
-
}
|
|
17
|
+
navigationBarTextStyle: 'black',
|
|
18
|
+
},
|
|
11
19
|
})
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createApp } from 'vue'
|
|
2
|
+
|
|
2
3
|
import { setupStore } from './store'
|
|
3
4
|
import '@nutui/touch-emulator'
|
|
4
5
|
import 'uno.css'
|
|
5
|
-
import '
|
|
6
|
+
import '@/styles/index.css'
|
|
6
7
|
|
|
7
8
|
const App = createApp({
|
|
8
|
-
onShow(_options) {
|
|
9
|
-
},
|
|
9
|
+
onShow(_options) {},
|
|
10
10
|
})
|
|
11
11
|
|
|
12
12
|
setupStore(App)
|
|
File without changes
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import Taro from '@tarojs/taro'
|
|
3
|
+
import { uploadFile } from '@/api/common/upload'
|
|
4
|
+
import { canvasToFile, file2Md5 } from '@/utils'
|
|
5
|
+
import { isH5 } from '@/utils/env'
|
|
6
|
+
|
|
7
|
+
async function handleConfirm(canvas: any, data: string) {
|
|
8
|
+
if (isH5) {
|
|
9
|
+
const file = await canvasToFile(canvas)
|
|
10
|
+
const fileMd5 = await file2Md5(file)
|
|
11
|
+
const data = new FormData()
|
|
12
|
+
data.append('file', file)
|
|
13
|
+
data.append('companyId', 'c35bd5e0d5834eccb1cfbf4dd538eb61')
|
|
14
|
+
data.append('projectId', 'eb42a2b7e680a4124e78951ccf7f1268')
|
|
15
|
+
data.append('indexDbId', '0')
|
|
16
|
+
data.append('fileMd5', fileMd5)
|
|
17
|
+
data.append('fileSize', `${file.size}`)
|
|
18
|
+
data.append('filename', file.name)
|
|
19
|
+
try {
|
|
20
|
+
const res = await uploadFile(data)
|
|
21
|
+
if (res.code === 200) {
|
|
22
|
+
// console.log('💦res.data', res.data)
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
Taro.showToast({
|
|
26
|
+
title: res.message,
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
Taro.showToast({
|
|
32
|
+
title: '服务异常',
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
// 小程序端:用 Taro uploadFile 适配器
|
|
38
|
+
Taro.getFileSystemManager().getFileInfo({
|
|
39
|
+
filePath: data,
|
|
40
|
+
success: async (res) => {
|
|
41
|
+
const params = {
|
|
42
|
+
filePath: data,
|
|
43
|
+
companyId: 'c35bd5e0d5834eccb1cfbf4dd538eb61',
|
|
44
|
+
projectId: 'eb42a2b7e680a4124e78951ccf7f1268',
|
|
45
|
+
indexDbId: '0',
|
|
46
|
+
fileMd5: res.digest,
|
|
47
|
+
fileSize: res.size,
|
|
48
|
+
filename: `${res.digest}.png`,
|
|
49
|
+
}
|
|
50
|
+
const uploadResStr = await uploadFile(params)
|
|
51
|
+
const uploadRes = JSON.parse(uploadResStr)
|
|
52
|
+
if (uploadRes.code === 200) {
|
|
53
|
+
// console.log('💦uploadRes.data', uploadRes.data)
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
Taro.showToast({
|
|
57
|
+
title: uploadRes.message,
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<template>
|
|
67
|
+
<div class="text-red">
|
|
68
|
+
1112
|
|
69
|
+
<nut-signature @confirm="handleConfirm" />
|
|
70
|
+
</div>
|
|
71
|
+
</template>
|
|
@@ -1,18 +1,71 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import Taro from '@tarojs/taro'
|
|
3
|
+
import { uploadFile } from '@/api/common/upload'
|
|
4
|
+
import { canvasToFile, file2Md5 } from '@/utils'
|
|
5
|
+
import { isH5 } from '@/utils/env'
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
async function handleConfirm(canvas: any, data: string) {
|
|
8
|
+
if (isH5) {
|
|
9
|
+
const file = await canvasToFile(canvas)
|
|
10
|
+
const fileMd5 = await file2Md5(file)
|
|
11
|
+
const data = new FormData()
|
|
12
|
+
data.append('file', file)
|
|
13
|
+
data.append('companyId', 'c35bd5e0d5834eccb1cfbf4dd538eb61')
|
|
14
|
+
data.append('projectId', 'eb42a2b7e680a4124e78951ccf7f1268')
|
|
15
|
+
data.append('indexDbId', '0')
|
|
16
|
+
data.append('fileMd5', fileMd5)
|
|
17
|
+
data.append('fileSize', `${file.size}`)
|
|
18
|
+
data.append('filename', file.name)
|
|
19
|
+
try {
|
|
20
|
+
const res = await uploadFile(data)
|
|
21
|
+
if (res.code === 200) {
|
|
22
|
+
// console.log('💦res.data', res.data)
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
Taro.showToast({
|
|
26
|
+
title: res.message,
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
Taro.showToast({
|
|
32
|
+
title: '服务异常',
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
// 小程序端:用 Taro uploadFile 适配器
|
|
38
|
+
Taro.getFileSystemManager().getFileInfo({
|
|
39
|
+
filePath: data,
|
|
40
|
+
success: async (res) => {
|
|
41
|
+
const params = {
|
|
42
|
+
filePath: data,
|
|
43
|
+
companyId: 'c35bd5e0d5834eccb1cfbf4dd538eb61',
|
|
44
|
+
projectId: 'eb42a2b7e680a4124e78951ccf7f1268',
|
|
45
|
+
indexDbId: '0',
|
|
46
|
+
fileMd5: res.digest,
|
|
47
|
+
fileSize: res.size,
|
|
48
|
+
filename: `${res.digest}.png`,
|
|
49
|
+
}
|
|
50
|
+
const uploadResStr = await uploadFile(params)
|
|
51
|
+
const uploadRes = JSON.parse(uploadResStr)
|
|
52
|
+
if (uploadRes.code === 200) {
|
|
53
|
+
// console.log('💦uploadRes.data', uploadRes.data)
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
Taro.showToast({
|
|
57
|
+
title: uploadRes.message,
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
}
|
|
6
64
|
</script>
|
|
7
65
|
|
|
8
66
|
<template>
|
|
9
|
-
<div class="
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
</div>
|
|
13
|
-
<div class="flex-1 text-green">
|
|
14
|
-
222
|
|
15
|
-
</div>
|
|
16
|
-
<nut-button>111</nut-button>
|
|
67
|
+
<div class="text-red">
|
|
68
|
+
1112
|
|
69
|
+
<nut-signature @confirm="handleConfirm" />
|
|
17
70
|
</div>
|
|
18
71
|
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import './nut-theme.css';
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
const apiUrl = process.env.TARO_APP_API_URL
|
|
2
|
+
const apiAffix = process.env.TARO_APP_API_AFFIX
|
|
3
|
+
const uploadApiAffix = process.env.TARO_APP_UPLOAD_API_AFFIX
|
|
4
|
+
const weappId = process.env.TARO_APP_ID
|
|
5
|
+
const isH5 = process.env.TARO_ENV === 'h5'
|
|
2
6
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
export {
|
|
8
|
+
apiAffix,
|
|
9
|
+
apiUrl,
|
|
10
|
+
isH5,
|
|
11
|
+
uploadApiAffix,
|
|
12
|
+
weappId,
|
|
6
13
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import Taro from '@tarojs/taro'
|
|
2
|
+
import SparkMD5 from 'spark-md5'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* H5 端:canvas 元素转 File
|
|
6
|
+
*/
|
|
7
|
+
export function canvasToFile(canvas, filename = 'image.png', mimeType = 'image/png', quality = 1): Promise<File> {
|
|
8
|
+
return new Promise((resolve) => {
|
|
9
|
+
canvas.toBlob((blob) => {
|
|
10
|
+
const file = new File([blob], filename, { type: mimeType })
|
|
11
|
+
resolve(file)
|
|
12
|
+
}, mimeType, quality)
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 获取本地文件信息(小程序端)
|
|
18
|
+
*/
|
|
19
|
+
export function getFileInfo(filePath: string): Promise<Taro.getFileInfo.SuccessCallbackResult> {
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
Taro.getFileInfo({
|
|
22
|
+
filePath,
|
|
23
|
+
success: resolve,
|
|
24
|
+
fail: reject,
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function file2Md5(file): Promise<string> {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
const reader = new FileReader()
|
|
32
|
+
reader.onload = (e: ProgressEvent<FileReader>) => {
|
|
33
|
+
const spark = new SparkMD5.ArrayBuffer()
|
|
34
|
+
spark.append(e.target?.result)
|
|
35
|
+
resolve(spark.end())
|
|
36
|
+
}
|
|
37
|
+
reader.onerror = reject
|
|
38
|
+
reader.readAsArrayBuffer(file)
|
|
39
|
+
})
|
|
40
|
+
}
|
|
@@ -134,6 +134,7 @@ export function createInstance<
|
|
|
134
134
|
const shouldTransform = getMetaFlag(meta, 'isTransformResponse', config.isTransformResponse ?? true)
|
|
135
135
|
const showSuccess = getMetaFlag(meta, 'isShowSuccessMessage', config.isShowSuccessMessage ?? false)
|
|
136
136
|
const showError = getMetaFlag(meta, 'isShowErrorMessage', config.isShowErrorMessage ?? true)
|
|
137
|
+
const isWrapped = getMetaFlag(meta, 'isWrapped', config.isWrapped ?? true)
|
|
137
138
|
|
|
138
139
|
if (!shouldTransform)
|
|
139
140
|
return response
|
|
@@ -154,7 +155,7 @@ export function createInstance<
|
|
|
154
155
|
return Promise.reject(response)
|
|
155
156
|
}
|
|
156
157
|
|
|
157
|
-
if (!config.isWrapped) {
|
|
158
|
+
if (!isWrapped || (isWrapped === undefined || !config.isWrapped)) {
|
|
158
159
|
if (showSuccess)
|
|
159
160
|
config.successMessageFunc?.(config.successDefaultMessage ?? '操作成功')
|
|
160
161
|
return data
|
|
@@ -2,7 +2,7 @@ import type { TaroConfig } from '@alova/adapter-taro'
|
|
|
2
2
|
import type { VueHookExportType } from 'alova/vue'
|
|
3
3
|
import AdapterTaroVue from '@alova/adapter-taro/vue'
|
|
4
4
|
import Taro from '@tarojs/taro'
|
|
5
|
-
import {
|
|
5
|
+
import { apiAffix, apiUrl, isH5, uploadApiAffix } from '@/utils/env'
|
|
6
6
|
import { createInstance } from './core'
|
|
7
7
|
|
|
8
8
|
type TaroResponse
|
|
@@ -20,7 +20,7 @@ const alovaRequest = createInstance<
|
|
|
20
20
|
TaroResponseHeader,
|
|
21
21
|
VueHookExportType<unknown>
|
|
22
22
|
>({
|
|
23
|
-
baseUrl: `${
|
|
23
|
+
baseUrl: isH5 ? `/${apiAffix}` : `${apiUrl}/${apiAffix}`,
|
|
24
24
|
statusMap: { success: 200, unAuthorized: 401 },
|
|
25
25
|
codeMap: { success: [200] },
|
|
26
26
|
responseDataKey: 'data',
|
|
@@ -42,3 +42,32 @@ const alovaRequest = createInstance<
|
|
|
42
42
|
})
|
|
43
43
|
|
|
44
44
|
export default alovaRequest
|
|
45
|
+
|
|
46
|
+
const alovaUploadRequest = createInstance<
|
|
47
|
+
TaroConfig,
|
|
48
|
+
TaroResponse,
|
|
49
|
+
TaroResponseHeader,
|
|
50
|
+
VueHookExportType<unknown>
|
|
51
|
+
>({
|
|
52
|
+
baseUrl: isH5 ? `/${uploadApiAffix}` : `${apiUrl}/${uploadApiAffix}`,
|
|
53
|
+
statusMap: { success: 200, unAuthorized: 401 },
|
|
54
|
+
codeMap: { success: [200] },
|
|
55
|
+
responseDataKey: 'data',
|
|
56
|
+
responseMessageKey: 'msg',
|
|
57
|
+
commonHeaders: {},
|
|
58
|
+
successMessageFunc: (msg) => {
|
|
59
|
+
Taro.showToast({ title: msg })
|
|
60
|
+
},
|
|
61
|
+
errorMessageFunc: (msg) => {
|
|
62
|
+
Taro.showToast({ title: msg, icon: 'error' })
|
|
63
|
+
},
|
|
64
|
+
unAuthorizedResponseFunc: () => {
|
|
65
|
+
Taro.showToast({ title: '登录过期或未登录' })
|
|
66
|
+
Taro.navigateTo({ url: '/pages/login/index' })
|
|
67
|
+
},
|
|
68
|
+
statesHook: taroAdapter.statesHook,
|
|
69
|
+
requestAdapter: taroAdapter.requestAdapter,
|
|
70
|
+
storageAdapter: taroAdapter.storageAdapter,
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
export { alovaUploadRequest }
|
|
@@ -1,27 +0,0 @@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