| 1234567891011121314151617181920212223242526 |
- import { defineStore } from 'pinia';
- import { ref } from 'vue';
- export const useKeepAliveStore = defineStore('keepAlive', () => {
- const cachedViews = ref<string[]>([]);
- function addCachedView(name: string) {
- if (!cachedViews.value.includes(name)) {
- cachedViews.value.push(name);
- }
- }
- function removeCachedView(name: string) {
- const index = cachedViews.value.indexOf(name);
- if (index > -1) {
- cachedViews.value.splice(index, 1);
- }
- }
- function clearCachedViews() {
- cachedViews.value = [];
- }
- return { cachedViews, addCachedView, removeCachedView, clearCachedViews };
- });
|