fix(fetch): fix

This commit is contained in:
zhangheng
2026-03-16 17:08:57 +08:00
parent 37ecb4641b
commit a55a0bfbc5
7 changed files with 103 additions and 101 deletions

View File

@@ -1,6 +1,4 @@
"use client"
import { getName } from "@tauri-apps/api/app"
import { getCurrentWindow } from "@tauri-apps/api/window"
import { usePathname } from "next/navigation"
import { useEffect } from "react"
import { getProjectAdminList } from "./api/project"
@@ -12,16 +10,16 @@ import {
} from "./store/auth"
export function OptStore() {
const detectEnvironment = async () => {
try {
const result = await getName()
console.log("Running in Tauri environment", result)
return true
} catch {
console.log("Not running in Tauri environment")
return false
}
}
// const detectEnvironment = async () => {
// try {
// const result = await getName()
// console.log("Running in Tauri environment", result)
// return true
// } catch {
// console.log("Not running in Tauri environment")
// return false
// }
// }
const user_id = usePermissionStore.getState().user_id
const { needUpdate, setUserOpts, setTreeData, setAdminOpts, setFlag } =
useAllUserStore()
@@ -93,22 +91,22 @@ export function OptStore() {
}
}, [pathname])
// tauri://close-requested
useEffect(() => {
;(async () => {
if (await detectEnvironment()) {
const window = getCurrentWindow()
const unlisten = await window.onCloseRequested(async (_event) => {
usePermissionStore.getState().logout()
// event.preventDefault();
})
// // tauri://close-requested
// useEffect(() => {
// ;(async () => {
// if (await detectEnvironment()) {
// const window = getCurrentWindow()
// const unlisten = await window.onCloseRequested(async (_event) => {
// usePermissionStore.getState().logout()
// // event.preventDefault();
// })
return () => {
unlisten()
}
}
})()
}, [])
// return () => {
// unlisten()
// }
// }
// })()
// }, [])
return <></>
}