chore: 统一本地服务器与远程仓库源码
- 合并 main 与 master 历史并以服务器结构为基线 - 保留迁移、数据保留、AWS 账单与部署安全能力 - 建立 SDD 规格和 CI 验证闭环
This commit is contained in:
commit
fd60361d93
460 files changed
+37492
-23871
No files matched your search
@@ -53,8 +53,10 @@ function resolveApiUrl(path: string): string {
|
||||
export function getWsBase(): string {
|
||||
const envBase = import.meta.env.VITE_API_BASE_URL;
|
||||
if (envBase) {
|
||||
const origin = String(envBase).replace(/\/$/, '').replace(/\/api\/v1$/, '');
|
||||
return origin.replace(/^http/, 'ws');
|
||||
const apiUrl = new URL(String(envBase), window.location.origin);
|
||||
apiUrl.protocol = apiUrl.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
apiUrl.pathname = apiUrl.pathname.replace(/\/$/, '').replace(/\/api\/v1$/, '');
|
||||
return apiUrl.toString().replace(/\/$/, '');
|
||||
}
|
||||
const proto = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
return `${proto}//${window.location.host}`;
|
||||
@@ -101,14 +103,14 @@ async function request<T = any>(
|
||||
clearToken();
|
||||
useUserStore.getState().logout();
|
||||
window.location.href = '/login';
|
||||
throw new Error(i18n.t('common.request.tokenExpired'));
|
||||
throw new Error(i18n.t('common.requestts.sd3ab821c'));
|
||||
}
|
||||
|
||||
let json: ApiResponse<T>;
|
||||
try {
|
||||
json = await response.json();
|
||||
} catch {
|
||||
throw new Error(`HTTP ${response.status}: ${i18n.t('common.responseParseError')}`);
|
||||
throw new Error(`HTTP ${response.status}: 响应解析失败`);
|
||||
}
|
||||
|
||||
if (!response.ok || (json.code && json.code !== 200)) {
|
||||
@@ -191,4 +193,4 @@ export const http = {
|
||||
},
|
||||
};
|
||||
|
||||
export default http;
|
||||
export default http;
|
||||
Reference in new issue
Block a user