Newer
Older
xc-business-system / src / utils / keepQuery.ts
dutingting on 7 Apr 2024 569 bytes bug修复,组件缓存功能
// 保存页面查询等参数
import useKeepAliveStore from '@/store/modules/keepAlive'

const keepAliveStore = useKeepAliveStore()
// 操作
const needKeep = ['edit', 'detail', 'add']
export function keepSearchParams(to: any, componentName: string) {
  if (needKeep.some((item: string) => to.includes(item))) {
    console.log('是否需要缓存组件', needKeep.some((item: string) => to.includes(item)))
    keepAliveStore.add(componentName)
    console.log('缓存的组件列表', keepAliveStore.list)
  }
  else {
    keepAliveStore.remove(componentName)
  }
}