diff --git a/packages/website/src/components/Heading.tsx b/packages/website/src/components/Heading.tsx index 3a43661..29b0e91 100644 --- a/packages/website/src/components/Heading.tsx +++ b/packages/website/src/components/Heading.tsx @@ -6,15 +6,18 @@ type Level = 2 | 3 interface HeadingProps extends Omit, 'children'> { id: string - level: Level + level?: Level children: React.ReactNode } -const tags = { 2: 'h2', 3: 'h3' } as const +const levelStyles = { + 2: { tag: 'h2', className: 'text-2xl font-semibold mb-4' }, + 3: { tag: 'h3', className: 'text-xl font-semibold mb-3' }, +} as const -export function Heading({ id, level, className, children, ...props }: HeadingProps) { +export function Heading({ id, level = 2, className, children, ...props }: HeadingProps) { const ref = useRef(null) - const Tag = tags[level] + const { tag: Tag, className: defaultClassName } = levelStyles[level] useEffect(() => { if (window.location.hash === `#${id}`) { @@ -23,7 +26,12 @@ export function Heading({ id, level, className, children, ...props }: HeadingPro }, [id]) return ( - + - - {isZh ? '架构' : 'Architecture'} - + {isZh ? '架构' : 'Architecture'}

{isZh ? 'PageAgent 由三个独立模块组成,可自由组合:' @@ -48,9 +46,7 @@ export default function CustomUIDocs() { {/* Two Event Streams */}

- - {isZh ? '两个事件流' : 'Two Event Streams'} - + {isZh ? '两个事件流' : 'Two Event Streams'}

{isZh ? 'PageAgentCore 提供两种不同性质的事件流,方便 UI 渲染:' @@ -125,9 +121,7 @@ export default function CustomUIDocs() { {/* All Events */}

- - {isZh ? '所有事件' : 'All Events'} - + {isZh ? '所有事件' : 'All Events'} - - HistoricalEvent - + HistoricalEvent

{isZh ? 'agent.history 数组中的事件类型:' : 'Event types in agent.history array:'}

@@ -181,9 +173,7 @@ export default function CustomUIDocs() { {/* AgentActivity Types */}
- - AgentActivity - + AgentActivity

{isZh ? 'activity 事件的 detail 类型:' : 'The detail type of activity events:'}

@@ -202,9 +192,7 @@ export default function CustomUIDocs() { {/* React Hooks Example */}
- - {isZh ? '使用 React Hooks' : 'Using React Hooks'} - + {isZh ? '使用 React Hooks' : 'Using React Hooks'}

{isZh ? '监听事件并更新 React 状态:' : 'Listen to events and update React state:'}

@@ -240,11 +228,7 @@ export default function CustomUIDocs() { {/* Assembly Example */}
- + {isZh ? '组装 Core + Controller + 自定义 UI' : 'Assembling Core + Controller + Custom UI'}

diff --git a/packages/website/src/pages/docs/advanced/page-agent-core/page.tsx b/packages/website/src/pages/docs/advanced/page-agent-core/page.tsx index 38ae5b1..9476041 100644 --- a/packages/website/src/pages/docs/advanced/page-agent-core/page.tsx +++ b/packages/website/src/pages/docs/advanced/page-agent-core/page.tsx @@ -18,7 +18,7 @@ export default function PageAgentCoreDocs() { {/* When to use */}

- + {isZh ? '何时使用 PageAgentCore' : 'When to Use PageAgentCore'}
    @@ -39,9 +39,7 @@ export default function PageAgentCoreDocs() { {/* Basic Usage */}
    - - {isZh ? '基本用法' : 'Basic Usage'} - + {isZh ? '基本用法' : 'Basic Usage'} - - LLMConfig - + LLMConfig

    {isZh ? '配置与大语言模型的连接参数。支持 OpenAI 兼容的 API。' @@ -138,9 +134,7 @@ const result = await agent.execute('Fill in the form with test data')`} {/* Agent Configuration */}

    - - AgentConfig - + AgentConfig

    {isZh ? '配置 Agent 的行为、生命周期钩子和扩展能力。' @@ -217,9 +211,7 @@ const result = await agent.execute('Fill in the form with test data')`} {/* Lifecycle Hooks */}

    - - {isZh ? '生命周期钩子' : 'Lifecycle Hooks'} - + {isZh ? '生命周期钩子' : 'Lifecycle Hooks'}

    ⚠️ {isZh ? '警告' : 'Warning'}:{' '} @@ -271,9 +263,7 @@ const result = await agent.execute('Fill in the form with test data')`} {/* PageController Configuration */}

    - - PageControllerConfig - + PageControllerConfig

    {isZh ? '配置 DOM 提取、元素交互和视觉反馈。' @@ -332,9 +322,7 @@ const result = await agent.execute('Fill in the form with test data')`} {/* Properties */}

    - - {isZh ? '属性' : 'Properties'} - + {isZh ? '属性' : 'Properties'} - - {isZh ? '方法' : 'Methods'} - + {isZh ? '方法' : 'Methods'} - - {isZh ? '事件' : 'Events'} - + {isZh ? '事件' : 'Events'}

    {isZh ? ( <> @@ -455,9 +439,7 @@ const result = await agent.execute('Fill in the form with test data')`} {/* ExecutionResult */}

    - - ExecutionResult - + ExecutionResult - - AgentActivity - + AgentActivity - - {isZh ? '无头模式' : 'Headless Mode'} - + {isZh ? '无头模式' : 'Headless Mode'}

    {isZh ? '在非 DOM 环境中,你必须实现自定义的 PageController(例如远程操作页面或 Puppeteer)。' diff --git a/packages/website/src/pages/docs/advanced/page-agent/page.tsx b/packages/website/src/pages/docs/advanced/page-agent/page.tsx index 1d916d0..3704346 100644 --- a/packages/website/src/pages/docs/advanced/page-agent/page.tsx +++ b/packages/website/src/pages/docs/advanced/page-agent/page.tsx @@ -20,7 +20,7 @@ export default function PageAgentDocs() { {/* When to use */}

    - + {isZh ? '何时使用 PageAgent' : 'When to Use PageAgent'}

    @@ -44,9 +44,7 @@ export default function PageAgentDocs() { {/* Basic Usage */}

    - - {isZh ? '基本用法' : 'Basic Usage'} - + {isZh ? '基本用法' : 'Basic Usage'} - - {isZh ? '类定义' : 'Class Definition'} - + {isZh ? '类定义' : 'Class Definition'} - - {isZh ? '配置' : 'Configuration'} - + {isZh ? '配置' : 'Configuration'}

    {isZh ? 'PageAgent 使用与 PageAgentCore 相同的配置接口。' @@ -151,9 +145,7 @@ console.log(result.history) // Full execution history`} {/* Panel Property */}

    - - {isZh ? 'Panel 属性' : 'Panel Property'} - + {isZh ? 'Panel 属性' : 'Panel Property'}

    {isZh ? 'PageAgent 自动创建一个 Panel 实例。你可以通过 panel 属性访问它来控制 UI:' @@ -194,7 +186,7 @@ agent.panel.dispose()`} {/* Comparison with PageAgentCore */}

    - + {isZh ? 'PageAgent vs PageAgentCore' : 'PageAgent vs PageAgentCore'}
    diff --git a/packages/website/src/pages/docs/features/chrome-extension/page.tsx b/packages/website/src/pages/docs/features/chrome-extension/page.tsx index 86e9315..cb39f7f 100644 --- a/packages/website/src/pages/docs/features/chrome-extension/page.tsx +++ b/packages/website/src/pages/docs/features/chrome-extension/page.tsx @@ -23,7 +23,7 @@ export default function ChromeExtension() {
    {/* Features */}
    - + {isZh ? '核心特性' : 'Key Features'}
    @@ -60,7 +60,7 @@ export default function ChromeExtension() { {/* Install */}
    - + {isZh ? '获取扩展' : 'Get the Extension'}
    @@ -91,11 +91,7 @@ export default function ChromeExtension() { {/* Relationship with PageAgent.js */}
    - + {isZh ? '与 PageAgent.js 的关系' : 'How It Relates to PageAgent.js'}
    @@ -114,7 +110,7 @@ export default function ChromeExtension() { {/* Third-party Integration */}
    - + {isZh ? '第三方接入' : 'Third-Party Integration'}

    @@ -154,7 +150,7 @@ localStorage.setItem('PageAgentExtUserAuthToken', '') {/* API Reference */}

    - + {isZh ? 'API 参考' : 'API Reference'} @@ -181,7 +177,7 @@ localStorage.setItem('PageAgentExtUserAuthToken', '')
    {/* TypeScript Declaration */} - + {isZh ? 'TypeScript 类型声明' : 'TypeScript Declaration'}

    @@ -317,7 +313,6 @@ window.PAGE_AGENT_EXT.stop()`

    {isZh diff --git a/packages/website/src/pages/docs/features/custom-instructions/page.tsx b/packages/website/src/pages/docs/features/custom-instructions/page.tsx index d9f27fa..2a95e4c 100644 --- a/packages/website/src/pages/docs/features/custom-instructions/page.tsx +++ b/packages/website/src/pages/docs/features/custom-instructions/page.tsx @@ -17,7 +17,7 @@ export default function Instructions() { {/* System Instructions */}
    - + {isZh ? '系统级指导 (System Instructions)' : 'System Instructions'} @@ -47,7 +47,7 @@ Guidelines: {/* Page Instructions */}
    - + {isZh ? '页面级指导 (Page Instructions)' : 'Page Instructions'} @@ -91,7 +91,7 @@ This is the product listing page. {/* How It Works */}
    - + {isZh ? '工作原理' : 'How It Works'} diff --git a/packages/website/src/pages/docs/features/custom-tools/page.tsx b/packages/website/src/pages/docs/features/custom-tools/page.tsx index d13fdc0..fbd44e4 100644 --- a/packages/website/src/pages/docs/features/custom-tools/page.tsx +++ b/packages/website/src/pages/docs/features/custom-tools/page.tsx @@ -18,7 +18,7 @@ export default function CustomTools() {
    - + {isZh ? '工具注册' : 'Tool Registration'}

    @@ -58,7 +58,7 @@ const pageAgent = new PageAgent({customTools})

    - + {isZh ? '页面过滤器' : 'Page Filter'} @@ -94,7 +94,7 @@ const pageAgent = new PageAgent({customTools})
    - + {isZh ? '最佳实践' : 'Best Practices'}
    diff --git a/packages/website/src/pages/docs/features/data-masking/page.tsx b/packages/website/src/pages/docs/features/data-masking/page.tsx index 9f119f7..68125bb 100644 --- a/packages/website/src/pages/docs/features/data-masking/page.tsx +++ b/packages/website/src/pages/docs/features/data-masking/page.tsx @@ -16,7 +16,7 @@ export default function DataMasking() {

    - + {isZh ? '接口定义' : 'API Definition'} @@ -33,7 +33,7 @@ export default function DataMasking() {
    - + {isZh ? '常用脱敏规则' : 'Common Masking Patterns'} diff --git a/packages/website/src/pages/docs/features/models/page.tsx b/packages/website/src/pages/docs/features/models/page.tsx index 3441956..b3819a1 100644 --- a/packages/website/src/pages/docs/features/models/page.tsx +++ b/packages/website/src/pages/docs/features/models/page.tsx @@ -64,7 +64,7 @@ export default function Models() { {/* Models Section */}
    - + {isZh ? '已测试模型' : 'Tested Models'}

    @@ -144,9 +144,7 @@ export default function Models() { {/* Configuration Section */}

    - - {isZh ? '配置方式' : 'Configuration'} - + {isZh ? '配置方式' : 'Configuration'} - - {isZh ? '免费测试接口' : 'Free Testing API'} - + {isZh ? '免费测试接口' : 'Free Testing API'}

    {isZh ? '以下免费测试接口仅供 PageAgent.js 和 PageAgent Extension 的技术评估使用。有速率限制,可能随时变更。请勿用于生产环境。' @@ -220,9 +216,7 @@ LLM_API_KEY="NA"`} {/* Ollama Section */}

    - - Ollama - + Ollama

    {isZh ? '已在 Ollama 0.15 + qwen3:14b (RTX3090 24GB) 上测试通过。' diff --git a/packages/website/src/pages/docs/integration/security-permissions/page.tsx b/packages/website/src/pages/docs/integration/security-permissions/page.tsx index 28a2138..ac7824f 100644 --- a/packages/website/src/pages/docs/integration/security-permissions/page.tsx +++ b/packages/website/src/pages/docs/integration/security-permissions/page.tsx @@ -19,11 +19,7 @@ export default function SecurityPermissions() {

    - + {isZh ? '元素操作黑白名单' : 'Element Interaction Allowlist/Blocklist'}
    @@ -51,11 +47,7 @@ export default function SecurityPermissions() {
    - + {isZh ? 'Instruction 安全约束' : 'Instruction Safety Constraints'}
    diff --git a/packages/website/src/pages/docs/integration/third-party-agent/page.tsx b/packages/website/src/pages/docs/integration/third-party-agent/page.tsx index 8f3d07b..797ef49 100644 --- a/packages/website/src/pages/docs/integration/third-party-agent/page.tsx +++ b/packages/website/src/pages/docs/integration/third-party-agent/page.tsx @@ -27,7 +27,7 @@ export default function ThirdPartyAgentPage() {

    - + {isZh ? '集成方式' : 'Integration Method'} @@ -60,7 +60,7 @@ const pageAgentTool = {
    - + {isZh ? '应用场景' : 'Use Cases'}
    diff --git a/packages/website/src/pages/docs/introduction/limitations/page.tsx b/packages/website/src/pages/docs/introduction/limitations/page.tsx index 05565b3..6323d21 100644 --- a/packages/website/src/pages/docs/introduction/limitations/page.tsx +++ b/packages/website/src/pages/docs/introduction/limitations/page.tsx @@ -21,7 +21,7 @@ export default function LimitationsPage() {
    {/* PageAgent.js vs PageAgentExt */} - + {isZh ? 'PageAgent.js vs PageAgentExt' : 'PageAgent.js vs PageAgentExt'}

    @@ -83,7 +83,7 @@ export default function LimitationsPage() {

    {/* Interaction Limitations */} - + {isZh ? '交互能力' : 'Interaction Capabilities'}
    @@ -128,7 +128,7 @@ export default function LimitationsPage() {
    {/* Understanding Limitations */} - + {isZh ? '理解能力' : 'Understanding'}
    @@ -145,7 +145,7 @@ export default function LimitationsPage() {
    {/* Website Quality */} - + {isZh ? '网页质量影响' : 'Page Quality Matters'}
    diff --git a/packages/website/src/pages/docs/introduction/overview/page.tsx b/packages/website/src/pages/docs/introduction/overview/page.tsx index e8c6f75..4ebe254 100644 --- a/packages/website/src/pages/docs/introduction/overview/page.tsx +++ b/packages/website/src/pages/docs/introduction/overview/page.tsx @@ -49,7 +49,7 @@ export default function Overview() {
    - + {isZh ? '什么是 page-agent?' : 'What is page-agent?'} @@ -61,7 +61,7 @@ export default function Overview() {
    - + {isZh ? '核心特性' : 'Core Features'} @@ -111,7 +111,7 @@ export default function Overview() {
    - + {isZh ? '与 browser-use 的区别' : 'vs. browser-use'} @@ -177,7 +177,7 @@ export default function Overview() {
    - + {isZh ? '应用场景' : 'Use Cases'} diff --git a/packages/website/src/pages/docs/introduction/quick-start/page.tsx b/packages/website/src/pages/docs/introduction/quick-start/page.tsx index 703b940..86fafc1 100644 --- a/packages/website/src/pages/docs/introduction/quick-start/page.tsx +++ b/packages/website/src/pages/docs/introduction/quick-start/page.tsx @@ -14,7 +14,7 @@ export default function QuickStart() { {isZh ? '几分钟内完成 page-agent 的集成。' : 'Integrate page-agent in minutes.'}

    - + {isZh ? '安装步骤' : 'Installation Steps'} diff --git a/packages/website/src/pages/docs/introduction/troubleshooting/page.tsx b/packages/website/src/pages/docs/introduction/troubleshooting/page.tsx index eb11c52..6487715 100644 --- a/packages/website/src/pages/docs/introduction/troubleshooting/page.tsx +++ b/packages/website/src/pages/docs/introduction/troubleshooting/page.tsx @@ -373,7 +373,6 @@ export default function TroubleshootingPage() {
    {isZh ? section.title.zh : section.title.en}