feat(opencode): 将 iframe 替换为 webview 避免 Tauri 应用在 iframe 中卡死

This commit is contained in:
2026-03-14 23:56:02 +08:00
parent 3c353cb701
commit 18c02053da

View File

@@ -5,6 +5,7 @@ export const OpenCodePage: React.FC = () => {
const [port, setPort] = useState<number>(9999)
const startedRef = useRef(false)
const restartingRef = useRef(false)
const webviewRef = useRef<HTMLWebViewElement>(null)
useEffect(() => {
let mounted = true
@@ -72,10 +73,12 @@ export const OpenCodePage: React.FC = () => {
</div>
)}
{isHealthy && (
<iframe
<webview
ref={webviewRef}
src={`http://localhost:${port}`}
className="h-full w-full border-0"
title="XCOpenCodeWeb"
style={{ width: '100%', height: '100%', border: 'none' }}
allowpopups={true}
webpreferences="contextIsolation=no"
/>
)}
</div>