feat(dashboard): add auto switch theme (default off)#6405
feat(dashboard): add auto switch theme (default off)#6405LIghtJUNction merged 2 commits intoAstrBotDevs:devfrom
Conversation
feat(dashboard): move all get theme and set theme by check current theme into stores/customizer
Summary of ChangesHello, 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! 此拉取请求旨在通过引入一个基于用户系统偏好自动切换主题的功能,来提升用户体验。核心改动在于将主题管理逻辑集中到 Pinia store 中,实现了更清晰、更易维护的代码结构。用户现在可以灵活选择是否启用自动同步主题,并且手动切换主题时会自动禁用自动同步,确保了主题设置的灵活性和用户控制权。 Highlights
Changelog
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The auto theme sync only registers the
matchMedialistener inVerticalHeaderon mount whenautoSwitchThemeis already true, so enabling the toggle later in Settings won’t start listening to system changes; consider watchingautoSwitchThemeor centralizing the listener setup in the store so it activates/deactivates dynamically. - The logic in
autoSwitchThemeListenerduplicates whatAPPLY_SYSTEM_THEMEdoes; you could simplify and avoid divergence by delegating toAPPLY_SYSTEM_THEME()instead of recalculating and setting the theme separately.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The auto theme sync only registers the `matchMedia` listener in `VerticalHeader` on mount when `autoSwitchTheme` is already true, so enabling the toggle later in Settings won’t start listening to system changes; consider watching `autoSwitchTheme` or centralizing the listener setup in the store so it activates/deactivates dynamically.
- The logic in `autoSwitchThemeListener` duplicates what `APPLY_SYSTEM_THEME` does; you could simplify and avoid divergence by delegating to `APPLY_SYSTEM_THEME()` instead of recalculating and setting the theme separately.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
根据Gemini的意见更改了一些地方。 将原本的状态更新挪到了App.vue里,可以去除很多地方更新theme所需要的theme依赖。 将翻译修改了 将监听器改为了watch
|
可以 |
feat(dashboard): move all get theme and set theme by check current theme into stores/customizer
添加了根据浏览器主题自动切换页面主题的功能(默认不打开),打开按钮后如果页面主题和浏览器不匹配就会自动切换,无需刷新,可通过在其他地方手动切换主题关闭,也可直接关闭按钮。
Modifications / 改动点
在Settings页添加了一个按钮用于控制是否自动切换(默认关)
在VerticalHeader里添加了自动切换的逻辑以及监听器。
在stores/customizer里添加了判断当前是否是深色背景的getter和用于打开自动切换,自动切换,手动切换的actions。
添加了这个按钮相关的中英文翻译,改动了其他页面独立切换主题的逻辑(如果有),改动了其他页面判断主题的方式。
改动了ConversationSideBar中的中文描述(从夜间/日间改为深色/浅色,和其他地方统一)
Screenshots or Test Results / 运行截图或测试结果
按钮位置

未打开自动切换
打开之后
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.txt和pyproject.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.txtandpyproject.toml.😮 我的更改没有引入恶意代码。
/ My changes do not introduce malicious code.
/ I have read and understood all the above and confirm this PR follows the rules.
🚀 我确保本次开发基于 dev 分支,并将代码合并至开发分支(除非极其紧急,才允许合并到主分支)。
/ I confirm that this development is based on the dev branch and will be merged into the development branch, unless it is extremely urgent to merge into the main branch.
/ I did not read the above carefully before submitting.
Summary by Sourcery
Add optional automatic theme synchronization with the system appearance and centralize theme management in the customizer store.
New Features:
Enhancements: