feat: persist sidebar state

This commit is contained in:
juancwu 2026-04-12 16:15:22 +00:00
commit de0e87cd71
4 changed files with 36 additions and 2 deletions

View file

@ -13,7 +13,8 @@ const (
URLPathKey string = "url_path"
ConfigKey string = "config"
CSRFTokenKey string = "csrf_token"
AppVersionKey string = "app_version"
AppVersionKey string = "app_version"
SidebarCollapsedKey string = "sidebar_collapsed"
)
func User(ctx context.Context) *model.User {
@ -61,3 +62,12 @@ func AppVersion(ctx context.Context) string {
func WithAppVersion(ctx context.Context, version string) context.Context {
return context.WithValue(ctx, AppVersionKey, version)
}
func SidebarCollapsed(ctx context.Context) bool {
collapsed, _ := ctx.Value(SidebarCollapsedKey).(bool)
return collapsed
}
func WithSidebarCollapsed(ctx context.Context, collapsed bool) context.Context {
return context.WithValue(ctx, SidebarCollapsedKey, collapsed)
}