refactor: show after render

main
imspace 2023-03-04 19:19:24 +08:00
parent 586df102a9
commit abb46979da
6 changed files with 49 additions and 18 deletions

View File

@ -1,14 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="/src/main.css" rel="stylesheet" />
<title>Tauri + React + TS</title>
</head>
<body>
<div id="root">
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024"
class="animate-spin my-2 mx-auto" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">
<path
d="M512 1024c-69.1 0-136.2-13.5-199.3-40.2C251.7 958 197 921 150 874c-47-47-84-101.7-109.8-162.7C13.5 648.2 0 581.1 0 512c0-19.9 16.1-36 36-36s36 16.1 36 36c0 59.4 11.6 117 34.6 171.3 22.2 52.4 53.9 99.5 94.3 139.9 40.4 40.4 87.5 72.2 139.9 94.3C395 940.4 452.6 952 512 952c59.4 0 117-11.6 171.3-34.6 52.4-22.2 99.5-53.9 139.9-94.3 40.4-40.4 72.2-87.5 94.3-139.9C940.4 629 952 571.4 952 512c0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 0 0-94.3-139.9 437.71 437.71 0 0 0-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.2C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3s-13.5 136.2-40.2 199.3C958 772.3 921 827 874 874c-47 47-101.8 83.9-162.7 109.7-63.1 26.8-130.2 40.3-199.3 40.3z">
</path>
</svg>
</div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

View File

@ -13,7 +13,7 @@ edition = "2021"
tauri-build = { version = "1.2", features = [] }
[dependencies]
tauri = { version = "1.2", features = ["shell-open", "shell-sidecar"] }
tauri = { version = "1.2", features = ["shell-open", "shell-sidecar", "window-all"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

View File

@ -26,6 +26,16 @@
],
"all": false,
"open": true
},
"window": {
"all": true
},
"fs": {
"scope": [
"$APPCONFIG",
"$APPDATA",
"$APPCACHE"
]
}
},
"bundle": {
@ -55,7 +65,8 @@
"resizable": true,
"title": "s3si.ts",
"width": 800,
"height": 600
"height": 600,
"visible": false
}
]
}

View File

@ -1,11 +1,13 @@
import {
} from "@tauri-apps/api/window";
import { getCurrent } from "@tauri-apps/api/window";
import { Routes, Route } from "react-router-dom";
import { Layout } from "components/Layout";
import { Home } from "pages/Home";
import { useEffect } from "react";
function App() {
useEffect(() => {
getCurrent().show()
}, [])
return (
<Routes>
<Route path='/' element={<Layout />}>

View File

@ -2,7 +2,6 @@ import React from "react";
import ReactDOM from "react-dom/client";
import { BrowserRouter } from "react-router-dom";
import App from "./App";
import "./main.css";
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
@ -11,3 +10,4 @@ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
</BrowserRouter>
</React.StrictMode>
);

View File

@ -1,8 +1,17 @@
import { WebviewWindow } from '@tauri-apps/api/window'
import { Loading } from 'components/Loading'
import React from 'react'
export const Home: React.FC = ({ }) => {
const onClick = () => {
const webview = new WebviewWindow('theUniqueLabel', {
url: 'https://accounts.nintendo.com/',
resizable: false,
focus: true,
})
};
return <>
Hello world! <Loading />
<button onClick={onClick}>Open the window!</button>
</>
}
}