From 3c0bd38aeba2d14ded753fef311498191ada2e78 Mon Sep 17 00:00:00 2001 From: unknown <2916963017@qq.com> Date: Thu, 21 May 2026 22:17:32 +0800 Subject: [PATCH 1/6] fix: plugin name in the marketplace does not match the local plugin --- astrbot/dashboard/routes/plugin.py | 9 ++++++++ .../src/views/extension/useExtensionPage.js | 23 ++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/astrbot/dashboard/routes/plugin.py b/astrbot/dashboard/routes/plugin.py index 10d87eabea..336d38d2e7 100644 --- a/astrbot/dashboard/routes/plugin.py +++ b/astrbot/dashboard/routes/plugin.py @@ -1270,6 +1270,9 @@ async def get_plugins(self): logo_url = await self.get_plugin_logo_token(plugin.logo_path) _t = { "name": plugin.name, + "marketplace_name": plugin.name.replace( + "_", "-" + ), # 用于市场匹配的名称(减号格式) "repo": "" if plugin.repo is None else plugin.repo, "author": plugin.author, "desc": plugin.desc, @@ -1320,6 +1323,9 @@ async def get_plugin_detail(self): .ok( { "name": plugin.name, + "marketplace_name": plugin.name.replace( + "_", "-" + ), # 用于市场匹配的名称(减号格式) "repo": "" if plugin.repo is None else plugin.repo, "author": plugin.author, "desc": plugin.desc, @@ -1372,6 +1378,9 @@ async def get_plugin_page_components(self, plugin) -> list[dict]: "i18n_key": page["i18n_key"], "description": "Plugin Page entry", "plugin_name": plugin.name, + "plugin_marketplace_name": plugin.name.replace( + "_", "-" + ), # 用于市场匹配的名称(减号格式) } for page in pages ] diff --git a/dashboard/src/views/extension/useExtensionPage.js b/dashboard/src/views/extension/useExtensionPage.js index e23716acdc..ebe1ebb718 100644 --- a/dashboard/src/views/extension/useExtensionPage.js +++ b/dashboard/src/views/extension/useExtensionPage.js @@ -484,7 +484,7 @@ export const useExtensionPage = () => { const failRes = await axios.get("/api/plugin/source/get-failed-plugins"); failedPluginsDict.value = failRes.data.data || {}; - checkUpdate(); + // checkUpdate() is called after pluginMarketData is loaded in onMounted } catch (err) { toast(err, "error"); } finally { @@ -642,14 +642,20 @@ export const useExtensionPage = () => { if (plugin.repo) { onlinePluginsMap.set(plugin.repo.toLowerCase(), plugin); } - onlinePluginsNameMap.set(plugin.name, plugin); + const normalizedName = normalizeStr(plugin.name); + onlinePluginsNameMap.set(normalizedName, plugin); }); const data = Array.isArray(extension_data?.data) ? extension_data.data : []; + data.forEach((extension) => { const repoKey = extension.repo?.toLowerCase(); const onlinePlugin = repoKey ? onlinePluginsMap.get(repoKey) : null; - const onlinePluginByName = onlinePluginsNameMap.get(extension.name); + + // 使用 marketplace_name 进行市场匹配(已统一为减号格式) + const normalizedExtensionName = normalizeStr(extension.marketplace_name || extension.name); + const onlinePluginByName = onlinePluginsNameMap.get(normalizedExtensionName); + const matchedPlugin = onlinePlugin || onlinePluginByName; if (matchedPlugin) { @@ -1234,15 +1240,15 @@ export const useExtensionPage = () => { const checkAlreadyInstalled = () => { const data = Array.isArray(extension_data?.data) ? extension_data.data : []; const installedRepos = new Set(data.map((ext) => ext.repo?.toLowerCase())); - const installedNames = new Set( - data.map((ext) => normalizeStr(ext.name).replace(/_/g, "-")), - ); //统一格式,以防下面的匹配不生效 + // 使用 marketplace_name 进行市场匹配(已统一为减号格式) + const installedNames = new Set(data.map((ext) => normalizeStr(ext.marketplace_name || ext.name))); const installedByRepo = new Map( data .filter((ext) => ext.repo) .map((ext) => [ext.repo.toLowerCase(), ext]), ); - const installedByName = new Map(data.map((ext) => [ext.name, ext])); + // 使用 marketplace_name 创建映射,用于市场匹配 + const installedByName = new Map(data.map((ext) => [ext.marketplace_name || ext.name, ext])); for (let i = 0; i < pluginMarketData.value.length; i++) { const plugin = pluginMarketData.value[i]; @@ -1266,7 +1272,7 @@ export const useExtensionPage = () => { plugin.installed = installedRepos.has(plugin.repo?.toLowerCase()) || - installedNames.has(normalizeStr(plugin.name).replace(/_/g, "-")); //统一格式,防止匹配失败 + installedNames.has(normalizeStr(plugin.name)); } let installed = []; @@ -1477,6 +1483,7 @@ export const useExtensionPage = () => { selectedMarketInstallPlugin.value = null; await getExtensions(); checkAlreadyInstalled(); + checkUpdate(); viewReadme({ name: resData.data.name, From 605c12466ea981d4cffa326f12cb4f55fd200a55 Mon Sep 17 00:00:00 2001 From: unknown <2916963017@qq.com> Date: Thu, 21 May 2026 22:25:24 +0800 Subject: [PATCH 2/6] chore: update test --- tests/test_dashboard.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_dashboard.py b/tests/test_dashboard.py index 86bdf455ef..36f4c52d11 100644 --- a/tests/test_dashboard.py +++ b/tests/test_dashboard.py @@ -887,6 +887,7 @@ async def test_plugin_detail_includes_scanned_page_component( "i18n_key": f"pages.{PLUGIN_PAGE_DEMO_PAGE_NAME}", "description": "Plugin Page entry", "plugin_name": PLUGIN_PAGE_DEMO_NAME, + "plugin_marketplace_name": PLUGIN_PAGE_DEMO_NAME.replace("_", "-"), } ] From 22b792ddceea8cd80d467354a160e071bdf0a688 Mon Sep 17 00:00:00 2001 From: Waterwzy <2916963017@qq.com> Date: Thu, 21 May 2026 22:26:11 +0800 Subject: [PATCH 3/6] Update astrbot/dashboard/routes/plugin.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- astrbot/dashboard/routes/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/astrbot/dashboard/routes/plugin.py b/astrbot/dashboard/routes/plugin.py index 336d38d2e7..c0358bd962 100644 --- a/astrbot/dashboard/routes/plugin.py +++ b/astrbot/dashboard/routes/plugin.py @@ -1270,9 +1270,9 @@ async def get_plugins(self): logo_url = await self.get_plugin_logo_token(plugin.logo_path) _t = { "name": plugin.name, - "marketplace_name": plugin.name.replace( + "marketplace_name": (plugin.name or "").replace( "_", "-" - ), # 用于市场匹配的名称(减号格式) + ), "repo": "" if plugin.repo is None else plugin.repo, "author": plugin.author, "desc": plugin.desc, From 0e5922ca12f2bc9c47760ecd64f6e390a3b7b938 Mon Sep 17 00:00:00 2001 From: Waterwzy <2916963017@qq.com> Date: Thu, 21 May 2026 22:26:48 +0800 Subject: [PATCH 4/6] Update astrbot/dashboard/routes/plugin.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- astrbot/dashboard/routes/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/astrbot/dashboard/routes/plugin.py b/astrbot/dashboard/routes/plugin.py index c0358bd962..c6a88e46f2 100644 --- a/astrbot/dashboard/routes/plugin.py +++ b/astrbot/dashboard/routes/plugin.py @@ -1378,9 +1378,9 @@ async def get_plugin_page_components(self, plugin) -> list[dict]: "i18n_key": page["i18n_key"], "description": "Plugin Page entry", "plugin_name": plugin.name, - "plugin_marketplace_name": plugin.name.replace( + "plugin_marketplace_name": (plugin.name or "").replace( "_", "-" - ), # 用于市场匹配的名称(减号格式) + ), } for page in pages ] From 711be1168c9d4275565ca8b610aabb1045714322 Mon Sep 17 00:00:00 2001 From: Waterwzy <2916963017@qq.com> Date: Thu, 21 May 2026 22:27:04 +0800 Subject: [PATCH 5/6] Update astrbot/dashboard/routes/plugin.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- astrbot/dashboard/routes/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/astrbot/dashboard/routes/plugin.py b/astrbot/dashboard/routes/plugin.py index c6a88e46f2..9cfb008c01 100644 --- a/astrbot/dashboard/routes/plugin.py +++ b/astrbot/dashboard/routes/plugin.py @@ -1323,9 +1323,9 @@ async def get_plugin_detail(self): .ok( { "name": plugin.name, - "marketplace_name": plugin.name.replace( + "marketplace_name": (plugin.name or "").replace( "_", "-" - ), # 用于市场匹配的名称(减号格式) + ), "repo": "" if plugin.repo is None else plugin.repo, "author": plugin.author, "desc": plugin.desc, From 55e2a538d198b575835b2ee83868eca88a0f470c Mon Sep 17 00:00:00 2001 From: unknown <2916963017@qq.com> Date: Thu, 21 May 2026 22:32:31 +0800 Subject: [PATCH 6/6] chore: reformat code --- astrbot/dashboard/routes/plugin.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/astrbot/dashboard/routes/plugin.py b/astrbot/dashboard/routes/plugin.py index 9cfb008c01..9486a20499 100644 --- a/astrbot/dashboard/routes/plugin.py +++ b/astrbot/dashboard/routes/plugin.py @@ -1270,9 +1270,7 @@ async def get_plugins(self): logo_url = await self.get_plugin_logo_token(plugin.logo_path) _t = { "name": plugin.name, - "marketplace_name": (plugin.name or "").replace( - "_", "-" - ), + "marketplace_name": (plugin.name or "").replace("_", "-"), "repo": "" if plugin.repo is None else plugin.repo, "author": plugin.author, "desc": plugin.desc, @@ -1323,9 +1321,7 @@ async def get_plugin_detail(self): .ok( { "name": plugin.name, - "marketplace_name": (plugin.name or "").replace( - "_", "-" - ), + "marketplace_name": (plugin.name or "").replace("_", "-"), "repo": "" if plugin.repo is None else plugin.repo, "author": plugin.author, "desc": plugin.desc, @@ -1378,9 +1374,7 @@ async def get_plugin_page_components(self, plugin) -> list[dict]: "i18n_key": page["i18n_key"], "description": "Plugin Page entry", "plugin_name": plugin.name, - "plugin_marketplace_name": (plugin.name or "").replace( - "_", "-" - ), + "plugin_marketplace_name": (plugin.name or "").replace("_", "-"), } for page in pages ]