fix: back to last location

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei 2024-07-24 16:37:41 +08:00
parent 51db2dc263
commit 15f702289a
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
2 changed files with 14 additions and 1 deletions

View File

@ -1,12 +1,24 @@
import { getReadonlyRoute } from "@renderer/atoms/route"
import {
getSidebarActiveView,
setSidebarActiveView,
} from "@renderer/atoms/sidebar"
import { MotionButtonBase } from "@renderer/components/ui/button"
import { useRef } from "react"
import { Outlet, useNavigate } from "react-router-dom"
export function Component() {
const navigate = useNavigate()
const prevLocation = useRef(getReadonlyRoute().location).current
const prevView = useRef(getSidebarActiveView()).current
return (
<div className="relative flex size-full">
<MotionButtonBase
onClick={() => navigate("/")}
onClick={() => {
navigate(prevLocation)
setSidebarActiveView(prevView)
}}
className="absolute left-10 top-11 flex items-center gap-1"
>
<i className="i-mgc-left-cute-fi" />

View File

@ -64,5 +64,6 @@ export const StableRouterProvider = () => {
})
}
}, [location, searchParams])
return null
}