import { defineStore } from 'pinia' import { ref } from 'vue' export const useAppStore = defineStore('app', () => { const theme = ref('light') const pageCache = ref([]) const systemInfo = ref(null) function setTheme(value) { theme.value = value } function addCachePage(pageName) { if (!pageCache.value.includes(pageName)) { pageCache.value.push(pageName) } } function removeCachePage(pageName) { const index = pageCache.value.indexOf(pageName) if (index > -1) { pageCache.value.splice(index, 1) } } function clearCache() { pageCache.value = [] } function setSystemInfo(info) { systemInfo.value = info } return { theme, pageCache, systemInfo, setTheme, addCachePage, removeCachePage, clearCache, setSystemInfo } }, { persist: { key: 'app-store', paths: ['theme', 'pageCache'] } })