|
@@ -1,9 +1,10 @@
|
|
|
-import React, { useEffect, useState } from "react";
|
|
|
+import React, { useEffect, useRef, useState } from "react";
|
|
|
import { useSearchParams } from "react-router-dom";
|
|
|
import "./home.scss";
|
|
|
|
|
|
const HomePage: React.FC = () => {
|
|
|
const [searchParams] = useSearchParams();
|
|
|
+ const [key, setKey] = useState(0);
|
|
|
const [path, setPath] = useState(() => {
|
|
|
// 优先使用 URL 参数
|
|
|
return (
|
|
@@ -18,13 +19,18 @@ const HomePage: React.FC = () => {
|
|
|
(result: { type: string; data: string }) => {
|
|
|
const { data } = result;
|
|
|
setPath(data);
|
|
|
+ setKey(key + 1);
|
|
|
}
|
|
|
);
|
|
|
- }, []);
|
|
|
+ return () => {
|
|
|
+ window["electronAPI"].removeAllListeners("iframe");
|
|
|
+ };
|
|
|
+ }, [key]);
|
|
|
|
|
|
return (
|
|
|
<div className="home">
|
|
|
<webview
|
|
|
+ key={key}
|
|
|
id="webview"
|
|
|
allow-popups="true"
|
|
|
allow-scripts="true"
|