22 lines
594 B
TypeScript
22 lines
594 B
TypeScript
import { sessionGet } from '@/utils/cache-session-utils';
|
|
import { validHttp } from '@/utils/regular-utils';
|
|
|
|
/**
|
|
* 解析资源文件绝对路径 http
|
|
* @param path 服务端资源文件
|
|
* @returns
|
|
*/
|
|
export function parseUrlPath(path: string) {
|
|
if (!path || path === '#') {
|
|
return '#';
|
|
}
|
|
if (validHttp(path)) {
|
|
return path;
|
|
}
|
|
// 兼容旧前端可改配置文件
|
|
const baseUrl = import.meta.env.PROD
|
|
? sessionGet('baseUrl') || import.meta.env.VITE_API_BASE_URL
|
|
: import.meta.env.VITE_API_BASE_URL;
|
|
return `${baseUrl}${path}?r=${Math.random().toFixed(2)}`;
|
|
}
|