Merge remote-tracking branch 'origin/feature/0919_重构env配置' into test

# Conflicts:
#	.gitignore
#	vite.config.ts
This commit is contained in:
rd
2025-09-19 11:46:40 +08:00
13 changed files with 24 additions and 179 deletions

View File

@ -1,36 +0,0 @@
/*
* @Author: 田鑫
* @Date: 2023-02-17 11:15:23
* @LastEditors: 田鑫
* @LastEditTime: 2023-02-21 16:25:32
* @Description: API状态码
*/
export enum API_STATUS_CODE {
/** 正常响应 */
SUCCESS = 200,
/** 会话失效,请重新登录 */
SESSION_FAILUIRE = 1000,
/** 认证失败,无法访问系统资源 */
AUTH_FAILED = 1001,
/** 未授权,无法访问系统资源 */
RESOURCE_FORBIDDEN = 1002,
/** 黑名单用户 */
BLACK_LIST_USER = 1003,
/** 非法IP地址 */
ILLEGAL_IP = 1004,
/** 网关访问受限 */
GATEWAY_FORBIDDEN = 1005,
/** 网关访问异常,请稍后重试 */
GATEWAY_ERROR = 1006,
/** 流控异常 */
TRAFFIC_CONTROL_ERROR = 1007,
/** 资源找不到服务 */
RESOURCE_NOT_FOUND = 1008,
/** 资源请求超时 */
FETCH_TIMEOUT = 1009,
/** 资源响应异常 */
RESOURCE_RESPONSE_ERROR = 1010,
/** 请求路径不符合规范 */
ILLEGAL_PATH = 1011,
}

View File

@ -1,32 +0,0 @@
/*
* @Author: 田鑫
* @Date: 2023-02-21 16:34:47
* @LastEditors: 田鑫
* @LastEditTime: 2023-02-21 16:59:10
* @Description:
*/
import router from '@/router';
import { clearToken } from '@/utils/auth';
import { message } from 'ant-design-vue';
/**
* 处理业务逻辑定义的错误code
* @param errStatus
*/
export const handleCodeError = (error: any) => {
let errMessage = '未知错误';
console.log(error);
errMessage = error.msg;
switch (error.code) {
case 1000:
router.replace({
name: '/login/password',
});
clearToken();
break;
default:
errMessage = error.msg || `未知错误-${error.code}`;
}
message.error(errMessage);
};

View File

@ -25,13 +25,14 @@ enum HttpStatusCode {
InternalServerError = 500,
}
console.log();
//* 导出Request类可以用来自定义传递配置来创建实例
export class Request {
//* axios 实例
private instance: AxiosInstance;
//* 基础配置
private baseConfig: AxiosRequestConfig = {
baseURL: import.meta.env.EO_API_URL,
baseURL: `${import.meta.env.VITE_API_URL}`,
timeout: requestTimeout,
headers: {
'Content-Type': contentType,

19
src/api/types.d.ts vendored
View File

@ -1,19 +0,0 @@
/*
* @Author: 田鑫
* @Date: 2023-02-19 21:52:10
* @LastEditors: 田鑫
* @LastEditTime: 2023-02-21 16:59:27
* @Description:
*/
import 'axios';
import { API_STATUS_CODE } from './apiCodes';
declare module 'axios' {
export interface IWygResponse<T> {
success: boolean;
msg: string;
code: API_STATUS_CODE;
data: T;
timestamp: number;
}
}