fix(fetch): fix
This commit is contained in:
@@ -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 <></>
|
||||
}
|
||||
|
||||
@@ -47,11 +47,18 @@ export const fetchFeishuLogin = (params: Login.ReqFeishuLogin) => {
|
||||
}
|
||||
|
||||
// 刷新token
|
||||
export const refreshKey = (params: { token: string }) => {
|
||||
return httpFetch<ResultData<Login.ResRefreshKey>>({
|
||||
// export const refreshKey = (params: { token: string }) => {
|
||||
// return httpFetch<ResultData<Login.ResRefreshKey>>({
|
||||
// url: BASE_PATH + `/api/v1/label_server/user/refresh_token`,
|
||||
// method: "POST",
|
||||
// data: params,
|
||||
// isRefresh: true,
|
||||
// })
|
||||
// }
|
||||
export const refreshKey = () => {
|
||||
return httpFetch<Login.ResRefreshKey>({
|
||||
url: BASE_PATH + `/api/v1/label_server/user/refresh_token`,
|
||||
method: "POST",
|
||||
body: JSON.stringify(params),
|
||||
method: "GET",
|
||||
isRefresh: true,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user