chore(website): optimize bundle size

This commit is contained in:
Simon
2026-01-16 15:05:09 +08:00
parent c8bf0dd20f
commit 41123ac561
3 changed files with 129 additions and 132 deletions

View File

@@ -1,6 +1,5 @@
/* eslint-disable react-dom/no-dangerously-set-innerhtml */
import { Bot, Box, MessageSquare, PlayCircle, Shield, Sparkles, Users, Zap } from 'lucide-react'
import { PageAgent } from 'page-agent'
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Link, useSearchParams } from 'wouter'
@@ -59,13 +58,12 @@ export default function HomePage() {
const handleExecute = async () => {
if (!task.trim()) return
let pageAgent: PageAgent
const win = window as any
if (win.pageAgent && !win.pageAgent.disposed) {
pageAgent = win.pageAgent
} else {
pageAgent = new PageAgent({
// Lazy load PageAgent only when user clicks execute
if (!win.pageAgent || win.pageAgent.disposed) {
const { PageAgent } = await import('page-agent')
win.pageAgent = new PageAgent({
// 把 react 根元素排除掉,挂了很多冒泡时间导致假阳
interactiveBlacklist: [document.getElementById('root')!],
language: i18n.language as any,
@@ -92,11 +90,9 @@ export default function HomePage() {
? import.meta.env.LLM_API_KEY
: DEMO_API_KEY,
})
win.pageAgent = pageAgent
}
const result = await pageAgent.execute(task)
const result = await win.pageAgent.execute(task)
console.log(result)
}