-
Notifications
You must be signed in to change notification settings - Fork 8.1k
feat: 以插件模式支持alova请求库 #6675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 以插件模式支持alova请求库 #6675
Conversation
- 新增 Alova 客户端类,提供请求拦截器和响应处理功能 - 在 package.json 中添加 Alova相关配置 - 更新 pnpm-workspace.yaml,添加 Alova依赖
- 引入 AlovaClient 并配置登录、刷新 token 等功能 - 重构 auth 和 user API,使用新的 AlovaClient - 添加请求成功拦截器,统一处理错误码
- 引入 useResponseSuccess 函数以统一响应格式 - 修改返回值为包含 accessToken 的对象 - 删除多余的空行
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
- 为 AlovaClient 类添加泛型参数 T,默认为 AlovaGenerics - 重构请求拦截器和响应拦截器的类型定义 - 新增 ResponseData接口定义标准响应数据结构- 新增 ResponseSuccessMethod 类型定义请求成功拦截器方法 - 优化构造函数,支持传入自定义认证选项 - 为类方法添加 JSDoc 注释,提高代码可读性 - 更新 pnpm-lock.yaml,添加 alova 依赖
- 引入 createServerTokenAuthentication 用于服务端认证 - 在请求头中添加 Accept-Language 以支持国际化 -优化 client 实例创建方式,使用解构赋值
-移除自定义 ResponseData 接口,使用 alova 的 Response接口 - 重新定义 responseSuccessInterceptor 类型为 ResponseSuccessHandler - 优化响应成功拦截器的执行流程 - 移除不必要的错误抛出和 JSON 解析
- 添加 ResponseData 接口,用于统一响应数据格式 - 修改 login 方法,增加状态码和错误信息处理- 添加 logout 方法,暂未实现具体逻辑 - 优化 refreshTokenOnSuccess 处理逻辑 -重构 response success interceptor,增加状态码和错误信息处理
-移除了未使用的 import 语句 - 重新实现了 logoutApi 方法,使用 client 替代 baseRequestClient - 为 logoutApi 方法添加了 meta 信息,指定 authRole 为 'logout' - 删除了未使用的 withCredentials 配置项
- 在 auth.ts 文件中,注释掉了设置 accessToken 的代码行 - 这可能是为了暂时禁用该功能或进行调试
添加alova库的支持,内置token刷新等功能