UNPKG

@fmdevui/fm-dev

Version:

Page level components developed based on Element Plus.

30 lines (27 loc) 765 B
import { defineStore } from 'pinia'; const useKeepALiveNames = defineStore("keepALiveNames", { state: () => ({ keepAliveNames: [], cachedViews: [] }), actions: { async setCacheKeepAlive(data) { this.keepAliveNames = data; }, async addCachedView(view) { if (view.meta.isKeepAlive) this.cachedViews?.push(view.name); }, async delCachedView(view) { const index = this.cachedViews.indexOf(view.name); if (index > -1) this.cachedViews.splice(index, 1); }, async delOthersCachedViews(view) { if (view.meta.isKeepAlive) this.cachedViews = [view.name]; else this.cachedViews = []; }, async delAllCachedViews() { this.cachedViews = []; } } }); export { useKeepALiveNames };