mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-02 18:41:35 +08:00
fix(settings): navigate to About tab when clicking update badge
- Add defaultTab prop to SettingsPage for external tab control - UpdateBadge click now opens settings directly to About tab - Settings button still opens to General tab (default behavior) - Change update badge text from version number to "Update available"
This commit is contained in:
+10
-2
@@ -70,6 +70,7 @@ function App() {
|
|||||||
|
|
||||||
const [activeApp, setActiveApp] = useState<AppId>("claude");
|
const [activeApp, setActiveApp] = useState<AppId>("claude");
|
||||||
const [currentView, setCurrentView] = useState<View>("providers");
|
const [currentView, setCurrentView] = useState<View>("providers");
|
||||||
|
const [settingsDefaultTab, setSettingsDefaultTab] = useState("general");
|
||||||
const [isAddOpen, setIsAddOpen] = useState(false);
|
const [isAddOpen, setIsAddOpen] = useState(false);
|
||||||
|
|
||||||
const [editingProvider, setEditingProvider] = useState<Provider | null>(null);
|
const [editingProvider, setEditingProvider] = useState<Provider | null>(null);
|
||||||
@@ -411,6 +412,7 @@ function App() {
|
|||||||
open={true}
|
open={true}
|
||||||
onOpenChange={() => setCurrentView("providers")}
|
onOpenChange={() => setCurrentView("providers")}
|
||||||
onImportSuccess={handleImportSuccess}
|
onImportSuccess={handleImportSuccess}
|
||||||
|
defaultTab={settingsDefaultTab}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case "prompts":
|
case "prompts":
|
||||||
@@ -610,14 +612,20 @@ function App() {
|
|||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="icon"
|
size="icon"
|
||||||
onClick={() => setCurrentView("settings")}
|
onClick={() => {
|
||||||
|
setSettingsDefaultTab("general");
|
||||||
|
setCurrentView("settings");
|
||||||
|
}}
|
||||||
title={t("common.settings")}
|
title={t("common.settings")}
|
||||||
className="hover:bg-black/5 dark:hover:bg-white/5"
|
className="hover:bg-black/5 dark:hover:bg-white/5"
|
||||||
>
|
>
|
||||||
<Settings className="w-4 h-4" />
|
<Settings className="w-4 h-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<UpdateBadge onClick={() => setCurrentView("settings")} />
|
<UpdateBadge onClick={() => {
|
||||||
|
setSettingsDefaultTab("about");
|
||||||
|
setCurrentView("settings");
|
||||||
|
}} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export function UpdateBadge({ className = "", onClick }: UpdateBadgeProps) {
|
|||||||
>
|
>
|
||||||
<Download className="w-3 h-3 text-blue-500 dark:text-blue-400" />
|
<Download className="w-3 h-3 text-blue-500 dark:text-blue-400" />
|
||||||
<span className="text-gray-700 dark:text-gray-300 font-medium">
|
<span className="text-gray-700 dark:text-gray-300 font-medium">
|
||||||
v{updateInfo.availableVersion}
|
{t("settings.updateBadge")}
|
||||||
</span>
|
</span>
|
||||||
<button
|
<button
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
|
|||||||
@@ -52,12 +52,14 @@ interface SettingsDialogProps {
|
|||||||
open: boolean;
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
onImportSuccess?: () => void | Promise<void>;
|
onImportSuccess?: () => void | Promise<void>;
|
||||||
|
defaultTab?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SettingsPage({
|
export function SettingsPage({
|
||||||
open,
|
open,
|
||||||
onOpenChange,
|
onOpenChange,
|
||||||
onImportSuccess,
|
onImportSuccess,
|
||||||
|
defaultTab = "general",
|
||||||
}: SettingsDialogProps) {
|
}: SettingsDialogProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const {
|
const {
|
||||||
@@ -98,10 +100,10 @@ export function SettingsPage({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (open) {
|
if (open) {
|
||||||
setActiveTab("general");
|
setActiveTab(defaultTab);
|
||||||
resetStatus();
|
resetStatus();
|
||||||
}
|
}
|
||||||
}, [open, resetStatus]);
|
}, [open, resetStatus, defaultTab]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (requiresRestart) {
|
if (requiresRestart) {
|
||||||
|
|||||||
@@ -251,6 +251,7 @@
|
|||||||
"aboutHint": "View version information and update status.",
|
"aboutHint": "View version information and update status.",
|
||||||
"portableMode": "Portable mode: updates require manual download.",
|
"portableMode": "Portable mode: updates require manual download.",
|
||||||
"updateAvailable": "New version available: {{version}}",
|
"updateAvailable": "New version available: {{version}}",
|
||||||
|
"updateBadge": "Update available",
|
||||||
"updateFailed": "Update installation failed, attempted to open download page.",
|
"updateFailed": "Update installation failed, attempted to open download page.",
|
||||||
"checkUpdateFailed": "Failed to check for updates, please try again later.",
|
"checkUpdateFailed": "Failed to check for updates, please try again later.",
|
||||||
"openReleaseNotesFailed": "Failed to open release notes",
|
"openReleaseNotesFailed": "Failed to open release notes",
|
||||||
|
|||||||
@@ -251,6 +251,7 @@
|
|||||||
"aboutHint": "バージョン情報と更新状況を表示します。",
|
"aboutHint": "バージョン情報と更新状況を表示します。",
|
||||||
"portableMode": "ポータブルモード: 更新は手動ダウンロードが必要です。",
|
"portableMode": "ポータブルモード: 更新は手動ダウンロードが必要です。",
|
||||||
"updateAvailable": "新しいバージョンがあります: {{version}}",
|
"updateAvailable": "新しいバージョンがあります: {{version}}",
|
||||||
|
"updateBadge": "更新あり",
|
||||||
"updateFailed": "更新のインストールに失敗しました。ダウンロードページを開こうとしました。",
|
"updateFailed": "更新のインストールに失敗しました。ダウンロードページを開こうとしました。",
|
||||||
"checkUpdateFailed": "更新の確認に失敗しました。時間をおいて再試行してください。",
|
"checkUpdateFailed": "更新の確認に失敗しました。時間をおいて再試行してください。",
|
||||||
"openReleaseNotesFailed": "リリースノートの表示に失敗しました",
|
"openReleaseNotesFailed": "リリースノートの表示に失敗しました",
|
||||||
|
|||||||
@@ -251,6 +251,7 @@
|
|||||||
"aboutHint": "查看版本信息与更新状态。",
|
"aboutHint": "查看版本信息与更新状态。",
|
||||||
"portableMode": "当前为便携版,更新需手动下载。",
|
"portableMode": "当前为便携版,更新需手动下载。",
|
||||||
"updateAvailable": "检测到新版本:{{version}}",
|
"updateAvailable": "检测到新版本:{{version}}",
|
||||||
|
"updateBadge": "有更新可用",
|
||||||
"updateFailed": "更新安装失败,已尝试打开下载页面。",
|
"updateFailed": "更新安装失败,已尝试打开下载页面。",
|
||||||
"checkUpdateFailed": "检查更新失败,请稍后重试。",
|
"checkUpdateFailed": "检查更新失败,请稍后重试。",
|
||||||
"openReleaseNotesFailed": "打开更新日志失败",
|
"openReleaseNotesFailed": "打开更新日志失败",
|
||||||
|
|||||||
Reference in New Issue
Block a user