Initial commit: 商品售卖网站

This commit is contained in:
2026-04-13 07:20:09 +08:00
commit c6154273f2
865 changed files with 26573 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 'http://localhost:8080/api'
const BASE_URL = API_BASE_URL.replace('/api', '')
export function getImageUrl(path: string): string {
if (!path) return ''
if (path.startsWith('http://') || path.startsWith('https://')) {
return path
}
if (path.startsWith('/')) {
return BASE_URL + path
}
return BASE_URL + '/' + path
}
export function getFirstImage(images: string): string {
if (!images) return ''
const arr = images.split(',').map((s: string) => s.trim()).filter(Boolean)
const first = arr[0] || ''
return getImageUrl(first)
}