This commit is contained in:
rustmailer
2026-05-10 04:22:35 +08:00
parent c086a3caf5
commit 123260b69d
3 changed files with 3 additions and 8 deletions
+2 -4
View File
@@ -22,8 +22,7 @@ import {
TooltipTrigger,
} from '@/components/ui/tooltip'
const SIDEBAR_COOKIE_NAME = 'sidebar:state'
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
const SIDEBAR_COOKIE_NAME = 'sidebar_state'
const SIDEBAR_WIDTH = '14rem'
const SIDEBAR_WIDTH_MOBILE = '16rem'
const SIDEBAR_WIDTH_ICON = '3rem'
@@ -86,8 +85,7 @@ const SidebarProvider = React.forwardRef<
_setOpen(openState)
}
// This sets the cookie to keep the sidebar state.
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
localStorage.setItem(SIDEBAR_COOKIE_NAME, openState.toString());
},
[setOpenProp, open]
)
+1 -3
View File
@@ -16,8 +16,6 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import Cookies from 'js-cookie'
import { createFileRoute, Outlet } from '@tanstack/react-router'
import { cn } from '@/lib/utils'
import { SearchProvider } from '@/context/search-context'
@@ -29,7 +27,7 @@ export const Route = createFileRoute('/_authenticated')({
})
function RouteComponent() {
const defaultOpen = Cookies.get('sidebar:state') !== 'false'
const defaultOpen = localStorage.getItem('sidebar_state') === 'true';
return (
<SearchProvider>
<SidebarProvider defaultOpen={defaultOpen}>