feat: save group selected

This commit is contained in:
hamster1963
2025-01-03 10:00:07 +08:00
parent 1e2c271dc8
commit 2f02123787
3 changed files with 39 additions and 5 deletions

View File

@@ -37,6 +37,13 @@ export default function GroupSwitch({
}
}, [])
useEffect(() => {
const savedGroup = sessionStorage.getItem("selectedGroup")
if (savedGroup && tabs.includes(savedGroup)) {
setCurrentTab(savedGroup)
}
}, [tabs, setCurrentTab])
useEffect(() => {
const currentTagRef = tagRefs.current[tabs.indexOf(currentTab)]

View File

@@ -60,7 +60,13 @@ function Header() {
return (
<div className="mx-auto w-full max-w-5xl">
<section className="flex items-center justify-between header-top">
<section onClick={() => navigate("/")} className="cursor-pointer flex items-center sm:text-base text-sm font-medium">
<section
onClick={() => {
sessionStorage.removeItem("selectedGroup")
navigate("/")
}}
className="cursor-pointer flex items-center sm:text-base text-sm font-medium"
>
<div className="mr-1 flex flex-row items-center justify-start header-logo">
<img
width={40}