优化页面、修复BUG

This commit is contained in:
李琦
2026-06-24 16:50:04 +08:00
parent 88ba9be318
commit 3f653bc336
36 changed files with 1672 additions and 2401 deletions

View File

@@ -187,7 +187,7 @@
<script setup lang="ts">
import { ref, computed } from 'vue'
import { useToast } from '../../composables/useToast'
import { API_BASE } from '../../services/api'
import { API_BASE, authFetch, parseApiResponse } from '../../services/api'
import AttachmentLibraryModal from './AttachmentLibraryModal.vue'
const props = withDefaults(defineProps<{
@@ -365,22 +365,12 @@ const uploadSingleFile = async (file: File): Promise<string | null> => {
}
formData.append('storageType', 'local')
const token = localStorage.getItem('token')
const response = await fetch(`${API_BASE}/admin/attachments/upload`, {
const result = await parseApiResponse<{ fileUrl: string }>(await authFetch(`${API_BASE}/admin/attachments/upload`, {
method: 'POST',
headers: {
...(token ? { Authorization: `Bearer ${token}` } : {})
},
headers: {},
body: formData
})
if (!response.ok) {
const errorData = await response.json()
throw new Error(errorData.message || '上传失败')
}
const data = await response.json()
return data.result.fileUrl
}))
return result.fileUrl
} catch (err: any) {
console.error('Upload error:', err)
throw err