django-vue3-admin前端系统配置背景图

发布于 2024-03-08 13:22:21

前端背景图更改后没有生效,查看前端代码他这里是做的固定路径的调用,还是说只能通过改这个路径来更改这个图片

1.png2.png

查看更多

关注者
0
被浏览
2.7k
4 个回答
madaiquan
madaiquan 2026-07-14
这家伙很懒,什么也没写!

修正E:workdjango-vue3-adminwebsrcviewssystemconfigcomponentsformContent.vue中的js{{formContent.vue(uploading...)}}

madaiquan
madaiquan 2026-07-14
这家伙很懒,什么也没写!

// 上传成功
// const handleUploadSuccess = (response: any, file: any, fileList: any, imgKey: any) => {
// const that = this;
// const { code, msg } = response;
// if (code === 2000) {
// const { url } = response.data;
// const { name } = file;
// const type = isImage(name);
// if (!type) {
// errorMessage('只允许上传图片');
// } else {
// const uploadImgKey = formData[imgKey];
// if (!uploadImgKey || uploadImgKey === '') {
// formData[imgKey] = [];
// }
// // console.log(len)
// const dict = {
// name: name,
// url: getBaseURL() + url,
// };
// formData[imgKey].push(dict);
//
// // 新增:同步更新 formList 对应 item 的 value
// const targetItem = formList.value.find(item => item.key === imgKey);
// if (targetItem) {
// targetItem.value = [...formData.value[imgKey]];
// }
// }
// } else {
// errorMessage('上传失败,' + JSON.stringify(msg));
// }
// };
const handleUploadSuccess = (response: any, file: any, fileList: any, imgKey: any) => {
const { code, msg } = response;
if (code === 2000) {

const { url } = response.data;
const { name } = file;
const type = isImage(name);
if (!type) {
  errorMessage('只允许上传图片');
  return;
}
// 初始化数组
if (!formData.value[imgKey]) {
  formData.value[imgKey] = [];
}
const dict = {
  name: name,
  url: getBaseURL() + url,
};
formData.value[imgKey].push(dict);

// 新增:同步更新 formList 对应 item 的 value
const targetItem = formList.value.find(item => item.key === imgKey);
if (targetItem) {
  targetItem.value = [...formData.value[imgKey]];
}

} else {

errorMessage('上传失败,' + JSON.stringify(msg));

}
};

madaiquan
madaiquan 2026-07-14
这家伙很懒,什么也没写!

// 删除时的钩子
// const beforeRemove = (file: any, fileList: any, key: any) => {
// var index = 0;
// formData[key].map((value: any, inx: any) => {
// if (value.uid === file.uid) index = inx;
// });
// formData[key].splice(index, 1);
// };
const beforeRemove = (file: any, fileList: any, key: any) => {
// 删除formData里的图片
const arr = formData.value[key] || [];
const index = arr.findIndex((v: any) => v.uid === file.uid);
if (index > -1) {

arr.splice(index, 1);

}

// 新增:同步更新formList对应item.value
const targetItem = formList.value.find(item => item.key === key);
if (targetItem) {

targetItem.value = [...arr];

}
};

madaiquan
madaiquan 2026-07-14
这家伙很懒,什么也没写!

上传成功时同步更新 item.value,删除图片时同步更新 item.value,就可以了

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览