优化:优化响应时间戳数据值

This commit is contained in:
2023-02-08 22:11:05 +08:00
parent 2bc68528a4
commit 8085edbfe6
3 changed files with 6 additions and 8 deletions

View File

@@ -30,8 +30,8 @@ export interface HttpResponse<T = unknown> {
success: boolean; // 是否成功
code: number; // 状态码
msg: string; // 状态信息
timestamp: string; // 时间戳
data: T; // 返回数据
timestamp: string; // 时间戳
}
// response interceptors

View File

@@ -10,20 +10,20 @@ export default ({ mock, setup }: { mock?: boolean; setup: () => void }) => {
export const successResponseWrap = (data: unknown) => {
return {
data,
success: true,
code: 200,
msg: '操作成功',
timestamp: new Date().toLocaleDateString().replace(/\//g, '-'),
data,
timestamp: new Date().getTime(),
};
};
export const failResponseWrap = (data: unknown, msg: string, code = 500) => {
return {
data,
success: false,
code,
msg,
timestamp: new Date().toLocaleDateString().replace(/\//g, '-'),
data,
timestamp: new Date().getTime(),
};
};