这一版本优化了很多
This commit is contained in:
@@ -2,8 +2,8 @@ import Request from './luch-request/index.js';
|
||||
// 基础的url
|
||||
|
||||
|
||||
const baseUrl = 'https://yingji.hexieapi.com/prod-api';
|
||||
// const baseUrl = 'http://192.168.1.168:5004';
|
||||
// const baseUrl = 'https://yingji.hexieapi.com/prod-api';
|
||||
const baseUrl = 'http://192.168.1.168:5004';
|
||||
|
||||
// 图片/文件资源域名:去掉 /prod-api,便于 <image> / previewImage / downloadFile 直接访问
|
||||
const imageBaseUrl = baseUrl.replace(/\/prod-api\/?$/, '');
|
||||
@@ -156,4 +156,19 @@ export const toImageUrl = (filePath) => {
|
||||
return imageBaseUrl + normalized;
|
||||
};
|
||||
|
||||
// 提交附件时使用:统一转为后端需要的相对路径(如 /profile/upload/xxx.jpg)
|
||||
export const toRelativeFilePath = (filePath) => {
|
||||
if (!filePath) return '';
|
||||
|
||||
let p = String(filePath);
|
||||
if (p.startsWith('http://') || p.startsWith('https://')) {
|
||||
p = p.replace(/^https?:\/\/[^/]+/, '');
|
||||
}
|
||||
p = p.replace(/^\/prod-api(?=\/|$)/, '');
|
||||
if (!p.startsWith('/')) {
|
||||
p = `/${p}`;
|
||||
}
|
||||
return p;
|
||||
};
|
||||
|
||||
export { imageBaseUrl };
|
||||
Reference in New Issue
Block a user