mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-19 02:12:46 +08:00
feat: two dashboard persistence optimizations (#4221)
* feat: persist console visibility state in local storage on PlatformPage * feat: add persistence for sidebar opened items in local storage
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref, shallowRef, onMounted, onUnmounted } from 'vue';
|
||||
import { ref, shallowRef, onMounted, onUnmounted, watch } from 'vue';
|
||||
import { useCustomizerStore } from '../../../stores/customizer';
|
||||
import { useI18n } from '@/i18n/composables';
|
||||
import sidebarItems from './sidebarItem';
|
||||
@@ -12,6 +12,10 @@ const { t } = useI18n();
|
||||
const customizer = useCustomizerStore();
|
||||
const sidebarMenu = shallowRef(sidebarItems);
|
||||
|
||||
// 侧边栏分组展开状态持久化
|
||||
const openedItems = ref(JSON.parse(localStorage.getItem('sidebar_openedItems') || '[]'));
|
||||
watch(openedItems, (val) => localStorage.setItem('sidebar_openedItems', JSON.stringify(val)), { deep: true });
|
||||
|
||||
// Apply customization on mount and listen for storage changes
|
||||
const handleStorageChange = (e) => {
|
||||
if (e.key === 'astrbot_sidebar_customization') {
|
||||
@@ -243,7 +247,7 @@ function openChangelogDialog() {
|
||||
:rail="customizer.mini_sidebar"
|
||||
>
|
||||
<div class="sidebar-container">
|
||||
<v-list class="pa-4 listitem flex-grow-1">
|
||||
<v-list class="pa-4 listitem flex-grow-1" v-model:opened="openedItems" :open-strategy="'multiple'">
|
||||
<template v-for="(item, i) in sidebarMenu" :key="i">
|
||||
<NavItem :item="item" class="leftPadding" />
|
||||
</template>
|
||||
|
||||
@@ -230,7 +230,7 @@ export default {
|
||||
save_message: "",
|
||||
save_message_success: "success",
|
||||
|
||||
showConsole: false,
|
||||
showConsole: localStorage.getItem('platformPage_showConsole') === 'true',
|
||||
|
||||
showWebhookDialog: false,
|
||||
currentWebhookUuid: '',
|
||||
@@ -248,6 +248,10 @@ export default {
|
||||
},
|
||||
|
||||
watch: {
|
||||
showConsole(newValue) {
|
||||
localStorage.setItem('platformPage_showConsole', newValue.toString());
|
||||
},
|
||||
|
||||
showIdConflictDialog(newValue) {
|
||||
if (!newValue && this.idConflictResolve) {
|
||||
this.idConflictResolve(false);
|
||||
|
||||
Reference in New Issue
Block a user