Files
page-agent/packages/website/src/pages/docs/introduction/quick-start/page.tsx
T

130 lines
4.5 KiB
TypeScript
Raw Normal View History

2025-12-01 20:11:12 +08:00
import CodeEditor from '@/components/CodeEditor'
2026-02-27 19:46:44 +08:00
import { Heading } from '@/components/Heading'
2026-01-14 17:27:35 +08:00
import { CDN_DEMO_CN_URL, CDN_DEMO_URL } from '@/constants'
2026-01-30 16:47:23 +08:00
import { useLanguage } from '@/i18n/context'
2025-12-01 20:11:12 +08:00
2025-09-29 16:33:15 +08:00
export default function QuickStart() {
2026-01-30 16:47:23 +08:00
const { isZh } = useLanguage()
2025-10-22 22:35:25 +08:00
2025-09-29 16:33:15 +08:00
return (
<div>
2026-01-30 15:13:31 +08:00
<h1 className="text-4xl font-bold mb-6">Quick Start</h1>
2025-09-29 16:33:15 +08:00
2026-01-30 15:13:31 +08:00
<p className=" mb-6 leading-relaxed">
{isZh ? '几分钟内完成 page-agent 的集成。' : 'Integrate page-agent in minutes.'}
</p>
2025-09-29 16:33:15 +08:00
2026-02-27 20:36:00 +08:00
<Heading id="installation-steps" className="text-2xl font-bold mb-3">
2026-02-27 19:46:44 +08:00
{isZh ? '安装步骤' : 'Installation Steps'}
</Heading>
2025-09-29 16:33:15 +08:00
<div className="space-y-4 mb-6">
2026-01-14 17:27:35 +08:00
{/* Demo CDN - One Line */}
2025-09-29 16:33:15 +08:00
<div className="p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg">
<h3 className="text-lg font-semibold mb-2 text-blue-900 dark:text-blue-300">
2026-01-14 17:27:35 +08:00
{isZh ? '🚀 快速体验(Demo CDN' : '🚀 Quick Try (Demo CDN)'}
2025-09-29 16:33:15 +08:00
</h3>
2026-01-14 17:27:35 +08:00
<div className="bg-yellow-50 dark:bg-yellow-900/20 p-2 rounded mb-3 text-sm">
<span className="text-yellow-800 dark:text-yellow-200">
2026-02-27 17:09:54 +08:00
⚠️{' '}
{isZh ? (
<>
Demo CDN 使用了免费的测试 LLM API,使用即表示您同意其
<a
href="https://github.com/alibaba/page-agent/blob/main/docs/terms-and-privacy.md#2-testing-api-and-demo-disclaimer--terms-of-use"
target="_blank"
rel="noopener noreferrer"
className="underline"
>
使用条款
</a>
</>
) : (
<>
This demo CDN uses our free testing LLM API. By using it you agree to the{' '}
<a
href="https://github.com/alibaba/page-agent/blob/main/docs/terms-and-privacy.md#2-testing-api-and-demo-disclaimer--terms-of-use"
target="_blank"
rel="noopener noreferrer"
className="underline"
>
Terms of Use
</a>
</>
)}
2026-01-14 17:27:35 +08:00
</span>
2025-09-29 16:33:15 +08:00
</div>
2026-01-14 17:27:35 +08:00
<CodeEditor
2026-01-30 16:34:27 +08:00
code={`<script src="DEMO_CDN_URL" crossorigin="true"></script>`}
2026-01-14 17:27:35 +08:00
language="html"
/>
2026-01-19 19:31:07 +08:00
<table className="w-full border-collapse text-sm">
<thead>
<tr className="border-b border-gray-200 dark:border-gray-700">
<th className="text-left py-2 px-3 font-semibold w-28">
{isZh ? '镜像' : 'Mirrors'}
</th>
<th className="text-left py-2 px-3 font-semibold">URL</th>
</tr>
</thead>
<tbody>
<tr className="border-b border-gray-100 dark:border-gray-800">
<td className="py-2 px-3">{isZh ? '全球' : 'Global'}</td>
<td className="py-2 px-3 font-mono text-xs break-all">{CDN_DEMO_URL}</td>
</tr>
<tr>
<td className="py-2 px-3">{isZh ? '中国' : 'China'}</td>
<td className="py-2 px-3 font-mono text-xs break-all">{CDN_DEMO_CN_URL}</td>
</tr>
</tbody>
</table>
2025-09-29 16:33:15 +08:00
</div>
2026-01-14 17:27:35 +08:00
{/* NPM - Recommended */}
2025-09-29 16:33:15 +08:00
<div className="p-4 bg-green-50 dark:bg-green-900/20 rounded-lg">
<h3 className="text-lg font-semibold mb-2 text-green-900 dark:text-green-300">
2026-01-14 17:27:35 +08:00
{isZh ? '📦 NPM 安装(推荐)' : '📦 NPM Install (Recommended)'}
2025-09-29 16:33:15 +08:00
</h3>
<CodeEditor
2026-01-19 19:31:07 +08:00
code={`// npm install page-agent
2026-01-14 17:27:35 +08:00
import { PageAgent } from 'page-agent'`}
language="bash"
2025-09-29 16:33:15 +08:00
/>
</div>
<div className="p-4 bg-purple-50 dark:bg-purple-900/20 rounded-lg">
<h3 className="text-lg font-semibold mb-2 text-purple-900 dark:text-purple-300">
2026-01-30 15:13:31 +08:00
{isZh ? '2. 初始化配置' : '2. Initialize Configuration'}
2026-01-14 17:27:35 +08:00
</h3>
<CodeEditor
code={`const agent = new PageAgent({
model: 'qwen3.5-plus',
baseURL: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
2026-01-14 17:27:35 +08:00
apiKey: 'YOUR_API_KEY',
language: '${isZh ? 'zh-CN' : 'en-US'}'
})`}
language="javascript"
/>
</div>
<div className="p-4 bg-orange-50 dark:bg-orange-900/20 rounded-lg">
<h3 className="text-lg font-semibold mb-2 text-orange-900 dark:text-orange-300">
2026-01-30 15:13:31 +08:00
{isZh ? '3. 开始使用' : '3. Start Using'}
2025-09-29 16:33:15 +08:00
</h3>
<CodeEditor
2026-01-14 17:27:35 +08:00
code={`// ${isZh ? '程序化执行自然语言指令' : 'Execute natural language instructions programmatically'}
await agent.execute('${isZh ? '点击提交按钮,然后填写用户名为张三' : 'Click submit button, then fill username as John'}');
2025-09-29 16:33:15 +08:00
2026-01-19 19:31:07 +08:00
// ${isZh ? '或者' : 'Or:'}
// ${isZh ? '显示对话框让用户输入指令' : 'Show panel for user to input instructions'}
2026-01-14 17:27:35 +08:00
agent.panel.show()
2025-09-29 16:33:15 +08:00
`}
language="javascript"
/>
</div>
</div>
</div>
)
}