v2体验版

This commit is contained in:
2026-08-31 13:35:50 +08:00
parent 3b4a2f9a78
commit 3bd58e05c5
28 changed files with 299 additions and 115 deletions
+18 -2
View File
@@ -11,7 +11,14 @@
*/
// 基础路径:修改此处即可切换后端地址
const BASE_URL = 'https://official.inkreach.cc/api/';
// #ifdef H5
// H5 端走 devServer 代理(manifest.json h5.devServer.proxy),规避浏览器 CORS 限制
const BASE_URL = '/';
// #endif
// #ifndef H5
// 小程序端直连后端 v2 环境
const BASE_URL = 'https://official.inkreach.cc/v2-api/';
// #endif
export { BASE_URL };
// 默认配置
@@ -25,7 +32,16 @@ export function buildUrl(url) {
if (/^https?:\/\//i.test(url)) return url;
const base = BASE_URL.replace(/\/+$/, '');
const path = url.replace(/^\/+/, '');
return path ? `${base}/${path}` : base;
let full = path ? `${base}/${path}` : base;
// #ifdef H5
// uni-app H5 的 image 组件会将以 / 开头的路径重写为 routerBase + path
// (如 /assets/x.png → /h5/assets/x.png),导致 devServer 代理匹配不到而 404。
// 这里拼成完整绝对地址(https://host/assets/x.png),image 组件对 http(s):// 开头的路径原样放行
if (typeof window !== 'undefined' && full.charAt(0) === '/') {
full = window.location.origin + full;
}
// #endif
return full;
}
// 统一取 header(注入 token