create-bubbles 0.1.8 → 0.1.9
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/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
package/package.json
CHANGED
|
@@ -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",
|
|
@@ -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 @@
|
|
|
1
|
-
-----BEGIN RSA PRIVATE KEY-----
|
|
2
|
-
MIIEpQIBAAKCAQEA8F9CtEfBvL1L6KpXvIbXVPktUpBQWrM6336lYy4RI7LYeQqu
|
|
3
|
-
6FTuc9Xj/efpLHk25bO2B0/cbnm+fOsKqAOF/7q9KPuLVVNkCMlDrte62wuHXuU7
|
|
4
|
-
c3mKNjZ1LfUCeM1oVi4w1rYYm9m9D1trHvvCSc+UJvjQeE1Zbd9ExH12eCllkU0n
|
|
5
|
-
ARUAP2XoRNeXEShJiQ8EHc89Pko1v1hc3h6eOh0y4lBfqiasr/yj2Bkuc3WDSu3J
|
|
6
|
-
iUHFeKBIkaH7dAG8m86SlmS4YU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