Compare commits

...

1 Commits

Author SHA1 Message Date
Soulter
5360c3b106 feat: add short description support for plugin
short description will be displayed in the plugin card
2026-05-01 13:48:38 +08:00
12 changed files with 59 additions and 5 deletions

View File

@@ -27,6 +27,8 @@ class StarMetadata:
"""插件作者"""
desc: str | None = None
"""插件简介"""
short_desc: str | None = None
"""插件短简介"""
version: str | None = None
"""插件版本"""
repo: str | None = None

View File

@@ -497,6 +497,11 @@ class PluginManager:
name=metadata["name"],
author=metadata["author"],
desc=metadata["desc"],
short_desc=(
metadata["short_desc"]
if isinstance(metadata.get("short_desc"), str)
else None
),
version=metadata["version"],
repo=metadata["repo"] if "repo" in metadata else None,
display_name=metadata.get("display_name", None),
@@ -736,6 +741,7 @@ class PluginManager:
"name": metadata.name,
"author": metadata.author,
"desc": metadata.desc,
"short_desc": metadata.short_desc,
"version": metadata.version,
"repo": metadata.repo,
"display_name": metadata.display_name,
@@ -977,6 +983,7 @@ class PluginManager:
metadata.name = metadata_yaml.name
metadata.author = metadata_yaml.author
metadata.desc = metadata_yaml.desc
metadata.short_desc = metadata_yaml.short_desc
metadata.version = metadata_yaml.version
metadata.repo = metadata_yaml.repo
metadata.display_name = metadata_yaml.display_name

View File

@@ -2,8 +2,10 @@
import { computed } from "vue";
import { useModuleI18n } from "@/i18n/composables";
import PluginPlatformChip from "@/components/shared/PluginPlatformChip.vue";
import { usePluginI18n } from "@/utils/pluginI18n";
const { tm } = useModuleI18n("features/extension");
const { pluginShortDesc } = usePluginI18n();
const props = defineProps({
plugin: {
@@ -31,6 +33,10 @@ const platformDisplayList = computed(() =>
normalizePlatformList(props.plugin?.support_platforms),
);
const cardDescription = computed(() =>
pluginShortDesc(props.plugin, props.plugin?.short_desc || props.plugin?.desc || ""),
);
const handleInstall = (plugin) => {
emit("install", plugin);
};
@@ -141,7 +147,7 @@ const handleOpen = () => {
</div>
<div class="text-caption plugin-description">
{{ plugin.desc }}
{{ cardDescription }}
</div>
<div class="plugin-stats"></div>

View File

@@ -166,6 +166,7 @@ export const useCommonStore = defineStore("common", {
...pluginData,
"name": pluginData.name || key, // 优先使用插件数据中的name字段否则使用键名
"desc": pluginData.desc,
"short_desc": pluginData?.short_desc ? pluginData.short_desc : "",
"author": pluginData.author,
"repo": pluginData.repo,
"installed": false,

View File

@@ -45,6 +45,14 @@ export function usePluginI18n() {
)
}
const pluginShortDesc = (plugin, fallback = '') => {
return resolve(
plugin?.i18n,
'metadata.short_desc',
fallback || plugin?.short_desc || plugin?.desc || plugin?.description || '',
)
}
const configText = (i18n, path, attr, fallback = '') => {
const key = path ? `config.${path}.${attr}` : `config.${attr}`
return resolve(i18n, key, fallback)
@@ -55,6 +63,7 @@ export function usePluginI18n() {
resolve,
pluginName,
pluginDesc,
pluginShortDesc,
configText,
}
}

View File

@@ -83,6 +83,7 @@ export const getPluginSearchFields = (plugin) => {
plugin?.name,
plugin?.trimmedName,
plugin?.display_name,
plugin?.short_desc,
plugin?.desc,
plugin?.author,
plugin?.repo,

View File

@@ -18,17 +18,18 @@ Locale file names use WebUI locales, such as `zh-CN.json` and `en-US.json`. Each
When the current locale has no translation, a field is missing, or the locale file does not exist, AstrBot falls back to the default text:
- Plugin names and descriptions fall back to `display_name` and `desc` in `metadata.yaml`.
- Plugin names, card short descriptions, and descriptions fall back to `display_name`, `short_desc`, and `desc` in `metadata.yaml`.
- Configuration text falls back to `description`, `hint`, and `labels` in `_conf_schema.json`.
## Metadata
`metadata` overrides the plugin name and description shown on plugin pages.
`metadata` overrides the plugin name, card short description, and description shown on plugin pages.
```json
{
"metadata": {
"display_name": "Weather Assistant",
"short_desc": "One-line weather lookup.",
"desc": "Query weather and provide travel suggestions."
}
}

View File

@@ -53,6 +53,14 @@ You can modify (or add) the `display_name` field in the `metadata.yaml` file to
Plugin display names and descriptions can follow the WebUI language. See [Plugin Internationalization](./guides/plugin-i18n).
### Plugin Short Description (Optional)
You can add a `short_desc` field to `metadata.yaml` as the short description shown on plugin marketplace cards. Keep it to a concise one-sentence summary. If it is not provided, cards fall back to `desc`.
```yaml
short_desc: A one-line summary of your plugin.
```
### Declare Supported Platforms (Optional)
You can add a `support_platforms` field (`list[str]`) to `metadata.yaml` to declare which platform adapters your plugin supports. The WebUI plugin page will display this field.

View File

@@ -18,17 +18,18 @@ your_plugin/
当当前语言没有对应翻译、某个字段缺失或语言文件不存在时AstrBot 会回退到默认文案:
- 插件名称和描述回退到 `metadata.yaml` 中的 `display_name``desc`
- 插件名称、卡片短描述和描述回退到 `metadata.yaml` 中的 `display_name``short_desc``desc`
- 配置项文案回退到 `_conf_schema.json` 中的 `description``hint``labels`
## 元数据
`metadata` 用于覆盖插件在插件页展示的名称和描述。
`metadata` 用于覆盖插件在插件页展示的名称、卡片短描述和描述。
```json
{
"metadata": {
"display_name": "天气助手",
"short_desc": "一句话天气查询。",
"desc": "查询天气并提供出行建议。"
}
}

View File

@@ -55,6 +55,14 @@ git clone 插件仓库地址
插件展示名和描述支持按 WebUI 语言显示,详见[插件国际化](./guides/plugin-i18n)。
### 插件短描述(可选)
你可以在 `metadata.yaml` 中新增 `short_desc` 字段,作为插件市场卡片上的短描述。它适合写成一句简短介绍;如果没有提供,卡片会回退显示 `desc`
```yaml
short_desc: 一句话介绍你的插件。
```
### 声明支持平台Optional
你可以在 `metadata.yaml` 中新增 `support_platforms` 字段(`list[str]`声明插件支持的平台适配器。WebUI 插件页会展示该字段。

View File

@@ -226,6 +226,14 @@ async def on_message(self, event: AstrMessageEvent):
你可以修改(或添加) `metadata.yaml` 文件中的 `display_name` 字段,作为插件在插件市场等场景中的展示名,以方便用户阅读。
### 插件短描述
你可以在 `metadata.yaml` 中新增 `short_desc` 字段,作为插件市场卡片上的短描述。它适合写成一句简短介绍;如果没有提供,卡片会回退显示 `desc`。
```yaml
short_desc: 一句话介绍你的插件。
```
### 声明支持平台Optional
你可以在 `metadata.yaml` 中新增 `support_platforms` 字段(`list[str]`声明插件支持的平台适配器。WebUI 插件页会展示该字段。

View File

@@ -37,6 +37,7 @@ def _write_local_test_plugin(plugin_path: Path, repo_url: str):
"version": "1.0.0",
"author": "AstrBot Team",
"desc": "Local test plugin",
"short_desc": "Local test short description",
}
with open(plugin_path / "metadata.yaml", "w", encoding="utf-8") as f:
yaml.dump(metadata, f)
@@ -104,6 +105,7 @@ def test_load_plugin_metadata_includes_i18n(tmp_path: Path):
metadata = PluginManager._load_plugin_metadata(str(plugin_path))
assert metadata is not None
assert metadata.short_desc == "Local test short description"
assert metadata.i18n == {"zh-CN": {"metadata": {"display_name": "你好世界"}}}