From e4883241d985ce789448d42fa0f05e58b027d87c Mon Sep 17 00:00:00 2001 From: quirrel-zh Date: Fri, 28 Feb 2025 15:58:57 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9Bfixed=EF=BC=9A=20=091=E3=80=81?= =?UTF-8?q?=E7=94=B1=E4=BA=8Etooltip=E7=A7=BB=E5=85=A5=E6=97=B6=E4=BC=9A?= =?UTF-8?q?=E6=B6=88=E5=A4=B1=E6=97=A0=E6=B3=95=E7=82=B9=E5=87=BB=E5=85=B6?= =?UTF-8?q?=E4=B8=AD=E9=93=BE=E6=8E=A5=EF=BC=8C=E6=9B=B4=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E5=87=BA=E5=8F=91=20=092=E3=80=81=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=BA=86=E7=94=B1=E4=BA=8E=E5=B7=B2=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=8E=E6=8F=92=E4=BB=B6=E5=B8=82=E5=9C=BA?= =?UTF-8?q?=E4=B8=ADname=E4=B8=8D=E4=B8=80=E8=87=B4=E6=88=96repo=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E5=A4=A7=E5=B0=8F=E5=86=99=E4=B8=8D=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E6=A3=80=E6=B5=8B=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=AE=89=E8=A3=85=E6=88=96=E6=9C=89=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dashboard/src/views/ExtensionPage.vue | 66 +++++++++++++++++---------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/dashboard/src/views/ExtensionPage.vue b/dashboard/src/views/ExtensionPage.vue index 032367b5c..3cb15b11e 100644 --- a/dashboard/src/views/ExtensionPage.vue +++ b/dashboard/src/views/ExtensionPage.vue @@ -94,12 +94,15 @@ import { max } from 'date-fns'; 🧩 插件市场 - + mdi-help - 如无法显示,请打开 链接 复制想安装插件对应的 + + 如无法显示,请单击此按钮跳转至插件市场,复制想安装插件对应的 `repo` 链接然后点击右下角 + 号安装,或打开链接下载压缩包安装。 + + @@ -390,6 +393,9 @@ export default { }); }, methods: { + jumpToPluginMarket() { + window.open('https://soulter.github.io/AstrBot_Plugins_Collection/plugins.json', '_blank'); + }, toast(message, success) { this.snack_message = message; this.snack_show = true; @@ -422,21 +428,34 @@ export default { }, checkUpdate() { - // 遍历 extension_data 和 pluginMarketData,检查是否有更新\ - for (let i = 0; i < this.extension_data.data.length; i++) { - for (let j = 0; j < this.pluginMarketData.length; j++) { - console.log(this.extension_data.data[i].repo, this.pluginMarketData[j].repo); - if (this.extension_data.data[i].repo === this.pluginMarketData[j].repo || - this.extension_data.data[i].name === this.pluginMarketData[j].name) { - this.extension_data.data[i].online_version = this.pluginMarketData[j].version; - if (this.extension_data.data[i].version !== this.pluginMarketData[j].version && this.pluginMarketData[j].version !== "未知") { - this.extension_data.data[i].has_update = true; - } else { - this.extension_data.data[i].has_update = false; - } - } + // 创建在线插件的map + const onlinePluginsMap = new Map(); + const onlinePluginsNameMap = new Map(); + + // 将在线插件信息存储到map中 + this.pluginMarketData.forEach(plugin => { + if (plugin.repo) { + onlinePluginsMap.set(plugin.repo.toLowerCase(), plugin); } - } + onlinePluginsNameMap.set(plugin.name, plugin); + }); + + // 遍历本地插件列表 + this.extension_data.data.forEach(extension => { + // 通过repo或name查找在线版本 + const repoKey = extension.repo?.toLowerCase(); + const onlinePlugin = repoKey ? onlinePluginsMap.get(repoKey) : null; + const onlinePluginByName = onlinePluginsNameMap.get(extension.name); + const matchedPlugin = onlinePlugin || onlinePluginByName; + + if (matchedPlugin) { + extension.online_version = matchedPlugin.version; + extension.has_update = extension.version !== matchedPlugin.version && + matchedPlugin.version !== "未知"; + } else { + extension.has_update = false; + } + }); }, newExtension() { @@ -613,15 +632,14 @@ export default { }); }, checkAlreadyInstalled() { + // 创建已安装插件的仓库和名称集合 统一格式 + const installedRepos = new Set(this.extension_data.data.map(ext => ext.repo?.toLowerCase())); + const installedNames = new Set(this.extension_data.data.map(ext => ext.name)); + + // 遍历检查安装状态 for (let i = 0; i < this.pluginMarketData.length; i++) { - this.pluginMarketData[i].installed = false; - } - for (let i = 0; i < this.pluginMarketData.length; i++) { - for (let j = 0; j < this.extension_data.data.length; j++) { - if (this.pluginMarketData[i].repo === this.extension_data.data[j].repo || this.pluginMarketData[i].name === this.extension_data.data[j].name) { - this.pluginMarketData[i].installed = true; - } - } + const plugin = this.pluginMarketData[i]; + plugin.installed = installedRepos.has(plugin.repo?.toLowerCase()) || installedNames.has(plugin.name); } // 将已安装的插件移动到最后面