mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-01 01:10:21 +08:00
fix: prevent plugin detail marketplace mismatches (#9028)
This commit is contained in:
@@ -181,16 +181,30 @@ const selectedInstalledPlugin = computed(() => {
|
||||
return data.find((plugin) => plugin.name === selectedPluginId.value) || null;
|
||||
});
|
||||
|
||||
const normalizeRepoUrl = (value) =>
|
||||
String(value || "")
|
||||
.trim()
|
||||
.replace(/\/+$/, "")
|
||||
.toLowerCase()
|
||||
.replace(/\.git$/, "");
|
||||
|
||||
const selectedMarketPlugin = computed(() => {
|
||||
const market = Array.isArray(pluginMarketData.value)
|
||||
? pluginMarketData.value
|
||||
: [];
|
||||
const installedPlugin = selectedInstalledPlugin.value;
|
||||
const repo = installedPlugin?.repo?.toLowerCase();
|
||||
const marketNameMatch =
|
||||
market.find((item) => item.name === selectedPluginId.value) || null;
|
||||
|
||||
if (selectedDetailTab.value === "market" || !installedPlugin) {
|
||||
return marketNameMatch;
|
||||
}
|
||||
|
||||
const repo = normalizeRepoUrl(installedPlugin.repo);
|
||||
if (!repo) return null;
|
||||
|
||||
return (
|
||||
market.find((item) => item.name === selectedPluginId.value) ||
|
||||
market.find((item) => repo && item.repo?.toLowerCase() === repo) ||
|
||||
null
|
||||
market.find((item) => normalizeRepoUrl(item?.repo) === repo) || null
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user