mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-06-03 11:05:35 +08:00
refactor: inline useCommandKey as MOD_KEY constant in two call sites
This commit is contained in:
@@ -3,7 +3,6 @@ import { Check, ChevronDown } from "lucide-react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import { useServerPlatform } from "../../../../hooks/useServerPlatform";
|
import { useServerPlatform } from "../../../../hooks/useServerPlatform";
|
||||||
import { useCommandKey } from "../../../../hooks/useCommandKey";
|
|
||||||
import SessionProviderLogo from "../../../llm-logo-provider/SessionProviderLogo";
|
import SessionProviderLogo from "../../../llm-logo-provider/SessionProviderLogo";
|
||||||
import {
|
import {
|
||||||
CLAUDE_MODELS,
|
CLAUDE_MODELS,
|
||||||
@@ -28,6 +27,9 @@ import {
|
|||||||
Card,
|
Card,
|
||||||
} from "../../../../shared/view/ui";
|
} from "../../../../shared/view/ui";
|
||||||
|
|
||||||
|
const MOD_KEY =
|
||||||
|
typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform) ? "⌘" : "Ctrl";
|
||||||
|
|
||||||
type ProviderSelectionEmptyStateProps = {
|
type ProviderSelectionEmptyStateProps = {
|
||||||
selectedSession: ProjectSession | null;
|
selectedSession: ProjectSession | null;
|
||||||
currentSessionId: string | null;
|
currentSessionId: string | null;
|
||||||
@@ -108,7 +110,6 @@ export default function ProviderSelectionEmptyState({
|
|||||||
}: ProviderSelectionEmptyStateProps) {
|
}: ProviderSelectionEmptyStateProps) {
|
||||||
const { t } = useTranslation("chat");
|
const { t } = useTranslation("chat");
|
||||||
const { isWindowsServer } = useServerPlatform();
|
const { isWindowsServer } = useServerPlatform();
|
||||||
const { modKey } = useCommandKey();
|
|
||||||
const [dialogOpen, setDialogOpen] = useState(false);
|
const [dialogOpen, setDialogOpen] = useState(false);
|
||||||
|
|
||||||
const visibleProviderGroups = useMemo(
|
const visibleProviderGroups = useMemo(
|
||||||
@@ -293,7 +294,7 @@ export default function ProviderSelectionEmptyState({
|
|||||||
<p className="mt-3 flex items-center justify-center gap-1.5 text-center text-xs text-muted-foreground/60">
|
<p className="mt-3 flex items-center justify-center gap-1.5 text-center text-xs text-muted-foreground/60">
|
||||||
<span>Press</span>
|
<span>Press</span>
|
||||||
<kbd className="inline-flex items-center gap-0.5 rounded border border-border/60 bg-muted/40 px-1.5 py-0.5 font-mono text-[10px]">
|
<kbd className="inline-flex items-center gap-0.5 rounded border border-border/60 bg-muted/40 px-1.5 py-0.5 font-mono text-[10px]">
|
||||||
{modKey}
|
{MOD_KEY}
|
||||||
<span>K</span>
|
<span>K</span>
|
||||||
</kbd>
|
</kbd>
|
||||||
<span>to search sessions, files, and commits</span>
|
<span>to search sessions, files, and commits</span>
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ import type { TFunction } from 'i18next';
|
|||||||
import { Button, Input } from '../../../../shared/view/ui';
|
import { Button, Input } from '../../../../shared/view/ui';
|
||||||
import { IS_PLATFORM } from '../../../../constants/config';
|
import { IS_PLATFORM } from '../../../../constants/config';
|
||||||
import { cn } from '../../../../lib/utils';
|
import { cn } from '../../../../lib/utils';
|
||||||
import { useCommandKey } from '../../../../hooks/useCommandKey';
|
|
||||||
import GitHubStarBadge from './GitHubStarBadge';
|
import GitHubStarBadge from './GitHubStarBadge';
|
||||||
|
|
||||||
|
const MOD_KEY =
|
||||||
|
typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.platform) ? '⌘' : 'Ctrl';
|
||||||
|
|
||||||
type SearchMode = 'projects' | 'conversations';
|
type SearchMode = 'projects' | 'conversations';
|
||||||
|
|
||||||
type SidebarHeaderProps = {
|
type SidebarHeaderProps = {
|
||||||
@@ -41,7 +43,6 @@ export default function SidebarHeader({
|
|||||||
onCollapseSidebar,
|
onCollapseSidebar,
|
||||||
t,
|
t,
|
||||||
}: SidebarHeaderProps) {
|
}: SidebarHeaderProps) {
|
||||||
const { modKey } = useCommandKey();
|
|
||||||
const LogoBlock = () => (
|
const LogoBlock = () => (
|
||||||
<div className="flex min-w-0 items-center gap-2.5">
|
<div className="flex min-w-0 items-center gap-2.5">
|
||||||
<div className="flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-primary/90 shadow-sm">
|
<div className="flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-primary/90 shadow-sm">
|
||||||
@@ -166,7 +167,7 @@ export default function SidebarHeader({
|
|||||||
title="Open command palette"
|
title="Open command palette"
|
||||||
className="pointer-events-none absolute right-2.5 top-1/2 hidden -translate-y-1/2 items-center gap-0.5 rounded border border-border/60 bg-muted/40 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground md:inline-flex"
|
className="pointer-events-none absolute right-2.5 top-1/2 hidden -translate-y-1/2 items-center gap-0.5 rounded border border-border/60 bg-muted/40 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground md:inline-flex"
|
||||||
>
|
>
|
||||||
{modKey}
|
{MOD_KEY}
|
||||||
<span>K</span>
|
<span>K</span>
|
||||||
</kbd>
|
</kbd>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
export type CommandKey = {
|
|
||||||
isMac: boolean;
|
|
||||||
modKey: '⌘' | 'Ctrl';
|
|
||||||
};
|
|
||||||
|
|
||||||
export function useCommandKey(): CommandKey {
|
|
||||||
const isMac =
|
|
||||||
typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.platform);
|
|
||||||
return { isMac, modKey: isMac ? '⌘' : 'Ctrl' };
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user