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

102 lines
3.5 KiB
TypeScript
Raw Normal View History

2025-10-22 22:35:25 +08:00
import { useTranslation } from 'react-i18next'
2025-09-29 16:33:15 +08:00
2025-12-01 20:11:12 +08:00
import CodeEditor from '@/components/CodeEditor'
2026-01-14 17:27:35 +08:00
import { CDN_DEMO_CN_URL, CDN_DEMO_URL } from '@/constants'
2025-12-01 20:11:12 +08:00
2025-09-29 16:33:15 +08:00
export default function QuickStart() {
2026-01-14 17:27:35 +08:00
const { t, i18n } = useTranslation('docs')
const isZh = i18n.language === 'zh-CN'
2025-10-22 22:35:25 +08:00
2025-09-29 16:33:15 +08:00
return (
<div>
2025-10-22 22:35:25 +08:00
<h1 className="text-4xl font-bold mb-6">{t('quick_start.title')}</h1>
2025-09-29 16:33:15 +08:00
2025-10-22 22:35:25 +08:00
<p className=" mb-6 leading-relaxed">{t('quick_start.subtitle')}</p>
2025-09-29 16:33:15 +08:00
2025-10-22 22:35:25 +08:00
<h2 className="text-2xl font-bold mb-3">{t('quick_start.installation')}</h2>
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">
⚠️ {isZh ? '仅用于技术评估' : 'For evaluation only'}
</span>
2025-09-29 16:33:15 +08:00
</div>
2026-01-14 17:27:35 +08:00
<CodeEditor
2026-01-19 19:31:07 +08:00
code={`<script src="${isZh ? CDN_DEMO_CN_URL : CDN_DEMO_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-14 17:27:35 +08:00
{t('quick_start.step2_title')}
</h3>
<CodeEditor
code={`const agent = new PageAgent({
model: 'deepseek-chat',
baseURL: 'https://api.deepseek.com',
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">
2025-10-22 22:35:25 +08:00
{t('quick_start.step3_title')}
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>
)
}