Skip to content

fix: 前端修正切換到 chat 切換後回 welcome 的配置保存最終切換頁面#5792

Merged
Soulter merged 2 commits intoAstrBotDevs:masterfrom
itamiokanjiro:itamiokanjiro
Mar 10, 2026
Merged

fix: 前端修正切換到 chat 切換後回 welcome 的配置保存最終切換頁面#5792
Soulter merged 2 commits intoAstrBotDevs:masterfrom
itamiokanjiro:itamiokanjiro

Conversation

@itamiokanjiro
Copy link
Contributor

@itamiokanjiro itamiokanjiro commented Mar 6, 2026

解決了每次切換到chat頁面 回bot配置頁面都跑回 歡迎主頁面的問題

Modifications / 改动点

修改 watch(() => customizer.viewMode (newMode, oldMode) 函數 切換回 / 改成lastBotRoute
新增 watch(route, (newRoute) , 保存 bot 模式的最後路由

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

123


Checklist / 检查清单

  • [] 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。/ If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。/ My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了 requirements.txtpyproject.toml 文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 我的更改没有引入恶意代码。/ My changes do not introduce malicious code.

Summary by Sourcery

错误修复:

  • 修复从聊天切换回机器人模式时的导航问题,现在用户会被重定向到他们上次访问的机器人路由,而不是根页面。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Fix navigation when switching from chat back to bot mode so users are redirected to their last bot route rather than the root page.

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. area:webui The bug / feature is about webui(dashboard) of astrbot. labels Mar 6, 2026
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些整体性的反馈:

  • 建议在访问 localStorage 时增加防护(例如先检查 typeof window !== 'undefined' 或类似方式),以避免这个 header 组件在 SSR / 非浏览器环境中渲染时发生错误。
  • watch(route, ...) 会对 route 对象上的任何变动做出响应;你可能会希望把它收窄为 watch(() => route.fullPath, ...),这样它只会在真实路径发生变化时才运行。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- Consider guarding `localStorage` access (e.g., checking `typeof window !== 'undefined'` or similar) so this header component doesn't break if rendered in an SSR/non-browser context.
- The `watch(route, ...)` will react to any mutation on the route object; you may want to narrow it to `watch(() => route.fullPath, ...)` so it only runs when the actual path changes.

Sourcery 对开源项目免费 —— 如果你觉得我们的评审有帮助,欢迎分享给更多人 ✨
请帮助我变得更有用!你可以在每条评论上点 👍 或 👎,我会根据你的反馈来改进后续的评审。
Original comment in English

Hey - I've left some high level feedback:

  • Consider guarding localStorage access (e.g., checking typeof window !== 'undefined' or similar) so this header component doesn't break if rendered in an SSR/non-browser context.
  • The watch(route, ...) will react to any mutation on the route object; you may want to narrow it to watch(() => route.fullPath, ...) so it only runs when the actual path changes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider guarding `localStorage` access (e.g., checking `typeof window !== 'undefined'` or similar) so this header component doesn't break if rendered in an SSR/non-browser context.
- The `watch(route, ...)` will react to any mutation on the route object; you may want to narrow it to `watch(() => route.fullPath, ...)` so it only runs when the actual path changes.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取請求旨在優化用戶在應用程式不同視圖模式間切換時的導航體驗。它解決了從聊天模式返回機器人模式時,用戶不再被強制重定向到起始頁面,而是返回到他們上次訪問的機器人頁面,從而提升了操作的流暢性和便捷性,確保用戶的導航狀態能夠被正確保存和恢復。

Highlights

  • 修復導航問題: 解決了從聊天模式切換回機器人模式時,應用程式總是跳轉到歡迎頁面的問題,提升了用戶體驗。
  • 保存最後路由: 新增了在機器人模式下自動保存用戶最後訪問路由的功能,確保導航狀態的持久性。
  • 智能重定向: 當用戶從聊天模式切換回機器人模式時,系統會自動導航到他們上次停留的機器人頁面,而非強制返回首頁。
Changelog
  • dashboard/src/layouts/full/vertical-header/VerticalHeader.vue
    • 新增了 LAST_BOT_ROUTE_KEY 常量,用於本地存儲最後的機器人路由。
    • 實現了監聽路由變化的功能,以便在機器人模式下保存當前路由到本地存儲。
    • 修改了 viewMode 監聽器,使其在從聊天模式切換回機器人模式時,導航到本地存儲的最後機器人路由。
Activity
  • 此拉取請求尚未收到任何評論或審閱。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

此 PR 旨在记住用户在“bot”模式下最后访问的页面,并在从“chat”模式切换回来时恢复该页面。该功能通过 localStorage 实现。实现方式直接,但缺少对 localStorage 操作的错误处理,这在某些浏览器环境下可能会导致问题。我已添加评论并提出建议,通过在 localStorage 调用周围添加 try...catch 块来增强代码的健壮性。

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 10, 2026
@Soulter Soulter changed the title 前端修正切換到chat切換後回 welcome 的配置保存最終切換頁面 fix: 前端修正切換到 chat 切換後回 welcome 的配置保存最終切換頁面 Mar 10, 2026
@Soulter Soulter merged commit be017c8 into AstrBotDevs:master Mar 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:webui The bug / feature is about webui(dashboard) of astrbot. lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants