Skip to content

Conversation

jinmao88
Copy link
Collaborator

添加alova库的支持,内置token刷新等功能

- 新增 Alova 客户端类,提供请求拦截器和响应处理功能
- 在 package.json 中添加 Alova相关配置
- 更新 pnpm-workspace.yaml,添加 Alova依赖
- 引入 AlovaClient 并配置登录、刷新 token 等功能
- 重构 auth 和 user API,使用新的 AlovaClient
- 添加请求成功拦截器,统一处理错误码
- 引入 useResponseSuccess 函数以统一响应格式
- 修改返回值为包含 accessToken 的对象
- 删除多余的空行
Copy link

changeset-bot bot commented Aug 23, 2025

⚠️ No Changeset found

Latest commit: 382918b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Aug 23, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch alova

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

jinmao88 and others added 7 commits August 23, 2025 23:05
- 为 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 的代码行
- 这可能是为了暂时禁用该功能或进行调试
@jinmao88 jinmao88 closed this Sep 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant