完成仓库模块

This commit is contained in:
Zy
2026-04-23 17:59:36 +08:00
parent 985860c9de
commit 9d4416b238
39 changed files with 5040 additions and 80 deletions

View File

@@ -51,13 +51,20 @@ export function needVillageId(url: string): boolean {
// 去掉 ? 后面的参数
const path = url.split('?')[0];
// 遍历白名单,正则匹配
return !whiteVillageId.some((pattern) => {
// 把 * 转成正则的 .* 通配
const regPattern = pattern.replace(/\*/g, '[^\\/]*');
const regex = new RegExp(`^${regPattern}$`);
return regex.test(path);
// 遍历白名单匹配
const isWhite = whiteVillageId.some((pattern) => {
// 处理 /* 结尾的通配(匹配该路径及其所有子路径)
if (pattern.endsWith('/*')) {
const basePath = pattern.slice(0, -2); // 比如 /warehouse/* → /warehouse
// 只要 path 是 /warehouse 或 /warehouse/ 或 /warehouse/xxx 就匹配
return path === basePath || path.startsWith(basePath + '/');
} else {
// 精确匹配
return path === pattern;
}
});
return !isWhite;
}
// 请求拦截器
service.interceptors.request.use(
@@ -105,6 +112,7 @@ service.interceptors.request.use(
} else {
obj = config.data;
}
if (!config.data) config.data = {};
Object.assign(config.data, obj);