vending-machine/mobile/utils/image.js
2026-04-08 21:03:13 +08:00

14 lines
424 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { BASE_URL } from '../api/request.js'
/**
* 将后端返回的相对路径图片URL转换为完整URL
* 如果已经是完整URLhttp/https开头则直接返回
* @param {string} url - 图片路径
* @returns {string} 完整的图片URL
*/
export function resolveImageUrl(url) {
if (!url) return ''
if (url.startsWith('http://') || url.startsWith('https://')) return url
return `${BASE_URL}${url}`
}