From 5dc11f26ca7dfaf6c89ed10671145b01a4368f1a Mon Sep 17 00:00:00 2001 From: t8y2 Date: Sat, 3 Oct 2026 06:49:54 +0800 Subject: [PATCH] feat(plugins): tidy marketplace cards and collapse badge rows --- .../plugins/PluginContributionsPanel.vue | 245 ++++++++---------- .../PluginContributionsPanelBatch.spec.ts | 55 +++- apps/desktop/src/i18n/locales/en.ts | 1 - apps/desktop/src/i18n/locales/es.ts | 1 - apps/desktop/src/i18n/locales/id.ts | 1 - apps/desktop/src/i18n/locales/it.ts | 1 - apps/desktop/src/i18n/locales/ja.ts | 1 - apps/desktop/src/i18n/locales/ko.ts | 1 - apps/desktop/src/i18n/locales/pt-BR.ts | 1 - apps/desktop/src/i18n/locales/ru.ts | 1 - apps/desktop/src/i18n/locales/zh-CN.ts | 1 - apps/desktop/src/i18n/locales/zh-TW.ts | 1 - 12 files changed, 146 insertions(+), 164 deletions(-) diff --git a/apps/desktop/src/components/plugins/PluginContributionsPanel.vue b/apps/desktop/src/components/plugins/PluginContributionsPanel.vue index 45826bd995..a9c2baa90a 100644 --- a/apps/desktop/src/components/plugins/PluginContributionsPanel.vue +++ b/apps/desktop/src/components/plugins/PluginContributionsPanel.vue @@ -58,16 +58,18 @@ const emit = defineEmits<{ pluginRuntimeReplaced: [pluginId: string]; }>(); -// lucide no longer ships brand icons; mirror the inline glyph used in AppToolbar. +// lucide no longer ships brand icons; this stroke glyph keeps the 2px outline style of +// neighboring lucide icons instead of the heavier filled brand mark. const GithubIcon = defineComponent({ props: { iconClass: { type: String, default: "size-3" }, }, render() { - return h("svg", { class: this.iconClass, viewBox: "0 0 24 24", fill: "currentColor" }, [ + return h("svg", { class: this.iconClass, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": 2, "stroke-linecap": "round", "stroke-linejoin": "round" }, [ h("path", { - d: "M12 0C5.37 0 0 5.37 0 12c0 5.3 3.438 9.8 8.205 11.387.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61-.546-1.387-1.333-1.756-1.333-1.756-1.09-.745.083-.729.083-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 21.795 24 17.295 24 12 24 5.37 18.627 0 12 0z", + d: "M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4", }), + h("path", { d: "M9 18c-4.51 2-5-2-7-2" }), ]); }, }); @@ -225,18 +227,24 @@ const showCustomRepositoryTrustSettings = computed(() => customRepositories.valu const pluginDevelopmentDocsUrl = computed(() => `https://dbxio.com/${appLocale.value.startsWith("zh") ? "cn" : "en"}/docs/plugin-development`); function marketplaceActionClass(listing: MarketplacePluginListing): string { - if (listing.status === "update") return "text-blue-600 hover:bg-gray-200 dark:text-blue-400 dark:hover:bg-gray-700"; - if (listing.status === "install") return "text-foreground hover:bg-gray-200 dark:hover:bg-gray-700"; - return "cursor-default text-gray-600 dark:text-gray-400"; + if (listing.status === "update") return "bg-blue-600/10 text-blue-700 hover:bg-blue-600/20 dark:bg-blue-400/10 dark:text-blue-400 dark:hover:bg-blue-400/20"; + if (listing.status === "install") return "bg-muted text-foreground hover:bg-accent"; + return "cursor-default bg-muted text-muted-foreground"; } -// 紧凑档(窄卡)下 "+N" 折叠标签的展开状态;只影响展示,重开面板自然复位。 -const expandedTagKeys = ref(new Set()); -function toggleTagExpansion(key: string) { - const next = new Set(expandedTagKeys.value); - if (next.has(key)) next.delete(key); - else next.add(key); - expandedTagKeys.value = next; +// Badge row budget: tags first, then permissions, then one trailing "+N" counter. The row must +// stay single-line; everything past the limit rides in the "+N" tooltip, and when the overflow +// hides a sensitive permission the "+N" badge itself takes the destructive variant so the risk +// signal never leaves the card. +const MARKETPLACE_CARD_BADGE_LIMIT = 3; + +type MarketplaceCardBadge = { value: string; kind: "tag" | "permission"; sensitive: boolean }; + +function marketplaceCardBadges(listing: MarketplacePluginListing): { visible: MarketplaceCardBadge[]; hidden: MarketplaceCardBadge[]; hiddenSensitive: boolean } { + const badges: MarketplaceCardBadge[] = [...listing.plugin.tags.map((value) => ({ value, kind: "tag" as const, sensitive: false })), ...listing.plugin.permissions.map((value) => ({ value, kind: "permission" as const, sensitive: isSensitivePluginPermission(value) }))]; + const visible = badges.slice(0, MARKETPLACE_CARD_BADGE_LIMIT); + const hidden = badges.slice(MARKETPLACE_CARD_BADGE_LIMIT); + return { visible, hidden, hiddenSensitive: hidden.some((badge) => badge.sensitive) }; } // 安装/更新完成后的短促确认窗口:动作按钮上的对勾弹入几百毫秒即退场。 @@ -1201,104 +1209,72 @@ onBeforeUnmount(() => {
{{ t("pluginPlatform.noMarketplacePluginsDescription") }}
-
-
- +
+
+
{{ listing.name }}
-
- v{{ listing.plugin.latestVersion }} -
{{ listing.plugin.publisher }} · {{ listing.repository.name }}
-
- - - {{ formatMarketplaceReleasedDate(listing.latestVersionReleasedAt, appLocale) }} -
- +
+ + + +
-
- - +
+ + - {{ listing.plugin.tags[0] }} - - {{ listing.plugin.tags[0] }} - - - - - - - {{ - permission + {{ + badge.value }} - {{ permission }} + {{ badge.value }} + + + + +{{ marketplaceCardBadges(listing).hidden.length }} + + +
+ {{ badge.value }} +
+
-
- -
-
-
- - - {{ tag }} - - {{ tag }} - -
-
@@ -1307,17 +1283,24 @@ onBeforeUnmount(() => { {{ listing.description || t("pluginPlatform.noDescription") }}