-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix: plugin name in the marketplace does not match the local plugin #8274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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,19 @@ 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); | ||
|
|
||
| const normalizedExtensionName = normalizeStr(extension.name); | ||
| const onlinePluginByName = onlinePluginsNameMap.get(normalizedExtensionName); | ||
|
Comment on lines
+645
to
+656
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The References
|
||
|
|
||
| const matchedPlugin = onlinePlugin || onlinePluginByName; | ||
|
|
||
| if (matchedPlugin) { | ||
|
|
@@ -1234,9 +1239,7 @@ 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, "-")), | ||
| ); //统一格式,以防下面的匹配不生效 | ||
| const installedNames = new Set(data.map((ext) => normalizeStr(ext.name))); | ||
| const installedByRepo = new Map( | ||
| data | ||
| .filter((ext) => ext.repo) | ||
|
|
@@ -1266,7 +1269,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 +1480,7 @@ export const useExtensionPage = () => { | |
| selectedMarketInstallPlugin.value = null; | ||
| await getExtensions(); | ||
| checkAlreadyInstalled(); | ||
| checkUpdate(); | ||
|
|
||
| viewReadme({ | ||
| name: resData.data.name, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the
namefield from underscores to hyphens in the API response is a breaking change for plugin management. This field acts as the unique identifier for plugins in subsequent API calls such as/api/plugin/uninstall,/api/plugin/on/off, and/api/plugin/update. Since the backend lookup logic (e.g.,get_registered_staror_get_plugin_metadata_by_name) performs a direct string comparison against the internal plugin name (which still uses underscores), these operations will fail for any plugin containing an underscore.Furthermore, this will break plugin pages because
_serve_plugin_page_contentuses this name to look up metadata. It is recommended to keep the originalnameas the identifier and add a separate field for marketplace matching, or update all backend lookup logic to be separator-insensitive. Additionally, refactor the lookup logic into a shared helper function and ensure this new functionality is accompanied by unit tests.References