mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-24 17:15:50 +00:00
更新大量 tsx 原始文件; 已经迁移 login panel; 部分 (#121)
* style(B1-1): 格式化 ink/buddy/cli/context/screens/tasks/services/keybindings/state (43 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 修复了 Box.tsx 和 ScrollBox.tsx 中无效的 global.d.ts import。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-2): 格式化 commands (79 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-3): 格式化 components/messages,permissions,mcp,sandbox,shell (104 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-4): 格式化 components/PromptInput,FeedbackSurvey,tasks,agents,skills,design-system,wizard (73 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-5): 格式化 components其余 + hooks + tools (232 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-6): 格式化 main/entrypoints/utils/moreright (21 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: 更新 README,新增 Run.ps1/TODO.md,删除 V6.md - README.md: 大幅重写,更详细版本历史和配置示例 - Run.ps1: 新增 Windows 启动脚本 - TODO.md: 新增包完成清单 - V6.md: 删除(架构重构规划已不适用) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: 修复以前的问题 * fix: 修复 login 面板的问题 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,22 +1,14 @@
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import * as React from 'react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { Box } from '../../ink.js';
|
||||
import { getInitialSettings } from '../../utils/settings/settings.js';
|
||||
import { Clawd, type ClawdPose } from './Clawd.js';
|
||||
type Frame = {
|
||||
pose: ClawdPose;
|
||||
offset: number;
|
||||
};
|
||||
import * as React from 'react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { Box } from '../../ink.js'
|
||||
import { getInitialSettings } from '../../utils/settings/settings.js'
|
||||
import { Clawd, type ClawdPose } from './Clawd.js'
|
||||
|
||||
type Frame = { pose: ClawdPose; offset: number }
|
||||
|
||||
/** Hold a pose for n frames (60ms each). */
|
||||
function hold(pose: ClawdPose, offset: number, frames: number): Frame[] {
|
||||
return Array.from({
|
||||
length: frames
|
||||
}, () => ({
|
||||
pose,
|
||||
offset
|
||||
}));
|
||||
return Array.from({ length: frames }, () => ({ pose, offset }))
|
||||
}
|
||||
|
||||
// Offset semantics: marginTop in a fixed-height-3 container. 0 = normal,
|
||||
@@ -25,26 +17,28 @@ function hold(pose: ClawdPose, offset: number, frames: number): Frame[] {
|
||||
// clipped — reads as "ducking below the frame" before springing back up.
|
||||
|
||||
// Click animation: crouch, then spring up with both arms raised. Twice.
|
||||
const JUMP_WAVE: readonly Frame[] = [...hold('default', 1, 2),
|
||||
// crouch
|
||||
...hold('arms-up', 0, 3),
|
||||
// spring!
|
||||
...hold('default', 0, 1), ...hold('default', 1, 2),
|
||||
// crouch again
|
||||
...hold('arms-up', 0, 3),
|
||||
// spring!
|
||||
...hold('default', 0, 1)];
|
||||
const JUMP_WAVE: readonly Frame[] = [
|
||||
...hold('default', 1, 2), // crouch
|
||||
...hold('arms-up', 0, 3), // spring!
|
||||
...hold('default', 0, 1),
|
||||
...hold('default', 1, 2), // crouch again
|
||||
...hold('arms-up', 0, 3), // spring!
|
||||
...hold('default', 0, 1),
|
||||
]
|
||||
|
||||
// Click animation: glance right, then left, then back.
|
||||
const LOOK_AROUND: readonly Frame[] = [...hold('look-right', 0, 5), ...hold('look-left', 0, 5), ...hold('default', 0, 1)];
|
||||
const CLICK_ANIMATIONS: readonly (readonly Frame[])[] = [JUMP_WAVE, LOOK_AROUND];
|
||||
const IDLE: Frame = {
|
||||
pose: 'default',
|
||||
offset: 0
|
||||
};
|
||||
const FRAME_MS = 60;
|
||||
const incrementFrame = (i: number) => i + 1;
|
||||
const CLAWD_HEIGHT = 3;
|
||||
const LOOK_AROUND: readonly Frame[] = [
|
||||
...hold('look-right', 0, 5),
|
||||
...hold('look-left', 0, 5),
|
||||
...hold('default', 0, 1),
|
||||
]
|
||||
|
||||
const CLICK_ANIMATIONS: readonly (readonly Frame[])[] = [JUMP_WAVE, LOOK_AROUND]
|
||||
|
||||
const IDLE: Frame = { pose: 'default', offset: 0 }
|
||||
const FRAME_MS = 60
|
||||
const incrementFrame = (i: number) => i + 1
|
||||
const CLAWD_HEIGHT = 3
|
||||
|
||||
/**
|
||||
* Clawd with click-triggered animations (crouch-jump with arms up, or
|
||||
@@ -54,70 +48,49 @@ const CLAWD_HEIGHT = 3;
|
||||
* mouse tracking is enabled (i.e. inside `<AlternateScreen>` / fullscreen);
|
||||
* elsewhere this renders and behaves identically to plain `<Clawd />`.
|
||||
*/
|
||||
export function AnimatedClawd() {
|
||||
const $ = _c(8);
|
||||
const {
|
||||
pose,
|
||||
bounceOffset,
|
||||
onClick
|
||||
} = useClawdAnimation();
|
||||
let t0;
|
||||
if ($[0] !== pose) {
|
||||
t0 = <Clawd pose={pose} />;
|
||||
$[0] = pose;
|
||||
$[1] = t0;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
}
|
||||
let t1;
|
||||
if ($[2] !== bounceOffset || $[3] !== t0) {
|
||||
t1 = <Box marginTop={bounceOffset} flexShrink={0}>{t0}</Box>;
|
||||
$[2] = bounceOffset;
|
||||
$[3] = t0;
|
||||
$[4] = t1;
|
||||
} else {
|
||||
t1 = $[4];
|
||||
}
|
||||
let t2;
|
||||
if ($[5] !== onClick || $[6] !== t1) {
|
||||
t2 = <Box height={CLAWD_HEIGHT} flexDirection="column" onClick={onClick}>{t1}</Box>;
|
||||
$[5] = onClick;
|
||||
$[6] = t1;
|
||||
$[7] = t2;
|
||||
} else {
|
||||
t2 = $[7];
|
||||
}
|
||||
return t2;
|
||||
export function AnimatedClawd(): React.ReactNode {
|
||||
const { pose, bounceOffset, onClick } = useClawdAnimation()
|
||||
return (
|
||||
<Box height={CLAWD_HEIGHT} flexDirection="column" onClick={onClick}>
|
||||
<Box marginTop={bounceOffset} flexShrink={0}>
|
||||
<Clawd pose={pose} />
|
||||
</Box>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
function useClawdAnimation(): {
|
||||
pose: ClawdPose;
|
||||
bounceOffset: number;
|
||||
onClick: () => void;
|
||||
pose: ClawdPose
|
||||
bounceOffset: number
|
||||
onClick: () => void
|
||||
} {
|
||||
// Read once at mount — no useSettings() subscription, since that would
|
||||
// re-render on any settings change.
|
||||
const [reducedMotion] = useState(() => getInitialSettings().prefersReducedMotion ?? false);
|
||||
const [frameIndex, setFrameIndex] = useState(-1);
|
||||
const sequenceRef = useRef<readonly Frame[]>(JUMP_WAVE);
|
||||
const [reducedMotion] = useState(
|
||||
() => getInitialSettings().prefersReducedMotion ?? false,
|
||||
)
|
||||
const [frameIndex, setFrameIndex] = useState(-1)
|
||||
const sequenceRef = useRef<readonly Frame[]>(JUMP_WAVE)
|
||||
|
||||
const onClick = () => {
|
||||
if (reducedMotion || frameIndex !== -1) return;
|
||||
sequenceRef.current = CLICK_ANIMATIONS[Math.floor(Math.random() * CLICK_ANIMATIONS.length)]!;
|
||||
setFrameIndex(0);
|
||||
};
|
||||
if (reducedMotion || frameIndex !== -1) return
|
||||
sequenceRef.current =
|
||||
CLICK_ANIMATIONS[Math.floor(Math.random() * CLICK_ANIMATIONS.length)]!
|
||||
setFrameIndex(0)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (frameIndex === -1) return;
|
||||
if (frameIndex === -1) return
|
||||
if (frameIndex >= sequenceRef.current.length) {
|
||||
setFrameIndex(-1);
|
||||
return;
|
||||
setFrameIndex(-1)
|
||||
return
|
||||
}
|
||||
const timer = setTimeout(setFrameIndex, FRAME_MS, incrementFrame);
|
||||
return () => clearTimeout(timer);
|
||||
}, [frameIndex]);
|
||||
const seq = sequenceRef.current;
|
||||
const current = frameIndex >= 0 && frameIndex < seq.length ? seq[frameIndex]! : IDLE;
|
||||
return {
|
||||
pose: current.pose,
|
||||
bounceOffset: current.offset,
|
||||
onClick
|
||||
};
|
||||
const timer = setTimeout(setFrameIndex, FRAME_MS, incrementFrame)
|
||||
return () => clearTimeout(timer)
|
||||
}, [frameIndex])
|
||||
|
||||
const seq = sequenceRef.current
|
||||
const current =
|
||||
frameIndex >= 0 && frameIndex < seq.length ? seq[frameIndex]! : IDLE
|
||||
return { pose: current.pose, bounceOffset: current.offset, onClick }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user