mirror of
https://github.com/TangSengDaoDao/TangSengDaoDaoManager
synced 2025-06-06 17:50:44 +00:00
perf: 👌代码优化
This commit is contained in:
parent
d17c1fba40
commit
99179834ba
@ -22,8 +22,8 @@
|
||||
list-type="picture-card"
|
||||
:show-file-list="false"
|
||||
:headers="headers"
|
||||
:before-upload="beforeAvatarUpload"
|
||||
:on-success="handleAvatarSuccess"
|
||||
:before-upload="beforeUploadFile"
|
||||
:on-success="onFileSuccess"
|
||||
>
|
||||
<img v-if="formData.cover" :src="`${BU_DOU_CONFIG.APP_URL}${formData.cover}`" class="avatar" />
|
||||
<el-icon v-else><Plus /></el-icon>
|
||||
@ -113,13 +113,16 @@ watch(
|
||||
}
|
||||
}
|
||||
);
|
||||
// 上传图片
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*/
|
||||
const headers = {
|
||||
token: userStore.token
|
||||
};
|
||||
const actionURL = ref('');
|
||||
// 图片上传前获取上传地址
|
||||
const beforeAvatarUpload = async (rawFile: any) => {
|
||||
const beforeUploadFile = async (rawFile: any) => {
|
||||
const fileData = {
|
||||
path: `/${rawFile.uid}/${rawFile.name}`,
|
||||
type: 'report'
|
||||
@ -133,7 +136,7 @@ const beforeAvatarUpload = async (rawFile: any) => {
|
||||
}
|
||||
};
|
||||
// 图片上传成功获取地址
|
||||
const handleAvatarSuccess = (response: any, _uploadFile: any) => {
|
||||
const onFileSuccess = (response: any, _uploadFile: any) => {
|
||||
formData.value.cover = response.path;
|
||||
};
|
||||
// 取消
|
||||
|
@ -22,8 +22,8 @@
|
||||
list-type="picture-card"
|
||||
:show-file-list="false"
|
||||
:headers="headers"
|
||||
:before-upload="beforeAvatarUpload"
|
||||
:on-success="handleAvatarSuccess"
|
||||
:before-upload="beforeUploadFile"
|
||||
:on-success="onFileSuccess"
|
||||
>
|
||||
<img v-if="formData.icon" :src="`${BU_DOU_CONFIG.APP_URL}${formData.icon}`" class="avatar" />
|
||||
<el-icon v-else><Plus /></el-icon>
|
||||
@ -133,11 +133,15 @@ watch(
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*/
|
||||
const headers = {
|
||||
token: userStore.token
|
||||
};
|
||||
const actionURL = ref('');
|
||||
const beforeAvatarUpload = async (rawFile: any) => {
|
||||
// 图片上传前获取上传地址
|
||||
const beforeUploadFile = async (rawFile: any) => {
|
||||
const fileData = {
|
||||
path: `/${rawFile.uid}/${rawFile.name}`,
|
||||
type: 'report'
|
||||
@ -150,7 +154,8 @@ const beforeAvatarUpload = async (rawFile: any) => {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
const handleAvatarSuccess = (response: any, _uploadFile: any) => {
|
||||
// 图片上传成功获取地址
|
||||
const onFileSuccess = (response: any, _uploadFile: any) => {
|
||||
formData.value.icon = response.path;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user