From c7419e719644fa7ea7fa459de0080c81c98ff6e0 Mon Sep 17 00:00:00 2001 From: cosimawei <87409893+cosimawei@users.noreply.github.com> Date: Sat, 5 Dec 2026 19:40:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8F=92=E4=BB=B6=E5=B8=82=E5=9C=BA?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E5=AE=89=E8=A3=85=E6=8E=A8=E8=8D=90=E7=89=88?= =?UTF-8?q?=E6=9C=AC=EF=BC=88#195=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changes/market-install-latest.json | 7 ++ frontend/src/components/PluginMarket.tsx | 115 +---------------------- frontend/src/i18n/domains/plugins.gen.ts | 6 -- frontend/src/i18n/keys.gen.ts | 3 - frontend/src/styles/app.css | 20 ---- locales/en-US/plugins.json | 3 - locales/zh-CN/plugins.json | 3 - 7 files changed, 12 insertions(+), 145 deletions(-) create mode 100644 changes/market-install-latest.json diff --git a/changes/market-install-latest.json b/changes/market-install-latest.json new file mode 100644 index 0000000..2836951 --- /dev/null +++ b/changes/market-install-latest.json @@ -0,0 +1,7 @@ +{ + "group": "improvements", + "order": 0, + "authors": ["cosimawei"], + "zh": "在插件市场点击安装或更新时直接使用市场推荐的最新版本。", + "en": "Install or update directly to the latest version offered by the plugin market." +} diff --git a/frontend/src/components/PluginMarket.tsx b/frontend/src/components/PluginMarket.tsx index bacd31e..e367443 100644 --- a/frontend/src/components/PluginMarket.tsx +++ b/frontend/src/components/PluginMarket.tsx @@ -34,20 +34,6 @@ function formatCompactCount(n: number): string { return String(n) } -function formatByteSize(bytes?: number): string { - if (!bytes || bytes <= 0) return '' - if (bytes >= 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB` - if (bytes >= 1024) return `${Math.max(1, Math.round(bytes / 1024))} KB` - return `${bytes} B` -} - -function formatShortDate(iso?: string): string { - if (!iso) return '' - const ms = Date.parse(iso) - if (Number.isNaN(ms)) return '' - return new Date(ms).toISOString().slice(0, 10) -} - function parseTimestamp(iso?: string): number { if (!iso) return 0 const ms = Date.parse(iso) @@ -62,20 +48,6 @@ function compositeScore(item: MarketCatalogItem, nowMs: number): number { return recency + downloads } -function entryReleases(item: MarketCatalogItem) { - const e = item.entry - if (e.releases && e.releases.length > 0) return e.releases - return [{ - version: e.version, - channel: e.channel || 'stable', - download_url: e.download_url, - sha256: e.sha256, - size_bytes: e.size_bytes, - published_at: e.updated_at, - changelog: e.changelog, - }] -} - interface Props { locale: Locale safeMode?: boolean @@ -102,7 +74,6 @@ export const PluginMarket: React.FC = ({ const [query, setQuery] = useState('') const [kind, setKind] = useState('') const [sortBy, setSortBy] = useState('composite') - const [versionPick, setVersionPick] = useState<{ item: MarketCatalogItem; selected: string } | null>(null) const [result, setResult] = useState(null) const [syncing, setSyncing] = useState(false) const [refreshing, setRefreshing] = useState(false) @@ -277,22 +248,13 @@ export const PluginMarket: React.FC = ({ advancePrompt() } - const openVersionPicker = (item: MarketCatalogItem) => { - const list = entryReleases(item) - const defaultVer = list.find((r) => r.version === item.entry.version)?.version ?? list[0]?.version ?? item.entry.version - setVersionPick({ item, selected: defaultVer }) - } - - const install = async (item: MarketCatalogItem, version?: string) => { + const install = async (item: MarketCatalogItem) => { const id = item.entry.id if (installingRef.current.has(id)) return installingRef.current.add(id) - const rel = entryReleases(item).find((r) => r.version === version) - setProgress((prev) => ({ ...prev, [id]: { id, phase: 'download', done: 0, total: rel?.size_bytes ?? item.entry.size_bytes ?? 0 } })) + setProgress((prev) => ({ ...prev, [id]: { id, phase: 'download', done: 0, total: item.entry.size_bytes ?? 0 } })) try { - const info = version - ? await api.InstallMarketPluginVersion(id, version) - : await api.InstallMarketPlugin(id, true) + const info = await api.InstallMarketPluginVersion(id, item.entry.version) await onChanged({}) if (info && !info.enabled) { if (promptTargetIDRef.current) { @@ -372,7 +334,7 @@ export const PluginMarket: React.FC = ({ return ( - @@ -380,7 +342,7 @@ export const PluginMarket: React.FC = ({ ) } return ( - ) @@ -536,73 +498,6 @@ export const PluginMarket: React.FC = ({ )} - {versionPick && ( - setVersionPick(null)} - > -
-
- {entryReleases(versionPick.item).map((rel) => { - const selected = versionPick.selected === rel.version - const isCurrent = versionPick.item.installed && versionPick.item.installed_version === rel.version - const notes = locText(rel.changelog, locale, '') - const date = formatShortDate(rel.published_at) - const size = formatByteSize(rel.size_bytes) - return ( - - ) - })} -
-
-
- - - - - -
-
- )} - {prompt && ( = { "pluginLinkDevBtn": "链接插件开发目录", "pluginLinkDevTitle": "链接本地开发插件目录", "pluginMarketAlphaTag": "Alpha", - "pluginMarketCurrentVersion": "当前已安装", "pluginMarketDownloading": "下载中", "pluginMarketEmpty": "当前插件市场暂无可用条目,你仍可导入本地 .zip 插件包或配置自定义市场索引地址", "pluginMarketFeedEnd": "共 {count} 个插件", @@ -64,8 +63,6 @@ export const pluginsZh: Record = { "pluginMarketKindTheme": "主题", "pluginMarketKindTool": "工具", "pluginMarketLoading": "正在读取插件市场", - "pluginMarketPickVersionInstall": "安装此版本", - "pluginMarketPickVersionTitle": "选择安装版本", "pluginMarketRefresh": "刷新索引", "pluginMarketSearchPlaceholder": "搜索市场插件、作者或标签", "pluginMarketSortComposite": "综合排序", @@ -173,7 +170,6 @@ export const pluginsEn: Record = { "pluginLinkDevBtn": "Link plugin dev folder", "pluginLinkDevTitle": "Link local dev plugin folder", "pluginMarketAlphaTag": "Alpha", - "pluginMarketCurrentVersion": "Installed", "pluginMarketDownloading": "Downloading", "pluginMarketEmpty": "No plugins available in the market index yet. You can still import local .zip packages or configure a custom index URL.", "pluginMarketFeedEnd": "{count} plugins", @@ -189,8 +185,6 @@ export const pluginsEn: Record = { "pluginMarketKindTheme": "Themes", "pluginMarketKindTool": "Tools", "pluginMarketLoading": "Loading the plugin market", - "pluginMarketPickVersionInstall": "Install version", - "pluginMarketPickVersionTitle": "Select version", "pluginMarketRefresh": "Refresh index", "pluginMarketSearchPlaceholder": "Search market plugins, publishers, or tags", "pluginMarketSortComposite": "Recommended", diff --git a/frontend/src/i18n/keys.gen.ts b/frontend/src/i18n/keys.gen.ts index 0625894..359fa08 100644 --- a/frontend/src/i18n/keys.gen.ts +++ b/frontend/src/i18n/keys.gen.ts @@ -799,7 +799,6 @@ export type I18nKey = | "pluginLinkDevBtn" | "pluginLinkDevTitle" | "pluginMarketAlphaTag" - | "pluginMarketCurrentVersion" | "pluginMarketDownloading" | "pluginMarketEmpty" | "pluginMarketFeedEnd" @@ -815,8 +814,6 @@ export type I18nKey = | "pluginMarketKindTheme" | "pluginMarketKindTool" | "pluginMarketLoading" - | "pluginMarketPickVersionInstall" - | "pluginMarketPickVersionTitle" | "pluginMarketRefresh" | "pluginMarketSearchPlaceholder" | "pluginMarketSortComposite" diff --git a/frontend/src/styles/app.css b/frontend/src/styles/app.css index deaf54b..9e87479 100644 --- a/frontend/src/styles/app.css +++ b/frontend/src/styles/app.css @@ -1878,26 +1878,6 @@ button.status-issue + .status-metric { margin-left: 6px; } border-radius: 4px; font-size: 10px; font-weight: 600; flex-shrink: 0; color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); } -.market-version-list { display: flex; flex-direction: column; gap: 8px; } -.market-version-opt { - display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; - border-radius: var(--r-md); border: 1px solid var(--border); - background: var(--surface-1); cursor: pointer; -} -.market-version-opt.is-selected { - border-color: var(--accent); - background: color-mix(in srgb, var(--accent) 6%, var(--surface-1)); -} -.market-version-opt input[type='radio'] { margin-top: 3px; flex-shrink: 0; } -.market-version-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; } -.market-version-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: var(--fs-13); } -.market-version-current { - display: inline-flex; align-items: center; padding: 0 5px; height: 16px; - border-radius: 4px; font-size: 10px; font-weight: 600; - color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); -} -.market-version-meta { margin-left: auto; font-size: var(--fs-12); color: var(--text-3); font-variant-numeric: tabular-nums; } -.market-version-notes { margin: 0; font-size: var(--fs-12); color: var(--text-2); line-height: 1.45; } .plugin-title-link { color: inherit; text-decoration: none; } .plugin-title-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; } .market-card-action { flex-shrink: 0; } diff --git a/locales/en-US/plugins.json b/locales/en-US/plugins.json index f824578..a42baea 100644 --- a/locales/en-US/plugins.json +++ b/locales/en-US/plugins.json @@ -108,9 +108,6 @@ "pluginMarketSortDownloads": "Most downloads", "pluginMarketSortRecent": "Recently updated", "pluginMarketAlphaTag": "Alpha", - "pluginMarketPickVersionTitle": "Select version", - "pluginMarketPickVersionInstall": "Install version", - "pluginMarketCurrentVersion": "Installed", "pluginEnablePromptTitle": "“{name}” is installed", "pluginEnablePromptBody": "Enable it now? Here is what it can do:", "pluginEnablePromptNoRisk": "This plugin declares no extra capabilities.", diff --git a/locales/zh-CN/plugins.json b/locales/zh-CN/plugins.json index 4538846..19afc4c 100644 --- a/locales/zh-CN/plugins.json +++ b/locales/zh-CN/plugins.json @@ -108,9 +108,6 @@ "pluginMarketSortDownloads": "最多下载", "pluginMarketSortRecent": "最新发布", "pluginMarketAlphaTag": "Alpha", - "pluginMarketPickVersionTitle": "选择安装版本", - "pluginMarketPickVersionInstall": "安装此版本", - "pluginMarketCurrentVersion": "当前已安装", "pluginEnablePromptTitle": "「{name}」已安装", "pluginEnablePromptBody": "要现在启用吗?启用前请了解它会做什么:", "pluginEnablePromptNoRisk": "此插件没有声明额外能力,可以放心启用。",