|
|
@ -1,5 +1,5 @@ |
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<div id="app"> |
|
|
|
<div> |
|
|
|
<div class="app-bg"></div> |
|
|
|
<div class="app-bg"></div> |
|
|
|
|
|
|
|
|
|
|
|
<!-- <div class="safe-area-inset-bottom"> |
|
|
|
<!-- <div class="safe-area-inset-bottom"> |
|
|
@ -49,19 +49,21 @@ onMounted(() => {}); |
|
|
|
const componentNameList: any = ref([]); |
|
|
|
const componentNameList: any = ref([]); |
|
|
|
getKeepAlive(router.options.routes as object[]); |
|
|
|
getKeepAlive(router.options.routes as object[]); |
|
|
|
|
|
|
|
|
|
|
|
// console.log("componentNameList",componentNameList) |
|
|
|
console.log("componentNameList", componentNameList); |
|
|
|
|
|
|
|
|
|
|
|
function getKeepAlive(routesArr: object[]) { |
|
|
|
function getKeepAlive(routesArr: object[]) { |
|
|
|
// console.log(routesArr) |
|
|
|
// console.log(routesArr); |
|
|
|
routesArr.forEach((item: any) => { |
|
|
|
routesArr.forEach((item: any) => { |
|
|
|
if ( |
|
|
|
if ( |
|
|
|
!item.meta || |
|
|
|
!item.meta || |
|
|
|
item.meta.notKeepAlive === undefined || |
|
|
|
item.meta.notKeepAlive === undefined || |
|
|
|
item.meta.notKeepAlive === false |
|
|
|
item.meta.notKeepAlive === false |
|
|
|
) { |
|
|
|
) { |
|
|
|
// console.warn('item',item) |
|
|
|
// console.warn("item", item); |
|
|
|
// console.warn('item.component',item.component) |
|
|
|
// console.warn("item.component", item.component); |
|
|
|
if (item.component) { |
|
|
|
if (item.component) { |
|
|
|
|
|
|
|
const name = getComponentName(item.component.toString()); |
|
|
|
|
|
|
|
name && |
|
|
|
componentNameList.value.push( |
|
|
|
componentNameList.value.push( |
|
|
|
getComponentName(item.component.toString()) |
|
|
|
getComponentName(item.component.toString()) |
|
|
|
); |
|
|
|
); |
|
|
@ -75,14 +77,14 @@ function getKeepAlive(routesArr: object[]) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取组件名 |
|
|
|
// 获取组件名 |
|
|
|
function getComponentName(url: string) { |
|
|
|
function getComponentName(str: string) { |
|
|
|
const regex = /\/([^\/]+)\.(?=[^\/]*$)/; |
|
|
|
const hasLegacy = str.includes("legacy"); |
|
|
|
const match = regex.exec(url); // 执行正则匹配 |
|
|
|
const regex = hasLegacy ? /\/(.+?)-legacy\./ : /\/([^\/]+)\.(?=[^\/]*$)/; |
|
|
|
|
|
|
|
const match = regex.exec(str); // 执行正则匹配 |
|
|
|
if (match) { |
|
|
|
if (match) { |
|
|
|
const name = match[1]; // 获取第一个捕获组的值 |
|
|
|
const name = match[1]; // 获取第一个捕获组的值 |
|
|
|
return name; |
|
|
|
return name; |
|
|
|
} |
|
|
|
} |
|
|
|
return ""; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|