feat: 提交请求封装

This commit is contained in:
Json_Lee
2025-04-19 12:15:28 +08:00
parent a4c360ee52
commit 294e818487
26 changed files with 1543 additions and 162 deletions
+32
View File
@@ -0,0 +1,32 @@
import hookFetch from 'hook-fetch';
import { sseTextDecoderPlugin } from 'hook-fetch/plugins';
interface BaseResponse {
code: number;
data: null;
message: string;
}
const instance = hookFetch.create<BaseResponse, unknown, 'data'>({
baseURL: 'https://web.pandarobot.chat/api',
headers: {
'Content-Type': 'application/json',
},
plugins: [sseTextDecoderPlugin()],
});
function jwtPlugin() {
return {
name: 'jwt',
};
}
instance.use(jwtPlugin());
export const request = instance.request;
export const post = instance.post;
export const get = instance.get;
export default instance;