Skip to content

Feat: 显示插件列表时可选隐藏前缀 #1681

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

Closed
wants to merge 6 commits into from

Conversation

Kwicxy
Copy link
Contributor

@Kwicxy Kwicxy commented May 30, 2025

Motivation

插件市场表格中 插件名称字段过长 一堆滚动条的话不好看
考虑对插件名称中的固定前缀部分(astrbot_plugin_)在显示时进行删减以改善可读性

Modifications

ExtensionMarketplace.vue:

  1. showPluginFullName字段控制是否显示完整名称
  2. trimExtensionName()方法对前缀进行删减,新增键trimmedName,不修改原name
  3. 表格默认显示缩略名称(删减了前缀),增加一个显示完整名称按钮用于切换
  4. 页面顶部问号按钮tooltip加入宽度限制(之前是撑满整页)和延迟时间

其他:

  1. 代码样式微调
  2. 仪表盘 消息趋势图表的tooltip跟随深色模式切换

Check

  • 😊 我的 Commit Message 符合良好的规范
  • 👀 我的更改经过良好的测试
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了 requirements.txtpyproject.toml 文件相应位置。
  • 😮 我的更改没有引入恶意代码

Sourcery 总结

在插件市场中,可以裁剪扩展名称中固定的前缀,并提供一个开关来切换显示完整名称。同时,对仪表盘组件进行了一些小的 UI 和主题增强。

新功能:

  • 在插件市场中裁剪插件名称的前缀,并添加一个开关来切换完整名称的显示

增强:

  • 限制帮助工具提示的宽度,并在插件市场中增加打开延迟
  • 更新扩展列表条目的滚动条样式和按钮图标
  • 调整聊天侧边栏和会话列表的背景、颜色和间距
  • 根据当前的 UI 主题切换图表工具提示的主题
  • 重构导入路径,并在主布局中应用一致的主题
  • 在 localStorage 中持久化和验证 UI 主题,并提供默认的回退方案
Original summary in English

Summary by Sourcery

Trim fixed prefixes from extension names in the plugin marketplace with a toggle for full names, and apply minor UI and theming enhancements across dashboard components.

New Features:

  • Trim plugin name prefixes in the marketplace and add a switch to toggle full name display

Enhancements:

  • Restrict help tooltip width and add an open delay in the marketplace
  • Update scrollbar styling and button icons for extension list entries
  • Adjust chat sidebar and conversation list backgrounds, colors, and spacing
  • Switch chart tooltip theme based on the current UI theme
  • Refactor import paths and apply consistent theming in the main layout
  • Persist and validate UI theme in localStorage with a fallback default

Copy link
Contributor

sourcery-ai bot commented May 30, 2025

## 审查者指南

在 marketplace 视图中实现扩展名称修剪功能,并在多个组件中应用一系列小的 UI、主题和导入路径修复。

#### 用于填充和处理插件市场数据的序列图

```mermaid
sequenceDiagram
    participant ExtensionMarketplaceVue as 组件
    participant CommonStoreService as 数据服务
    participant PluginMarketDataArray as "Component.pluginMarketData"

    ExtensionMarketplaceVue->>DataService: getPluginCollections()
    activate DataService
    DataService-->>ExtensionMarketplaceVue: rawPluginData
    deactivate DataService
    ExtensionMarketplaceVue->>ExtensionMarketplaceVue: this.pluginMarketData = rawPluginData
    ExtensionMarketplaceVue->>PluginMarketDataArray: 调用 trimExtensionName()
    activate PluginMarketDataArray
    loop 对于 pluginMarketData 中的每个插件
        PluginMarketDataArray->>PluginMarketDataArray: 读取 plugin.name
        PluginMarketDataArray->>PluginMarketDataArray: 应用修剪逻辑(例如,删除 "astrbot_plugin_")
        PluginMarketDataArray->>PluginMarketDataArray: 设置 plugin.trimmedName
    end
    deactivate PluginMarketDataArray
    ExtensionMarketplaceVue->>ExtensionMarketplaceVue: 使用处理后的 pluginMarketData 进行显示(根据 showPluginFullName 有条件地显示 name 或 trimmedName)

ExtensionMarketplace.vue 组件的更新类图

Loading
classDiagram
    class ExtensionMarketplace {
      <<VueComponent>>
      +showPluginFullName: boolean
      +pluginMarketData: Plugin[]
      +trimExtensionName(): void
      +getPluginMarket(): void
      +getExtensions(): void
    }
    class Plugin {
      <<DataStructure>>
      +name: string
      +trimmedName: string
      +desc: string
      +author: string
      +stars: number
      +updated_at: string
      +tags: string[]
      +repo: string
      +logo: string
      +installed: boolean
    }
    ExtensionMarketplace "1" -- "*" Plugin : uses

MessageStat.vue 组件的更新类图

Loading
classDiagram
    class MessageStat {
        <<VueComponent>>
        +chartOptions: Object
        +fetchData(): void
        +updateChartData(): void
    }
    class CustomizerStore {
        +uiTheme: string
    }
    MessageStat ..> CustomizerStore : uses (for chartOptions.tooltip.theme)

文件级别更改

变更 详情 文件
扩展名称修剪功能
  • 添加 showPluginFullName 标志以控制完整/修剪显示
  • 实现 trimExtensionName() 以从名称前缀派生 trimmedName
  • 在获取插件数据后调用 trimExtensionName()
  • 更新表格单元格模板以在 name 和 trimmedName 之间切换
  • 添加一个开关以切换全名显示
dashboard/src/views/ExtensionMarketplace.vue
marketplace 中的工具提示和 UI 改进
  • 在帮助按钮上设置工具提示最大宽度和打开延迟
  • 将 转换为自闭合形式
  • 调整插件列表中的 overflow-x 样式和滚动条外观
  • 优化空标签占位符并调整标题 maxWidth 值
dashboard/src/views/ExtensionMarketplace.vue
将操作按钮转换为仅图标 UI
  • 将安装/帮助文本按钮替换为图标按钮
  • 使用 mdi-download、mdi-check 和 mdi-help 图标
  • 删除冗余按钮边框并简化点击处理程序
dashboard/src/views/ExtensionMarketplace.vue
跨组件主题、样式和导入修复
  • 修复 FullLayout.vue 中 useCustomizerStore 的导入路径
  • 在 MessageStat 中基于 uiTheme 应用动态工具提示主题
  • 调整 ChatPage 中的背景颜色、边框半径、活动颜色和行高
  • 重构 FullLayout 中的 v-app 属性格式
  • 增强 config.ts 主题持久性逻辑并添加一个 todo 注释
dashboard/src/views/ChatPage.vue
dashboard/src/layouts/full/FullLayout.vue
dashboard/src/views/dashboards/default/components/MessageStat.vue
dashboard/src/config.ts

提示和命令

与 Sourcery 互动

  • 触发新的审查: 在 pull request 上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 通过回复审查评论,要求 Sourcery 从审查评论创建一个 issue。您也可以回复审查评论并使用 @sourcery-ai issue 从中创建一个 issue。
  • 生成 pull request 标题: 在 pull request 标题中的任何位置写入 @sourcery-ai 以随时生成标题。您也可以在 pull request 上评论 @sourcery-ai title 以随时(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文中的任何位置写入 @sourcery-ai summary 以随时在您想要的位置生成 PR 摘要。您也可以在 pull request 上评论 @sourcery-ai summary 以随时(重新)生成摘要。
  • 生成审查者指南: 在 pull request 上评论 @sourcery-ai guide 以随时(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在 pull request 上评论 @sourcery-ai resolve 以解决所有 Sourcery 评论。如果您已经解决了所有评论并且不想再看到它们,这将非常有用。
  • 驳回所有 Sourcery 审查: 在 pull request 上评论 @sourcery-ai dismiss 以驳回所有现有的 Sourcery 审查。如果您想重新开始新的审查,这将特别有用 - 不要忘记评论 @sourcery-ai review 以触发新的审查!

自定义您的体验

访问您的 dashboard 以:

  • 启用或禁用审查功能,例如 Sourcery 生成的 pull request 摘要、审查者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获得帮助

```
Original review guide in English

Reviewer's Guide

Implements an extension name trim feature in the marketplace view and applies a set of minor UI, theming, and import-path fixes across multiple components.

Sequence Diagram for Populating and Processing Plugin Market Data

Loading
sequenceDiagram
    participant ExtensionMarketplaceVue as Component
    participant CommonStoreService as DataService
    participant PluginMarketDataArray as "Component.pluginMarketData"

    ExtensionMarketplaceVue->>DataService: getPluginCollections()
    activate DataService
    DataService-->>ExtensionMarketplaceVue: rawPluginData
    deactivate DataService
    ExtensionMarketplaceVue->>ExtensionMarketplaceVue: this.pluginMarketData = rawPluginData
    ExtensionMarketplaceVue->>PluginMarketDataArray: Calls trimExtensionName()
    activate PluginMarketDataArray
    loop For each plugin in pluginMarketData
        PluginMarketDataArray->>PluginMarketDataArray: Read plugin.name
        PluginMarketDataArray->>PluginMarketDataArray: Apply trimming logic (e.g., remove "astrbot_plugin_")
        PluginMarketDataArray->>PluginMarketDataArray: Set plugin.trimmedName
    end
    deactivate PluginMarketDataArray
    ExtensionMarketplaceVue->>ExtensionMarketplaceVue: Uses processed pluginMarketData for display (conditionally showing name or trimmedName based on showPluginFullName)

Updated Class Diagram for ExtensionMarketplace.vue Component

Loading
classDiagram
    class ExtensionMarketplace {
      <<VueComponent>>
      +showPluginFullName: boolean
      +pluginMarketData: Plugin[]
      +trimExtensionName(): void
      +getPluginMarket(): void
      +getExtensions(): void
    }
    class Plugin {
      <<DataStructure>>
      +name: string
      +trimmedName: string
      +desc: string
      +author: string
      +stars: number
      +updated_at: string
      +tags: string[]
      +repo: string
      +logo: string
      +installed: boolean
    }
    ExtensionMarketplace "1" -- "*" Plugin : uses

Updated Class Diagram for MessageStat.vue Component

Loading
classDiagram
    class MessageStat {
        <<VueComponent>>
        +chartOptions: Object
        +fetchData(): void
        +updateChartData(): void
    }
    class CustomizerStore {
        +uiTheme: string
    }
    MessageStat ..> CustomizerStore : uses (for chartOptions.tooltip.theme)

File-Level Changes

Change Details Files
Extension name trimming feature
  • Add showPluginFullName flag to control full/trimmed display
  • Implement trimExtensionName() to derive trimmedName from name prefixes
  • Invoke trimExtensionName() after fetching plugin data
  • Update table cell template to toggle between name and trimmedName
  • Add a switch to toggle full name display
dashboard/src/views/ExtensionMarketplace.vue
Tooltip and UI refinements in the marketplace
  • Set tooltip max-width and open-delay on help button
  • Convert to self-closing form
  • Adjust overflow-x styling and scrollbar appearance in plugin list
  • Refine empty-tag placeholder and tweak header maxWidth values
dashboard/src/views/ExtensionMarketplace.vue
Convert action buttons to icon-only UI
  • Replace install/help text buttons with icon buttons
  • Use mdi-download, mdi-check, and mdi-help icons
  • Remove redundant button borders and streamline click handlers
dashboard/src/views/ExtensionMarketplace.vue
Cross-component theming, styling, and import fixes
  • Fix import path for useCustomizerStore in FullLayout.vue
  • Apply dynamic tooltip theme in MessageStat based on uiTheme
  • Adjust background colors, border radius, active-color and line-height in ChatPage
  • Refactor v-app attribute formatting in FullLayout
  • Enhance config.ts theme persistence logic and add a todo comment
dashboard/src/views/ChatPage.vue
dashboard/src/layouts/full/FullLayout.vue
dashboard/src/views/dashboards/default/components/MessageStat.vue
dashboard/src/config.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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.

@Kwicxy - 我已经查看了你的更改,它们看起来很棒!

这是我在审查期间查看的内容
  • 🟡 一般问题:发现 6 个问题
  • 🟢 安全性:一切看起来都不错
  • 🟢 测试:一切看起来都不错
  • 🟢 复杂性:一切看起来都不错
  • 🟢 文档:一切看起来都不错

Sourcery 对开源是免费的 - 如果你喜欢我们的评论,请考虑分享它们 ✨
帮助我更有用!请点击每个评论上的 👍 或 👎,我将使用反馈来改进你的评论。
Original comment in English

Hey @Kwicxy - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 6 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

console.log(this.pluginMarketData);
this.pluginMarketData.forEach(plugin => {
if (plugin.name) {
let name = plugin.name.trim().toLowerCase();
Copy link
Contributor

Choose a reason for hiding this comment

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

问题: 将修剪后的插件名称转换为小写会丢失原始大小写

仅使用小写进行前缀检测,然后从原始名称中切片以在 trimmedName 中保留正确的大小写。

Original comment in English

issue: Lowercasing trimmed plugin names loses original casing

Use lowercase only for prefix detection, then slice from the original name to keep the correct casing in trimmedName.

<v-col cols="12" md="12" style="padding: 0px;">
<v-data-table :headers="pluginMarketHeaders" :items="pluginMarketData" item-key="name"
:loading="loading_" v-model:search="marketSearch" :filter-keys="filterKeys">
<template v-slot:item.name="{ item }">
<div class="d-flex align-center" style="overflow-x: scroll;">
<div class="d-flex align-center" style="overflow-x: auto; scrollbar-width: thin; scrollbar-track-color: transparent;">
Copy link
Contributor

Choose a reason for hiding this comment

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

问题: 跨浏览器滚动条样式属性是非标准的

这些属性的浏览器支持有限。为了更广泛的兼容性,请使用带有供应商前缀的伪元素或更通用的解决方案。

Original comment in English

issue: Cross-browser scrollbar styling properties are non-standard

These properties have limited browser support. For broader compatibility, use vendor-prefixed pseudo-elements or a more universal solution.

}}</v-chip>
<span v-if="item.tags.length === 0">-</span>
<v-chip v-for="tag in item.tags" :key="tag" color="primary" size="x-small">
{{ tag }}</v-chip>
</template>
Copy link
Contributor

Choose a reason for hiding this comment

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

问题: 仅包含图标的按钮缺少可访问的标签

请添加一个可访问的标签,例如 aria-labelv-tooltip 或可见文本,以确保屏幕阅读器可以识别按钮的用途。

Original comment in English

issue: Icon-only buttons lack accessible labels

Please add an accessible label, such as an aria-label, v-tooltip, or visible text, to ensure screen readers can identify the button's purpose.

@@ -129,7 +130,7 @@ export default {
}
},
tooltip: {
theme: 'light',
theme: useCustomizerStore().uiTheme==='PurpleTheme' ? 'light' : 'dark',
Copy link
Contributor

Choose a reason for hiding this comment

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

问题(bug 风险): 工具提示主题属性对主题更改无反应

将主题选择逻辑移至计算属性或观察程序中,以确保工具提示在 uiTheme 更改时更新。

Original comment in English

issue (bug_risk): Tooltip theme prop not reactive to theme changes

Move the theme selection logic into a computed property or watcher to ensure the tooltip updates when uiTheme changes.

this.checkAlreadyInstalled();
this.checkUpdate()
});
},

trimExtensionName() {
console.log(this.pluginMarketData);
Copy link
Contributor

Choose a reason for hiding this comment

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

吹毛求疵: 删除剩余的调试 console.log

应删除实用程序方法中的调试日志或使用调试标志进行控制,以避免使生产输出混乱。

Original comment in English

nitpick: Remove leftover debugging console.log

Debug logs in utility methods should be removed or controlled with a debug flag to avoid cluttering production output.

if (!theme || !(['PurpleTheme', 'PurpleThemeDark'].includes(theme))) {
localStorage.setItem("uiTheme", "PurpleTheme");
localStorage.setItem("uiTheme", "PurpleTheme"); // todo: 这部分可以根据vuetify.ts的默认主题动态调整
Copy link
Contributor

Choose a reason for hiding this comment

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

吹毛求疵: 关于动态默认主题的剩余 TODO

请通过实施动态主题检测或在问题中跟踪它来解决此 TODO,然后删除内联注释。

Original comment in English

nitpick: Leftover TODO about dynamic default theme

Please address this TODO by either implementing dynamic theme detection or tracking it in an issue, then remove the inline comment.

Comment on lines 13 to 16
if (!theme || !(['PurpleTheme', 'PurpleThemeDark'].includes(theme))) {
localStorage.setItem("uiTheme", "PurpleTheme");
localStorage.setItem("uiTheme", "PurpleTheme"); // todo: 这部分可以根据vuetify.ts的默认主题动态调整
return 'PurpleTheme';
} else return theme;
Copy link
Contributor

Choose a reason for hiding this comment

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

建议(代码质量): 对 ifs、whiles 等使用块花括号(use-braces

Suggested change
if (!theme || !(['PurpleTheme', 'PurpleThemeDark'].includes(theme))) {
localStorage.setItem("uiTheme", "PurpleTheme");
localStorage.setItem("uiTheme", "PurpleTheme"); // todo: 这部分可以根据vuetify.ts的默认主题动态调整
return 'PurpleTheme';
} else return theme;
if (!theme || !(['PurpleTheme', 'PurpleThemeDark'].includes(theme))) {
localStorage.setItem("uiTheme", "PurpleTheme"); // todo: 这部分可以根据vuetify.ts的默认主题动态调整
return 'PurpleTheme';
} else {
return theme;
}


解释建议始终使用花括号并创建显式语句块。

使用允许的语法仅编写单个语句可能会导致非常混乱的情况,尤其是在随后开发人员可能会添加另一个语句而忘记添加花括号的情况下(这意味着这不会包含在条件中)。

Original comment in English

suggestion (code-quality): Use block braces for ifs, whiles, etc. (use-braces)

Suggested change
if (!theme || !(['PurpleTheme', 'PurpleThemeDark'].includes(theme))) {
localStorage.setItem("uiTheme", "PurpleTheme");
localStorage.setItem("uiTheme", "PurpleTheme"); // todo: 这部分可以根据vuetify.ts的默认主题动态调整
return 'PurpleTheme';
} else return theme;
if (!theme || !(['PurpleTheme', 'PurpleThemeDark'].includes(theme))) {
localStorage.setItem("uiTheme", "PurpleTheme"); // todo: 这部分可以根据vuetify.ts的默认主题动态调整
return 'PurpleTheme';
} else {
return theme;
}


ExplanationIt is recommended to always use braces and create explicit statement blocks.

Using the allowed syntax to just write a single statement can lead to very confusing
situations, especially where subsequently a developer might add another statement
while forgetting to add the braces (meaning that this wouldn't be included in the condition).

@Kwicxy
Copy link
Contributor Author

Kwicxy commented May 30, 2025

记得把暗黑主题的issue close了
如果配色还有问题也可提出

@Kwicxy
Copy link
Contributor Author

Kwicxy commented May 30, 2025

Damn!

怎么没赶上release

@Kwicxy Kwicxy changed the title Chore: Extension name trim feature and minor bug fixes Feat: 显示插件列表时隐藏前缀 May 30, 2025
@Kwicxy Kwicxy changed the title Feat: 显示插件列表时隐藏前缀 Feat: 显示插件列表时可选隐藏前缀 May 31, 2025
@Kwicxy Kwicxy deleted the branch AstrBotDevs:master June 2, 2025 15:50
@Kwicxy Kwicxy closed this Jun 2, 2025
@Kwicxy Kwicxy deleted the master branch June 2, 2025 15:50
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