home.tsx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import React, { useEffect, useState } from "react";
  2. import { useSearchParams } from "react-router-dom";
  3. import "./home.scss";
  4. const HomePage: React.FC = () => {
  5. const [searchParams] = useSearchParams();
  6. const [path, setPath] = useState(() => {
  7. // 优先使用 URL 参数
  8. return (
  9. searchParams.get("iframePath") ||
  10. "http://106.225.184.197:8686/#/CDSSPages"
  11. );
  12. });
  13. useEffect(() => {
  14. window["electronAPI"].on(
  15. "iframe",
  16. (result: { type: string; data: string }) => {
  17. const { data } = result;
  18. setPath(data);
  19. }
  20. );
  21. }, []);
  22. return (
  23. <div className="home">
  24. <webview
  25. id="webview"
  26. allow-popups="true"
  27. allow-scripts="true"
  28. src={path}
  29. style={{ border: "none", width: "100%", height: "100%" }}
  30. ></webview>
  31. {/* <iframe
  32. src={path}
  33. style={{ border: "none" }}
  34. width={"100%"}
  35. height={"100%"}
  36. allowFullScreen
  37. /> */}
  38. </div>
  39. );
  40. };
  41. export default HomePage;