This commit is contained in:
2025-10-10 10:06:56 +08:00
parent 4fbe51d625
commit 6f22c9bffd
37 changed files with 2176 additions and 1183 deletions

View File

@@ -2,10 +2,12 @@
export type HttpMethod = 'GET' | 'POST';
const BASE_CLIENT = 'http://localhost:8081'; // erp_client_sb
const BASE_RUOYI = 'http://192.168.1.89:8080';
const BASE_RUOYI = 'http://192.168.1.89:8085';
function resolveBase(path: string): string {
// 走 ruoyi-admin 的路径:鉴权版本、平台工具路由
// 走 ruoyi-admin 的路径:鉴权、设备管理、版本、平台工具路由
if (path.startsWith('/monitor/account')) return BASE_RUOYI; // 账号认证相关
if (path.startsWith('/monitor/device')) return BASE_RUOYI; // 设备管理
if (path.startsWith('/system/')) return BASE_RUOYI; // 版本控制器 VersionController
if (path.startsWith('/tool/banma')) return BASE_RUOYI; // 既有规则保留
// 其他默认走客户端服务
@@ -41,7 +43,12 @@ async function request<T>(path: string, options: RequestInit): Promise<T> {
}
const contentType = res.headers.get('content-type') || '';
if (contentType.includes('application/json')) {
return (await res.json()) as T;
const json: any = await res.json();
// 检查业务状态码
if (json.code !== undefined && json.code !== 0 && json.code !== 200) {
throw new Error(json.msg || json.message || '请求失败');
}
return json as T;
}
return (await res.text()) as unknown as T;
}