Compare commits

..

No commits in common. '7dbd8fa26df008022f82e34575fff3cd803dd76c' and 'e195ba82e6e1f3b0ff0b45207083b05a5a298788' have entirely different histories.

  1. 20
      src/App.vue

20
src/App.vue

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

Loading…
Cancel
Save