这一版本优化了很多

This commit is contained in:
王利强
2026-06-03 10:16:37 +08:00
parent 8046316216
commit 2af9f1fd59
954 changed files with 58194 additions and 1609 deletions

View File

@@ -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 };