Skip to content

Commit 2f3e76d

Browse files
committed
feat: 更新版本号至 1.3.4,优化图片删除逻辑以处理未知来源图片
1 parent cd374d5 commit 2f3e76d

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

internal/models/constant.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ const (
164164
)
165165

166166
const (
167-
Version = "1.3.3" // 当前版本号
167+
Version = "1.3.4" // 当前版本号
168168
)
169169

170170
const (

internal/services/others_service.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func DeleteImage(image dto.ImageDto) error {
161161
return errors.New(models.ImageNotFoundMessage)
162162
}
163163

164-
if image.SOURCE == "" || image.SOURCE == models.ImageSourceLocal {
164+
if image.SOURCE == models.ImageSourceLocal {
165165
// 获取图片名字(去除前面的/images/)
166166
imageName := image.URL[len("/images/"):]
167167

@@ -176,6 +176,16 @@ func DeleteImage(image dto.ImageDto) error {
176176
// TODO: S3 删除图片
177177
} else if image.SOURCE == models.ImageSourceR2 {
178178
// TODO: R2 删除图片
179+
} else {
180+
// 未知图片来源按本地图片处理
181+
// 获取图片名字(去除前面的/images/)
182+
imageName := image.URL[len("/images/"):]
183+
184+
// 构造图片路径
185+
imagePath := fmt.Sprintf("data/images/%s", imageName)
186+
187+
// 删除图片
188+
return pkg.DeleteFile(imagePath)
179189
}
180190

181191
return nil

web/src/utils/other.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export const getImageUrl = (image: { imageUrl: string; imageSource: string }) =>
66
} else if (image.imageSource === 'url') {
77
return String(image.imageUrl)
88
} else {
9-
return ''
9+
// 未知的图片来源,按照本地图片处理
10+
return getApiUrl() + String(image.imageUrl)
1011
}
1112
}
1213

0 commit comments

Comments
 (0)