Skip to content

Commit 05b25d2

Browse files
committed
移除路由上下文的方式传递应用程序状态,因为会导致界面刷新。
1 parent 8a2c44c commit 05b25d2

6 files changed

Lines changed: 120 additions & 49 deletions

File tree

bun.lock

Lines changed: 51 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
"preview": "vite preview"
88
},
99
"devDependencies": {
10-
"@iconify/json": "2.2.389",
10+
"@iconify/json": "2.2.390",
1111
"@iconify/tailwind4": "1.0.6",
1212
"@tailwindcss/vite": "4.1.13",
13-
"@tanstack/router-plugin": "1.132.23",
13+
"@tanstack/router-plugin": "1.132.25",
1414
"@tauri-apps/cli": "2.8.4",
15-
"@types/node": "24.5.2",
15+
"@types/node": "24.6.0",
1616
"@vitejs/plugin-react": "5.0.4",
1717
"rollup-plugin-visualizer": "6.0.3",
1818
"tailwindcss": "4.1.13",
1919
"tw-animate-css": "1.4.0",
2020
"typescript": "5.9.2",
21-
"vite": "npm:rolldown-vite@7.1.13",
21+
"vite": "npm:rolldown-vite@7.1.14",
2222
"vite-plugin-wasm": "3.5.0"
2323
},
2424
"dependencies": {
@@ -30,8 +30,8 @@
3030
"@radix-ui/react-select": "2.2.6",
3131
"@radix-ui/react-slot": "1.2.3",
3232
"@radix-ui/react-tabs": "1.1.13",
33-
"@tanstack/react-router": "1.132.23",
34-
"@tanstack/react-router-devtools": "1.132.23",
33+
"@tanstack/react-router": "1.132.25",
34+
"@tanstack/react-router-devtools": "1.132.25",
3535
"@tauri-apps/api": "2.8.0",
3636
"@tauri-apps/plugin-os": "2.3.1",
3737
"@zhangxichang/network": "file:network/pkg",

src/routes/window/app.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
import { createFileRoute, Navigate, Outlet } from "@tanstack/react-router"
21
import { Database } from "@/lib/database"
2+
import { createFileRoute, Navigate, Outlet } from "@tanstack/react-router"
3+
4+
declare global {
5+
var database: Database | null
6+
}
37

48
export const Route = createFileRoute("/window/app")({
59
component: () => <>
610
<Outlet />
711
<Navigate to="/window/app/login" />
812
</>,
913
pendingComponent: PendingComponent,
10-
beforeLoad: async () => ({
11-
database: await Database.new()
12-
}),
14+
loader: async () => {
15+
if (!window.database) window.database = await Database.new();
16+
}
1317
})
1418

1519
function PendingComponent() {

0 commit comments

Comments
 (0)