fix: back to last location
Signed-off-by: Innei <i@innei.in>
This commit is contained in:
parent
51db2dc263
commit
15f702289a
|
|
@ -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" />
|
||||
|
|
|
|||
|
|
@ -64,5 +64,6 @@ export const StableRouterProvider = () => {
|
|||
})
|
||||
}
|
||||
}, [location, searchParams])
|
||||
|
||||
return null
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue