Commit 39469e46 by 杨灿

update:优化接口调用

parent 9b7bc9db
import request from './request'; // 请替换成你实际使用的请求库
// 定义一个登录请求的函数
export const login = async (email:string, password:string) => {
const result = await request({
method: 'POST',
url: `/auth/login?login=${email}&password=${password}`,
});
return result.data; // 返回请求成功时的数据
};
...@@ -59,9 +59,17 @@ instance.interceptors.response.use( ...@@ -59,9 +59,17 @@ instance.interceptors.response.use(
); );
// 封装请求函数 // 封装请求函数
const request = <T>(config: InternalAxiosRequestConfig): Promise<InternalAxiosRequestConfig> => { const request = async <T>(config: InternalAxiosRequestConfig): Promise<InternalAxiosRequestConfig> => {
return instance.request(config); try {
const response = await instance.request(config);
return response;
} catch (error) {
// 在这里处理错误
console.error('Request error:', error);
return Promise.reject(error);
}
}; };
export default request; export default request;
import request from './request'; // 请替换成你实际使用的请求库
// 定义一个登录请求的函数
export const login = async (email:string, password:string) => {
const result = await request({
method: 'POST',
url: `/auth/login?login=${email}&password=${password}`,
});
return result.data; // 返回请求成功时的数据
};
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
text-color="#fff" text-color="#fff"
style="width:220px;" style="width:220px;"
> >
<div style="height:50xp;line-height:50px;"> <div style="height:50xp;line-height:50px;text-align: center;">
<img style="width:32px;height:32px;vertical-align:middle;margin-right:10px;" src="../assets/logo.ico" alt=""> <img style="width:32px;height:32px;vertical-align:middle;margin-right:10px;" src="../assets/logo.ico" alt="">
<span style="font-size: 18px;font-weight:bold;color:#fff;position: relative;top:3px;">欧畅云技术支持</span> <span style="font-size: 18px;font-weight:bold;color:#fff;position: relative;top:3px;">欧畅云技术支持</span>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment