feat:增加图片存储模式

This commit is contained in:
2026-02-14 16:55:52 +08:00
parent 223a59cd8a
commit 4dc541da85
24 changed files with 333 additions and 468 deletions

View File

@@ -97,7 +97,6 @@ import { useAppStore } from '@/store/app.ts'
import { ElMessage, ElMessageBox, FormRules, UploadProps, UploadRawFile, UploadRequestOptions, UploadUserFile } from 'element-plus'
import { productRules } from '@/utils/element/elRules.ts'
import { onMounted, reactive, ref } from 'vue'
import { AListUrl } from '@/utils'
import { acceptImageTypes } from '@/utils/file.ts'
import { Plus } from '@element-plus/icons-vue'
import { beforeUploadImage, httpRequestFile } from '@/utils/element/elUpload.ts'
@@ -115,6 +114,17 @@ onMounted(async () => {
initImageFileList()
})
const initImageFileList = () => {
imageFileList.value = []
const { imageUrl } = productStore.currentProduct
if (imageUrl) {
imageFileList.value.push({
name: 'image',
url: imageUrl
})
}
}
const beforeUpload: UploadProps['beforeUpload'] = (rawFile: UploadRawFile) => {
return beforeUploadImage(rawFile)
}
@@ -124,7 +134,7 @@ const httpRequest: UploadProps['httpRequest'] = async (options: UploadRequestOpt
}
const handleSuccess = (response: string) => {
productStore.currentProduct.imageUrl = `p${response}`
productStore.currentProduct.imageUrl = response
}
const handleExceed: UploadProps['onExceed'] = () => {
@@ -139,17 +149,6 @@ const beforeRemove: UploadProps['beforeRemove'] = () => {
return ElMessageBox.confirm('确认删除该文件?').then(() => true, () => false)
}
const initImageFileList = () => {
imageFileList.value = []
const { imageUrl } = productStore.currentProduct
if (imageUrl) {
imageFileList.value.push({
name: 'image',
url: `${AListUrl}${imageUrl}`
})
}
}
/**
* 点击确认按钮
*/