修复一些问题

This commit is contained in:
李琦
2026-07-08 08:18:02 +08:00
parent 41e56b3be6
commit 497d0a840f
43 changed files with 1078 additions and 554 deletions

View File

@@ -1,36 +1,26 @@
/**
* 图片 URL 处理工具函数
*/
// 图片资源基础域名
const IMAGE_BASE_URL = 'https://g-ws.nailaoyun.cn'
import { API_ORIGIN } from '@/config/app'
/**
* 解析图片 URL,为相对路径添加域名前缀
* @param url 图片路径(可能是相对路径或完整 URL)
* @returns 完整的图片 URL
*/
export function resolveImageUrl(url?: string): string {
if (!url) return ''
// 已经是完整 URL(http/https/data URI)
if (url.startsWith('http://') || url.startsWith('https://') || url.startsWith('data:')) {
return url
}
// 仅处理 /upload/ 开头的路径
if (url.startsWith('/uploads/')) {
return IMAGE_BASE_URL + url
const normalized = url.startsWith('/') ? url : `/${url}`
if (normalized.startsWith('/uploads/')) {
return API_ORIGIN + normalized
}
// 其他情况直接返回
return url
}
/**
* 获取图片基础 URL
*/
export function getImageBaseUrl(): string {
return IMAGE_BASE_URL
return API_ORIGIN
}