mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-27 16:26:16 +08:00
style: format code and apply clippy lint fixes
This commit is contained in:
@@ -8,7 +8,10 @@ interface AppCountBarProps {
|
||||
counts: Record<AppId, number>;
|
||||
}
|
||||
|
||||
export const AppCountBar: React.FC<AppCountBarProps> = ({ totalLabel, counts }) => {
|
||||
export const AppCountBar: React.FC<AppCountBarProps> = ({
|
||||
totalLabel,
|
||||
counts,
|
||||
}) => {
|
||||
return (
|
||||
<div className="flex-shrink-0 py-4 glass rounded-xl border border-white/10 mb-4 px-6 flex items-center justify-between gap-4">
|
||||
<Badge variant="outline" className="bg-background/50 h-7 px-3">
|
||||
|
||||
@@ -12,7 +12,10 @@ interface AppToggleGroupProps {
|
||||
onToggle: (app: AppId, enabled: boolean) => void;
|
||||
}
|
||||
|
||||
export const AppToggleGroup: React.FC<AppToggleGroupProps> = ({ apps, onToggle }) => {
|
||||
export const AppToggleGroup: React.FC<AppToggleGroupProps> = ({
|
||||
apps,
|
||||
onToggle,
|
||||
}) => {
|
||||
return (
|
||||
<div className="flex items-center gap-1.5 flex-shrink-0">
|
||||
{APP_IDS.map((app) => {
|
||||
@@ -25,16 +28,17 @@ export const AppToggleGroup: React.FC<AppToggleGroupProps> = ({ apps, onToggle }
|
||||
type="button"
|
||||
onClick={() => onToggle(app, !enabled)}
|
||||
className={`w-7 h-7 rounded-lg flex items-center justify-center transition-all ${
|
||||
enabled
|
||||
? activeClass
|
||||
: "opacity-35 hover:opacity-70"
|
||||
enabled ? activeClass : "opacity-35 hover:opacity-70"
|
||||
}`}
|
||||
>
|
||||
{icon}
|
||||
</button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="bottom">
|
||||
<p>{label}{enabled ? " ✓" : ""}</p>
|
||||
<p>
|
||||
{label}
|
||||
{enabled ? " ✓" : ""}
|
||||
</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
);
|
||||
|
||||
@@ -5,7 +5,10 @@ interface ListItemRowProps {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export const ListItemRow: React.FC<ListItemRowProps> = ({ isLast, children }) => {
|
||||
export const ListItemRow: React.FC<ListItemRowProps> = ({
|
||||
isLast,
|
||||
children,
|
||||
}) => {
|
||||
return (
|
||||
<div
|
||||
className={`group flex items-center gap-3 px-4 py-2.5 hover:bg-muted/50 transition-colors ${
|
||||
|
||||
@@ -245,7 +245,9 @@ const UnifiedMcpListItem: React.FC<UnifiedMcpListItemProps> = ({
|
||||
<ListItemRow isLast={isLast}>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="font-medium text-sm text-foreground truncate">{name}</span>
|
||||
<span className="font-medium text-sm text-foreground truncate">
|
||||
{name}
|
||||
</span>
|
||||
{docsUrl && (
|
||||
<button
|
||||
type="button"
|
||||
@@ -258,7 +260,10 @@ const UnifiedMcpListItem: React.FC<UnifiedMcpListItemProps> = ({
|
||||
)}
|
||||
</div>
|
||||
{description && (
|
||||
<p className="text-xs text-muted-foreground truncate" title={description}>
|
||||
<p
|
||||
className="text-xs text-muted-foreground truncate"
|
||||
title={description}
|
||||
>
|
||||
{description}
|
||||
</p>
|
||||
)}
|
||||
|
||||
@@ -40,7 +40,7 @@ export function SessionItem({
|
||||
"w-full text-left rounded-lg px-3 py-2.5 transition-all group",
|
||||
isSelected
|
||||
? "bg-primary/10 border border-primary/30"
|
||||
: "hover:bg-muted/60 border border-transparent"
|
||||
: "hover:bg-muted/60 border border-transparent",
|
||||
)}
|
||||
>
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
@@ -62,7 +62,7 @@ export function SessionItem({
|
||||
<ChevronRight
|
||||
className={cn(
|
||||
"size-4 text-muted-foreground/50 shrink-0 transition-transform",
|
||||
isSelected && "text-primary rotate-90"
|
||||
isSelected && "text-primary rotate-90",
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -76,7 +76,7 @@ export function SessionManagerPage() {
|
||||
const messagesEndRef = useRef<HTMLDivElement | null>(null);
|
||||
const messageRefs = useRef<Map<number, HTMLDivElement>>(new Map());
|
||||
const [activeMessageIndex, setActiveMessageIndex] = useState<number | null>(
|
||||
null
|
||||
null,
|
||||
);
|
||||
const [tocDialogOpen, setTocDialogOpen] = useState(false);
|
||||
const [isSearchOpen, setIsSearchOpen] = useState(false);
|
||||
@@ -91,7 +91,7 @@ export function SessionManagerPage() {
|
||||
|
||||
useEffect(() => {
|
||||
const storedTarget = window.localStorage.getItem(
|
||||
TERMINAL_TARGET_KEY
|
||||
TERMINAL_TARGET_KEY,
|
||||
) as TerminalTarget | null;
|
||||
if (storedTarget) {
|
||||
setTerminalTarget(storedTarget);
|
||||
@@ -123,7 +123,7 @@ export function SessionManagerPage() {
|
||||
}
|
||||
const exists = selectedKey
|
||||
? filteredSessions.some(
|
||||
(session) => getSessionKey(session) === selectedKey
|
||||
(session) => getSessionKey(session) === selectedKey,
|
||||
)
|
||||
: false;
|
||||
if (!exists) {
|
||||
@@ -135,7 +135,7 @@ export function SessionManagerPage() {
|
||||
if (!selectedKey) return null;
|
||||
return (
|
||||
filteredSessions.find(
|
||||
(session) => getSessionKey(session) === selectedKey
|
||||
(session) => getSessionKey(session) === selectedKey,
|
||||
) || null
|
||||
);
|
||||
}, [filteredSessions, selectedKey]);
|
||||
@@ -143,7 +143,7 @@ export function SessionManagerPage() {
|
||||
const { data: messages = [], isLoading: isLoadingMessages } =
|
||||
useSessionMessagesQuery(
|
||||
selectedSession?.providerId,
|
||||
selectedSession?.sourcePath
|
||||
selectedSession?.sourcePath,
|
||||
);
|
||||
|
||||
// 提取用户消息用于目录
|
||||
@@ -187,7 +187,7 @@ export function SessionManagerPage() {
|
||||
} catch (error) {
|
||||
toast.error(
|
||||
extractErrorMessage(error) ||
|
||||
t("common.error", { defaultValue: "Copy failed" })
|
||||
t("common.error", { defaultValue: "Copy failed" }),
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -198,7 +198,7 @@ export function SessionManagerPage() {
|
||||
if (!isMac()) {
|
||||
await handleCopy(
|
||||
selectedSession.resumeCommand,
|
||||
t("sessionManager.resumeCommandCopied")
|
||||
t("sessionManager.resumeCommandCopied"),
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -281,7 +281,7 @@ export function SessionManagerPage() {
|
||||
setIsSearchOpen(true);
|
||||
setTimeout(
|
||||
() => searchInputRef.current?.focus(),
|
||||
0
|
||||
0,
|
||||
);
|
||||
}}
|
||||
>
|
||||
@@ -428,7 +428,7 @@ export function SessionManagerPage() {
|
||||
<span className="shrink-0">
|
||||
<ProviderIcon
|
||||
icon={getProviderIconName(
|
||||
selectedSession.providerId
|
||||
selectedSession.providerId,
|
||||
)}
|
||||
name={selectedSession.providerId}
|
||||
size={20}
|
||||
@@ -451,7 +451,7 @@ export function SessionManagerPage() {
|
||||
<span>
|
||||
{formatTimestamp(
|
||||
selectedSession.lastActiveAt ??
|
||||
selectedSession.createdAt
|
||||
selectedSession.createdAt,
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
@@ -463,7 +463,7 @@ export function SessionManagerPage() {
|
||||
onClick={() =>
|
||||
void handleCopy(
|
||||
selectedSession.projectDir!,
|
||||
t("sessionManager.projectDirCopied")
|
||||
t("sessionManager.projectDirCopied"),
|
||||
)
|
||||
}
|
||||
className="flex items-center gap-1 hover:text-foreground transition-colors"
|
||||
@@ -590,7 +590,7 @@ export function SessionManagerPage() {
|
||||
onClick={() =>
|
||||
void handleCopy(
|
||||
selectedSession.resumeCommand!,
|
||||
t("sessionManager.resumeCommandCopied")
|
||||
t("sessionManager.resumeCommandCopied"),
|
||||
)
|
||||
}
|
||||
>
|
||||
@@ -652,7 +652,7 @@ export function SessionManagerPage() {
|
||||
content,
|
||||
t("sessionManager.messageCopied", {
|
||||
defaultValue: "已复制消息内容",
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -37,7 +37,7 @@ export function SessionMessageItem({
|
||||
: message.role.toLowerCase() === "assistant"
|
||||
? "bg-blue-500/5 border-blue-500/20 mr-8"
|
||||
: "bg-muted/40 border-border/60",
|
||||
isActive && "ring-2 ring-primary ring-offset-2"
|
||||
isActive && "ring-2 ring-primary ring-offset-2",
|
||||
)}
|
||||
>
|
||||
<Tooltip>
|
||||
|
||||
@@ -46,7 +46,7 @@ export function SessionTocSidebar({
|
||||
className={cn(
|
||||
"w-full text-left px-2 py-1.5 rounded text-xs transition-colors",
|
||||
"hover:bg-muted/80 text-muted-foreground hover:text-foreground",
|
||||
"flex items-start gap-2"
|
||||
"flex items-start gap-2",
|
||||
)}
|
||||
>
|
||||
<span className="shrink-0 w-4 h-4 rounded-full bg-primary/10 text-primary text-[10px] flex items-center justify-center font-medium">
|
||||
@@ -115,7 +115,7 @@ export function SessionTocDialog({
|
||||
"w-full text-left px-3 py-2.5 rounded-lg text-sm transition-all",
|
||||
"hover:bg-primary/10 text-foreground",
|
||||
"flex items-start gap-3",
|
||||
"focus:outline-none focus:ring-2 focus:ring-primary focus:ring-inset"
|
||||
"focus:outline-none focus:ring-2 focus:ring-primary focus:ring-inset",
|
||||
)}
|
||||
>
|
||||
<span className="shrink-0 w-6 h-6 rounded-full bg-primary text-primary-foreground text-xs flex items-center justify-center font-semibold">
|
||||
|
||||
@@ -34,7 +34,7 @@ export const formatRelativeTime = (value?: number) => {
|
||||
|
||||
export const getProviderLabel = (
|
||||
providerId: string,
|
||||
t: (key: string) => string
|
||||
t: (key: string) => string,
|
||||
) => {
|
||||
const key = `apps.${providerId}`;
|
||||
const translated = t(key);
|
||||
|
||||
@@ -63,11 +63,7 @@ const UnifiedSkillsPanel = React.forwardRef<
|
||||
return counts;
|
||||
}, [skills]);
|
||||
|
||||
const handleToggleApp = async (
|
||||
id: string,
|
||||
app: AppId,
|
||||
enabled: boolean,
|
||||
) => {
|
||||
const handleToggleApp = async (id: string, app: AppId, enabled: boolean) => {
|
||||
try {
|
||||
await toggleAppMutation.mutateAsync({ id, app, enabled });
|
||||
} catch (error) {
|
||||
@@ -257,7 +253,9 @@ const InstalledSkillListItem: React.FC<InstalledSkillListItemProps> = ({
|
||||
<ListItemRow isLast={isLast}>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="font-medium text-sm text-foreground truncate">{skill.name}</span>
|
||||
<span className="font-medium text-sm text-foreground truncate">
|
||||
{skill.name}
|
||||
</span>
|
||||
{skill.readmeUrl && (
|
||||
<button
|
||||
type="button"
|
||||
@@ -267,10 +265,15 @@ const InstalledSkillListItem: React.FC<InstalledSkillListItemProps> = ({
|
||||
<ExternalLink size={12} />
|
||||
</button>
|
||||
)}
|
||||
<span className="text-xs text-muted-foreground/50 flex-shrink-0">{sourceLabel}</span>
|
||||
<span className="text-xs text-muted-foreground/50 flex-shrink-0">
|
||||
{sourceLabel}
|
||||
</span>
|
||||
</div>
|
||||
{skill.description && (
|
||||
<p className="text-xs text-muted-foreground truncate" title={skill.description}>
|
||||
<p
|
||||
className="text-xs text-muted-foreground truncate"
|
||||
title={skill.description}
|
||||
>
|
||||
{skill.description}
|
||||
</p>
|
||||
)}
|
||||
|
||||
@@ -36,7 +36,7 @@ const ScrollBar = React.forwardRef<
|
||||
"h-full w-2.5 border-l border-l-transparent p-[1px]",
|
||||
orientation === "horizontal" &&
|
||||
"h-2.5 flex-col border-t border-t-transparent p-[1px]",
|
||||
className
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
|
||||
@@ -20,7 +20,7 @@ const TooltipContent = React.forwardRef<
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||
className
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user