All files / src/utils cacheKey.js

0% Statements 0/1
100% Branches 0/0
0% Functions 0/1
0% Lines 0/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12                       
/**
 * 页签缓存标识:把路由 fullPath 映射为 keep-alive include 可匹配的唯一组件名。
 *
 * 背景:keep-alive 的 include/exclude 只能按「组件名」匹配,无法按 :key(fullPath)精确销毁。
 * 对于「同一组件被不同参数复用」(如 /detail/1、/detail/2 共用 DetailPage)的场景,
 * 需要让每个 fullPath 拥有独立的组件类型与组件名,include 才能按参数精确销毁其实例,
 * 同时不同参数天然成为多个独立缓存。
 */
export function cacheKeyOf(fullPath) {
  return `page_${encodeURIComponent(fullPath)}`
}