Skip to content

Conversation

@ocetars
Copy link
Member

@ocetars ocetars commented Dec 27, 2025

为 Dashboard 添加两处用户界面状态持久化功能,提升用户体验。

Modifications / 改动点

  1. 平台页面日志展开状态记忆
    文件: dashboard/src/views/PlatformPage.vue
    改动: 日志区域的展开/收起状态现在会保存到浏览器 localStorage
    效果: 切换页面后返回,日志区域会保持之前的展开/收起状态,无需每次手动展开
  2. 侧边栏"更多功能"展开状态记忆
    文件: dashboard/src/layouts/full/vertical-sidebar/VerticalSidebar.vue
    改动:
    添加 v-model:opened 绑定展开状态到 localStorage
    添加 :open-strategy="'multiple'" 防止 Vuetify 在路由切换时自动收起分组
    效果: 展开"更多功能"后,在不同页面间切换时保持展开状态,无需反复点击展开
  • This is NOT a breaking change. / 这不是一个破坏性变更。

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

default.mp4

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

Persist dashboard UI state for sidebar groups and platform page console visibility.

New Features:

  • Remember the expanded state of the vertical sidebar groups across navigations using local storage.
  • Persist the platform page log/console visibility state across page visits using local storage.

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Dec 27, 2025
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 - 我提供了一些整体性的反馈:

  • 在组件初始化阶段直接访问 localStorageopenedItems 的 ref 和 showConsole 的默认值)在 SSR 或非浏览环境中可能会出错;可以考虑使用 typeof window !== 'undefined' 做保护,或者把读取逻辑延后到 onMounted 中执行。
  • JSON.parse(localStorage.getItem('sidebar_openedItems') || '[]') 在已存值格式不正确时会抛出异常;将其封装到一个带有 try/catch 和安全回退的辅助函数中,会让持久化逻辑更健壮。
  • watch(openedItems, ...) 被声明为 deep: true,但 openedItems 很可能只是一个原始 id 的数组;去掉 deep(或者 watch 一个已序列化的计算属性)可以避免不必要的响应式开销。
给 AI 代理的提示词
Please address the comments from this code review:

## Overall Comments
- Accessing `localStorage` directly during component initialization (`openedItems` ref and `showConsole` default) can break in SSR or non-browser environments; consider guarding with `typeof window !== 'undefined'` or deferring reads to `onMounted`.
- The `JSON.parse(localStorage.getItem('sidebar_openedItems') || '[]')` call will throw if the stored value is malformed; wrapping this in a small helper with try/catch and a safe fallback would make the persistence more robust.
- The `watch(openedItems, ...)` is declared `deep: true` even though `openedItems` is likely an array of primitive ids; dropping `deep` (or watching a computed serialized value) would avoid unnecessary reactivity overhead.

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

Hey - I've left some high level feedback:

  • Accessing localStorage directly during component initialization (openedItems ref and showConsole default) can break in SSR or non-browser environments; consider guarding with typeof window !== 'undefined' or deferring reads to onMounted.
  • The JSON.parse(localStorage.getItem('sidebar_openedItems') || '[]') call will throw if the stored value is malformed; wrapping this in a small helper with try/catch and a safe fallback would make the persistence more robust.
  • The watch(openedItems, ...) is declared deep: true even though openedItems is likely an array of primitive ids; dropping deep (or watching a computed serialized value) would avoid unnecessary reactivity overhead.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Accessing `localStorage` directly during component initialization (`openedItems` ref and `showConsole` default) can break in SSR or non-browser environments; consider guarding with `typeof window !== 'undefined'` or deferring reads to `onMounted`.
- The `JSON.parse(localStorage.getItem('sidebar_openedItems') || '[]')` call will throw if the stored value is malformed; wrapping this in a small helper with try/catch and a safe fallback would make the persistence more robust.
- The `watch(openedItems, ...)` is declared `deep: true` even though `openedItems` is likely an array of primitive ids; dropping `deep` (or watching a computed serialized value) would avoid unnecessary reactivity overhead.

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.

@dosubot dosubot bot added the area:webui The bug / feature is about webui(dashboard) of astrbot. label Dec 27, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 27, 2025
@Soulter Soulter merged commit 71ad974 into AstrBotDevs:master Dec 27, 2025
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