image upload and keep if not changed
This commit is contained in:
parent
91ede95530
commit
939c982c40
2 changed files with 16 additions and 8 deletions
|
@ -74,10 +74,14 @@ export const useSettingStore = defineStore("setting", {
|
|||
return res;
|
||||
});
|
||||
},
|
||||
async uploadImage(data: { key: "club.logo" | "club.icon"; value?: File }[]): Promise<AxiosResponse<any, any>> {
|
||||
async uploadImage(
|
||||
data: { key: "club.logo" | "club.icon"; value?: File | "keep" }[]
|
||||
): Promise<AxiosResponse<any, any>> {
|
||||
const formData = new FormData();
|
||||
for (let entry of data) {
|
||||
if (entry.value) formData.append(entry.key, entry.value);
|
||||
if (entry.value) {
|
||||
formData.append(typeof entry.value == "string" ? entry.key : entry.key.split(".")[1], entry.value);
|
||||
}
|
||||
}
|
||||
return await http
|
||||
.put("/admin/setting/images", formData, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue