From 5e405b31b238336a63da9d6b804385088a05355b Mon Sep 17 00:00:00 2001 From: leookun Date: Sun, 30 Aug 2026 21:15:03 +0800 Subject: [PATCH] feat: add copy button functionality to OAuthMethodCard - Implemented a new button to copy the user code in the OAuthMethodCard, enhancing user experience. - Added styles for the copy button to match the UI design. - Updated localization files to include new strings for the copy action in both English and Chinese. --- .../plugins/PluginResourcePanels.module.scss | 14 ++ .../features/plugins/PluginResourcePanels.tsx | 12 +- apps/desktop/src/i18n/generated/catalog.json | 171 ++++++++++-------- apps/desktop/src/i18n/locales/en-US.json | 1 + apps/desktop/src/i18n/locales/zh-CN.json | 1 + server/src/plugin/worker.rs | 18 +- 6 files changed, 136 insertions(+), 81 deletions(-) diff --git a/apps/desktop/src/features/plugins/PluginResourcePanels.module.scss b/apps/desktop/src/features/plugins/PluginResourcePanels.module.scss index b1cd609..23d1fb2 100644 --- a/apps/desktop/src/features/plugins/PluginResourcePanels.module.scss +++ b/apps/desktop/src/features/plugins/PluginResourcePanels.module.scss @@ -46,6 +46,20 @@ letter-spacing: 0.08em; cursor: pointer; } + + button.copy { + padding: 6px 2px; + color: var(--vscode-textLink-foreground); + background: none; + border: none; + font-family: inherit; + letter-spacing: normal; + font-size: type.$font-size-xs; + + &:hover { + text-decoration: underline; + } + } } .fileButton { diff --git a/apps/desktop/src/features/plugins/PluginResourcePanels.tsx b/apps/desktop/src/features/plugins/PluginResourcePanels.tsx index cbc47ae..2c4f902 100644 --- a/apps/desktop/src/features/plugins/PluginResourcePanels.tsx +++ b/apps/desktop/src/features/plugins/PluginResourcePanels.tsx @@ -56,8 +56,15 @@ function OAuthMethodCard({ pluginId, resourceType, method, onConfigured }: { const [status, setStatus] = useState<"idle" | "starting" | "polling" | "success" | "error">("idle"); const [begun, setBegun] = useState(null); const [error, setError] = useState(null); + const [copied, setCopied] = useState(false); const stopped = useRef(false); + const copyCode = async (code: string) => { + await api.copyCursorText(code).catch(() => undefined); + setCopied(true); + window.setTimeout(() => setCopied(false), 2000); + }; + useEffect(() => () => { stopped.current = true; }, []); useEffect(() => { @@ -115,7 +122,10 @@ function OAuthMethodCard({ pluginId, resourceType, method, onConfigured }: { {method.description && {pluginText(method.description, locale)}} {begun && status === "polling" &&
{t("设备验证码")} - + +
}