From 1ddb0caf7332caae6b114f9bd6bf3ffb31efe718 Mon Sep 17 00:00:00 2001 From: kterna <2569244273@qq.com> Date: Tue, 8 Apr 2025 10:47:59 +0800 Subject: [PATCH 1/6] =?UTF-8?q?star=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dashboard/src/views/ExtensionMarketplace.vue | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dashboard/src/views/ExtensionMarketplace.vue b/dashboard/src/views/ExtensionMarketplace.vue index 9e8587a6f..a58bb8e07 100644 --- a/dashboard/src/views/ExtensionMarketplace.vue +++ b/dashboard/src/views/ExtensionMarketplace.vue @@ -89,6 +89,14 @@ import 'highlight.js/styles/github.css'; }} {{ item.author }} + + + 无 + 无 {{ tag @@ -264,6 +272,7 @@ export default { { title: '名称', key: 'name', maxWidth: '150px' }, { title: '描述', key: 'desc', maxWidth: '250px' }, { title: '作者', key: 'author', maxWidth: '60px' }, + { title: 'Star数', key: 'stars', maxWidth: '100px' }, { title: '标签', key: 'tags', maxWidth: '60px' }, { title: '操作', key: 'actions', sortable: false } ], From 3b137ac762cbe62ffb2dd92063459af4f2fe09e1 Mon Sep 17 00:00:00 2001 From: kterna <2569244273@qq.com> Date: Tue, 8 Apr 2025 14:01:14 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=8F=92=E4=BB=B6=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E4=B8=AD=E6=9F=A5=E7=9C=8B=E6=9C=AC=E5=9C=B0=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=9A=84readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/shared/ExtensionCard.vue | 12 +- .../src/components/shared/ReadmeDialog.vue | 302 ++++++++++++++++++ dashboard/src/views/ExtensionPage.vue | 22 +- 3 files changed, 334 insertions(+), 2 deletions(-) create mode 100644 dashboard/src/components/shared/ReadmeDialog.vue diff --git a/dashboard/src/components/shared/ExtensionCard.vue b/dashboard/src/components/shared/ExtensionCard.vue index 18f845646..49cc87b76 100644 --- a/dashboard/src/components/shared/ExtensionCard.vue +++ b/dashboard/src/components/shared/ExtensionCard.vue @@ -24,7 +24,8 @@ const emit = defineEmits([ 'install', 'uninstall', 'toggle-activation', - 'view-handlers' + 'view-handlers', + 'view-readme' ]); const open = (link: string | undefined) => { @@ -70,6 +71,10 @@ const toggleActivation = () => { const viewHandlers = () => { emit('view-handlers', props.extension); }; + +const viewReadme = () => { + emit('view-readme', props.extension); +}; @@ -183,6 +188,11 @@ const viewHandlers = () => { @click="updateExtension" :block="$vuetify.display.xs"> 更新到 {{ extension.online_version || extension.version }} + + + 查看文档 + diff --git a/dashboard/src/components/shared/ReadmeDialog.vue b/dashboard/src/components/shared/ReadmeDialog.vue new file mode 100644 index 000000000..292575291 --- /dev/null +++ b/dashboard/src/components/shared/ReadmeDialog.vue @@ -0,0 +1,302 @@ + + + + + + + 插件说明文档 + + mdi-close + + + + + + + 在GitHub中查看仓库 + + + 刷新文档 + + + + + + + 正在加载README文档... + + + + + + + + mdi-alert-circle-outline + {{ error }} + + + + + mdi-file-question-outline + 该插件未提供文档链接或GitHub仓库地址。请查看插件市场或联系插件作者获取更多信息。 + + + + + + + 关闭 + + + + + + + + + \ No newline at end of file diff --git a/dashboard/src/views/ExtensionPage.vue b/dashboard/src/views/ExtensionPage.vue index 1b1171b1e..33f78dd01 100644 --- a/dashboard/src/views/ExtensionPage.vue +++ b/dashboard/src/views/ExtensionPage.vue @@ -3,6 +3,7 @@ import ExtensionCard from '@/components/shared/ExtensionCard.vue'; import WaitingForRestart from '@/components/shared/WaitingForRestart.vue'; import AstrBotConfig from '@/components/shared/AstrBotConfig.vue'; import ConsoleDisplayer from '@/components/shared/ConsoleDisplayer.vue'; +import ReadmeDialog from '@/components/shared/ReadmeDialog.vue'; import axios from 'axios'; import { useCommonStore } from '@/stores/common'; @@ -35,6 +36,12 @@ const selectedPlugin = ref({}); const curr_namespace = ref(""); const wfr = ref(null); +const readmeDialog = reactive({ + show: false, + pluginName: '', + repoUrl: null +}); + const plugin_handler_info_headers = [ { title: '行为类型', key: 'event_type_h' }, { title: '描述', key: 'desc', maxWidth: '250px' }, @@ -225,6 +232,12 @@ const reloadPlugin = async (plugin_name) => { } }; +const viewReadme = (plugin) => { + readmeDialog.pluginName = plugin.name; + readmeDialog.repoUrl = plugin.repo; + readmeDialog.show = true; +}; + // 生命周期 onMounted(async () => { await getExtensions(); @@ -279,7 +292,8 @@ onMounted(async () => { @update="updateExtension(extension.name)" @reload="reloadPlugin(extension.name)" @toggle-activation="extension.activated ? pluginOff(extension) : pluginOn(extension)" - @view-handlers="showPluginInfo(extension)"> + @view-handlers="showPluginInfo(extension)" + @view-readme="viewReadme(extension)"> @@ -365,4 +379,10 @@ onMounted(async () => { + + \ No newline at end of file From 45ef5811c8892dec7525bfcfd612c31eecb8f535 Mon Sep 17 00:00:00 2001 From: kterna <2569244273@qq.com> Date: Tue, 8 Apr 2025 14:02:59 +0800 Subject: [PATCH 3/6] 1 --- astrbot/dashboard/routes/plugin.py | 72 ++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/astrbot/dashboard/routes/plugin.py b/astrbot/dashboard/routes/plugin.py index e369ad054..0fe918915 100644 --- a/astrbot/dashboard/routes/plugin.py +++ b/astrbot/dashboard/routes/plugin.py @@ -1,5 +1,6 @@ import traceback import aiohttp +import os import ssl import certifi @@ -36,6 +37,7 @@ class PluginRoute(Route): "/plugin/off": ("POST", self.off_plugin), "/plugin/on": ("POST", self.on_plugin), "/plugin/reload": ("POST", self.reload_plugins), + "/plugin/readme": ("GET", self.get_plugin_readme), } self.core_lifecycle = core_lifecycle self.plugin_manager = plugin_manager @@ -317,3 +319,73 @@ class PluginRoute(Route): except Exception as e: logger.error(f"/api/plugin/on: {traceback.format_exc()}") return Response().error(str(e)).__dict__ + + async def get_plugin_readme(self): + """ + 获取插件的README文件内容 + + 请求参数: + - name: 插件名称 + + 返回: + - status: 'ok' 或 'error' + - data: { content: 'README内容' } + - message: 成功或错误信息 + """ + plugin_name = request.args.get("name") + + logger.info(f"正在获取插件 {plugin_name} 的README文件内容") + + if not plugin_name: + logger.warning("插件名称为空") + return Response().error("插件名称不能为空").__dict__ + + # 查找插件 + plugin_found = False + for plugin in self.plugin_manager.context.get_all_stars(): + if plugin.name == plugin_name: + plugin_found = True + break + + if not plugin_found: + logger.warning(f"插件 {plugin_name} 不存在") + return Response().error(f"插件 {plugin_name} 不存在").__dict__ + + # 尝试找到README文件 + readme_content = None + + # 先检查普通插件目录 + plugin_dir = os.path.join(self.plugin_manager.plugin_store_path, plugin_name) + + if not os.path.isdir(plugin_dir): + # 再检查保留插件目录 + plugin_dir = os.path.join(self.plugin_manager.reserved_plugin_path, plugin_name) + + if not os.path.isdir(plugin_dir): + logger.warning(f"无法找到插件目录: {plugin_dir}") + return Response().error(f"无法找到插件 {plugin_name} 的目录").__dict__ + + # 尝试查找README文件(支持多种扩展名和大小写) + readme_filenames = ["README.md", "readme.md", "README.txt", "readme.txt", "README", "readme"] + readme_path = None + + for filename in readme_filenames: + path = os.path.join(plugin_dir, filename) + if os.path.isfile(path): + readme_path = path + break + + # 如果没有找到README文件 + if not readme_path: + logger.warning(f"插件 {plugin_name} 没有README文件") + return Response().error(f"插件 {plugin_name} 没有README文件").__dict__ + + try: + # 读取README文件内容 + with open(readme_path, 'r', encoding='utf-8') as f: + readme_content = f.read() + + return Response().ok({"content": readme_content}, "成功获取README内容").__dict__ + except Exception as e: + logger.error(f"/api/plugin/readme: {traceback.format_exc()}") + return Response().error(f"读取README文件失败: {str(e)}").__dict__ From 59fbd98db39a59242e41902b88941fae650a8af2 Mon Sep 17 00:00:00 2001 From: kterna <2569244273@qq.com> Date: Tue, 8 Apr 2025 14:31:35 +0800 Subject: [PATCH 4/6] 1 --- astrbot/dashboard/routes/plugin.py | 30 ++----------------- .../src/components/shared/ExtensionCard.vue | 11 +------ dashboard/src/views/ExtensionMarketplace.vue | 1 - 3 files changed, 3 insertions(+), 39 deletions(-) diff --git a/astrbot/dashboard/routes/plugin.py b/astrbot/dashboard/routes/plugin.py index 0fe918915..44ebf2990 100644 --- a/astrbot/dashboard/routes/plugin.py +++ b/astrbot/dashboard/routes/plugin.py @@ -321,26 +321,13 @@ class PluginRoute(Route): return Response().error(str(e)).__dict__ async def get_plugin_readme(self): - """ - 获取插件的README文件内容 - - 请求参数: - - name: 插件名称 - - 返回: - - status: 'ok' 或 'error' - - data: { content: 'README内容' } - - message: 成功或错误信息 - """ plugin_name = request.args.get("name") - - logger.info(f"正在获取插件 {plugin_name} 的README文件内容") + logger.debug(f"正在获取插件 {plugin_name} 的README文件内容") if not plugin_name: logger.warning("插件名称为空") return Response().error("插件名称不能为空").__dict__ - # 查找插件 plugin_found = False for plugin in self.plugin_manager.context.get_all_stars(): if plugin.name == plugin_name: @@ -351,37 +338,24 @@ class PluginRoute(Route): logger.warning(f"插件 {plugin_name} 不存在") return Response().error(f"插件 {plugin_name} 不存在").__dict__ - # 尝试找到README文件 readme_content = None - # 先检查普通插件目录 plugin_dir = os.path.join(self.plugin_manager.plugin_store_path, plugin_name) if not os.path.isdir(plugin_dir): - # 再检查保留插件目录 plugin_dir = os.path.join(self.plugin_manager.reserved_plugin_path, plugin_name) if not os.path.isdir(plugin_dir): logger.warning(f"无法找到插件目录: {plugin_dir}") return Response().error(f"无法找到插件 {plugin_name} 的目录").__dict__ - # 尝试查找README文件(支持多种扩展名和大小写) - readme_filenames = ["README.md", "readme.md", "README.txt", "readme.txt", "README", "readme"] - readme_path = None + readme_path = os.path.join(plugin_dir, "README.md") - for filename in readme_filenames: - path = os.path.join(plugin_dir, filename) - if os.path.isfile(path): - readme_path = path - break - - # 如果没有找到README文件 if not readme_path: logger.warning(f"插件 {plugin_name} 没有README文件") return Response().error(f"插件 {plugin_name} 没有README文件").__dict__ try: - # 读取README文件内容 with open(readme_path, 'r', encoding='utf-8') as f: readme_content = f.read() diff --git a/dashboard/src/components/shared/ExtensionCard.vue b/dashboard/src/components/shared/ExtensionCard.vue index 49cc87b76..e6573260c 100644 --- a/dashboard/src/components/shared/ExtensionCard.vue +++ b/dashboard/src/components/shared/ExtensionCard.vue @@ -28,10 +28,6 @@ const emit = defineEmits([ 'view-readme' ]); -const open = (link: string | undefined) => { - window.open(link, '_blank'); -}; - const reveal = ref(false); // 操作函数 @@ -133,7 +129,7 @@ const viewReadme = () => { - + @@ -188,11 +184,6 @@ const viewReadme = () => { @click="updateExtension" :block="$vuetify.display.xs"> 更新到 {{ extension.online_version || extension.version }} - - - 查看文档 - diff --git a/dashboard/src/views/ExtensionMarketplace.vue b/dashboard/src/views/ExtensionMarketplace.vue index bbd41db0d..f8c14c540 100644 --- a/dashboard/src/views/ExtensionMarketplace.vue +++ b/dashboard/src/views/ExtensionMarketplace.vue @@ -94,7 +94,6 @@ import 'highlight.js/styles/github.css'; :alt="`Stars for ${item.name}`" style="height: 20px;" /> - 无 无 From 68885a4bbcd06150d11d2b95cd777ccbde704205 Mon Sep 17 00:00:00 2001 From: kterna <2569244273@qq.com> Date: Tue, 8 Apr 2025 16:30:36 +0800 Subject: [PATCH 5/6] Update astrbot/dashboard/routes/plugin.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- astrbot/dashboard/routes/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astrbot/dashboard/routes/plugin.py b/astrbot/dashboard/routes/plugin.py index 44ebf2990..277ae78fe 100644 --- a/astrbot/dashboard/routes/plugin.py +++ b/astrbot/dashboard/routes/plugin.py @@ -351,7 +351,7 @@ class PluginRoute(Route): readme_path = os.path.join(plugin_dir, "README.md") - if not readme_path: + if not os.path.isfile(readme_path): logger.warning(f"插件 {plugin_name} 没有README文件") return Response().error(f"插件 {plugin_name} 没有README文件").__dict__ From 062d482917430078ee8c09df0573f0850e3471cb Mon Sep 17 00:00:00 2001 From: kterna <2569244273@qq.com> Date: Wed, 9 Apr 2025 08:43:16 +0800 Subject: [PATCH 6/6] fix --- astrbot/dashboard/routes/plugin.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/astrbot/dashboard/routes/plugin.py b/astrbot/dashboard/routes/plugin.py index 277ae78fe..81d9b0bfe 100644 --- a/astrbot/dashboard/routes/plugin.py +++ b/astrbot/dashboard/routes/plugin.py @@ -328,26 +328,21 @@ class PluginRoute(Route): logger.warning("插件名称为空") return Response().error("插件名称不能为空").__dict__ - plugin_found = False + plugin_obj = None for plugin in self.plugin_manager.context.get_all_stars(): if plugin.name == plugin_name: - plugin_found = True + plugin_obj = plugin break - if not plugin_found: + if not plugin_obj: logger.warning(f"插件 {plugin_name} 不存在") return Response().error(f"插件 {plugin_name} 不存在").__dict__ - readme_content = None - - plugin_dir = os.path.join(self.plugin_manager.plugin_store_path, plugin_name) + plugin_dir = os.path.join(self.plugin_manager.plugin_store_path, plugin_obj.root_dir_name) if not os.path.isdir(plugin_dir): - plugin_dir = os.path.join(self.plugin_manager.reserved_plugin_path, plugin_name) - - if not os.path.isdir(plugin_dir): - logger.warning(f"无法找到插件目录: {plugin_dir}") - return Response().error(f"无法找到插件 {plugin_name} 的目录").__dict__ + logger.warning(f"无法找到插件目录: {plugin_dir}") + return Response().error(f"无法找到插件 {plugin_name} 的目录").__dict__ readme_path = os.path.join(plugin_dir, "README.md")
正在加载README文档...
{{ error }}
该插件未提供文档链接或GitHub仓库地址。请查看插件市场或联系插件作者获取更多信息。