From e09fdf046cac6fe7a2672d3d57e3c0340fc89bb8 Mon Sep 17 00:00:00 2001 From: Jason Date: Wed, 7 Oct 2026 09:16:14 +0800 Subject: [PATCH] feat(settings): give the About card's star prompt its own dismissible strip The star prompt sat at the end of the link row with ms-auto, so it wrapped onto a line of its own and read like a stray underlined caption. - Move it into a tinted strip at the bottom of the card with a slowly spinning star (stops under prefers-reduced-motion) and a "Star on GitHub" button that opens the repo - Drop the separate GitHub button while the strip is shown, since the star button goes to the same place - Add a close button; dismissal is remembered per device in localStorage, and the plain GitHub button returns to the link row - Add settings.starOnGithub to all four locales --- src/components/settings/AboutSection.tsx | 92 +++++++++++++++++++----- src/i18n/locales/en.json | 1 + src/i18n/locales/ja.json | 1 + src/i18n/locales/zh-TW.json | 1 + src/i18n/locales/zh.json | 1 + 5 files changed, 77 insertions(+), 19 deletions(-) diff --git a/src/components/settings/AboutSection.tsx b/src/components/settings/AboutSection.tsx index 3656e129d..a9126eb36 100644 --- a/src/components/settings/AboutSection.tsx +++ b/src/components/settings/AboutSection.tsx @@ -8,6 +8,8 @@ import { Loader2, RefreshCw, Sparkles, + Star, + X, } from "lucide-react"; import { Button } from "@/components/ui/button"; import { useTranslation } from "react-i18next"; @@ -28,6 +30,17 @@ interface AboutSectionProps { // 应用自身版本(getVersion,本地毫秒级、无网络)也缓存一份,纯为重挂时免去 loading 闪烁。 let appVersionCache: string | null = null; +// 邀 Star 条关掉后记在本机(纯界面偏好,不进库、不随云同步) +const STAR_PROMPT_DISMISSED_KEY = "ccswitch:about:starPromptDismissed"; + +function readStarPromptDismissed(): boolean { + try { + return localStorage.getItem(STAR_PROMPT_DISMISSED_KEY) === "1"; + } catch { + return false; + } +} + /** * 设置 → 关于:版本、便携模式、检查更新 / 安装并重启、项目链接。 * 命令行应用的安装与升级在侧栏「应用」页。 @@ -42,6 +55,9 @@ export function AboutSection({ isPortable }: AboutSectionProps) { ); const [isDownloading, setIsDownloading] = useState(false); const [whatsNewOpen, setWhatsNewOpen] = useState(false); + const [starPromptDismissed, setStarPromptDismissed] = useState( + readStarPromptDismissed, + ); const recentEntries = useMemo( () => (version ? entriesUpTo(WHATS_NEW_ENTRIES, version) : []), [version], @@ -106,6 +122,15 @@ export function AboutSection({ isPortable }: AboutSectionProps) { void settingsApi.openExternal("https://github.com/farion1231/cc-switch"); }, []); + const handleDismissStarPrompt = useCallback(() => { + setStarPromptDismissed(true); + try { + localStorage.setItem(STAR_PROMPT_DISMISSED_KEY, "1"); + } catch { + // 存不下就只在本次会话里隐藏 + } + }, []); + const handleCheckUpdate = useCallback(async () => { if (hasUpdate) { if (isPortable) { @@ -230,15 +255,17 @@ export function AboutSection({ isPortable }: AboutSectionProps) { )}
- + {starPromptDismissed && ( + + )}
+ {/* 下载与更新都走 ccswitch.io,用户不再经过仓库页,邀 Star 单独占一行;按钮即 GitHub 入口。 + 关掉后链接行补回 GitHub 按钮 */} + {!starPromptDismissed && ( +
+
+
+
+ + +
+
+ )} + setWhatsNewOpen(false)} diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 3629d9b49..e443fc4af 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -905,6 +905,7 @@ "officialWebsite": "Official Website", "github": "GitHub", "starPrompt": "If CC Switch has helped you, please star us on GitHub — it means a lot to us", + "starOnGithub": "Star on GitHub", "manualInstallCommands": "Manual Install Commands", "oneClickInstallHint": "Install or upgrade Claude Code / Codex / Gemini CLI / Grok Build / OpenCode / OpenClaw / Hermes / Pi / MiniMax Code", "localEnvCheck": "Local environment check", diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json index 39b14dae2..97615791b 100644 --- a/src/i18n/locales/ja.json +++ b/src/i18n/locales/ja.json @@ -905,6 +905,7 @@ "officialWebsite": "公式サイト", "github": "GitHub", "starPrompt": "CC Switch がお役に立てたなら、GitHub でスターをお願いします。私たちにとって大きな励みになります", + "starOnGithub": "GitHub でスター", "manualInstallCommands": "手動インストールコマンド", "oneClickInstallHint": "Claude Code / Codex / Gemini CLI / Grok Build / OpenCode / OpenClaw / Hermes / Pi / MiniMax Code をインストールまたは更新", "localEnvCheck": "ローカル環境チェック", diff --git a/src/i18n/locales/zh-TW.json b/src/i18n/locales/zh-TW.json index bc46e273a..4e40017bf 100644 --- a/src/i18n/locales/zh-TW.json +++ b/src/i18n/locales/zh-TW.json @@ -905,6 +905,7 @@ "officialWebsite": "官方網站", "github": "GitHub", "starPrompt": "如果 CC Switch 幫到了你,請在 GitHub 點個 Star,這對我們意義重大", + "starOnGithub": "去點 Star", "manualInstallCommands": "手動安裝指令", "oneClickInstall": "一鍵安裝", "oneClickInstallHint": "安裝或更新 Claude Code / Codex / Gemini CLI / Grok Build / OpenCode / OpenClaw / Hermes / Pi / MiniMax Code", diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json index 6aa0f0a17..1ebcd03d4 100644 --- a/src/i18n/locales/zh.json +++ b/src/i18n/locales/zh.json @@ -905,6 +905,7 @@ "officialWebsite": "官方网站", "github": "GitHub", "starPrompt": "如果 CC Switch 帮到了你,请在 GitHub 点个 Star,这对我们意义重大", + "starOnGithub": "去点 Star", "manualInstallCommands": "手动安装命令", "oneClickInstallHint": "安装或升级 Claude Code / Codex / Gemini CLI / Grok Build / OpenCode / OpenClaw / Hermes / Pi / MiniMax Code", "localEnvCheck": "本地环境检查",