侧边栏状态持久化存储

This commit is contained in:
Wenjie Zhang 2025-02-25 14:46:20 +08:00
parent 246a3aa875
commit d8f2f8490d

View File

@ -41,9 +41,16 @@ const convs = reactive(JSON.parse(localStorage.getItem('chat-convs')) || [
])
const state = reactive({
isSidebarOpen: true,
isSidebarOpen: JSON.parse(localStorage.getItem('chat-sidebar-open') || 'true'),
})
// Watch isSidebarOpen and save to localStorage
watch(
() => state.isSidebarOpen,
(newValue) => {
localStorage.setItem('chat-sidebar-open', JSON.stringify(newValue))
}
)
const curConvId = ref(0)
const generateRandomHash = (length) => {