|
@@ -1,8 +1,7 @@
|
|
|
import type { FunctionalComponent } from 'vue';
|
|
|
import type { RouteLocation } from 'vue-router';
|
|
|
-import { computed, ref, unref } from 'vue';
|
|
|
+import { computed, ref, unref, getCurrentInstance } from 'vue';
|
|
|
import { useRootSetting } from '/@/hooks/setting/useRootSetting';
|
|
|
-import { tryTsxEmit } from '/@/utils/helper/vueHelper';
|
|
|
|
|
|
import { useRouter } from 'vue-router';
|
|
|
import { useStore } from 'vuex';
|
|
@@ -20,21 +19,19 @@ export function useCache(isPage: boolean) {
|
|
|
|
|
|
const name = ref('');
|
|
|
const { currentRoute } = useRouter();
|
|
|
-
|
|
|
- tryTsxEmit((instance) => {
|
|
|
- const routeName = instance.type.name;
|
|
|
- if (routeName && ![ParentLayoutName].includes(routeName)) {
|
|
|
- name.value = routeName;
|
|
|
- } else {
|
|
|
- const matched = currentRoute.value?.matched;
|
|
|
- if (!matched) {
|
|
|
- return;
|
|
|
- }
|
|
|
- const len = matched.length;
|
|
|
- if (len < 2) return;
|
|
|
- name.value = matched[len - 2].name as string;
|
|
|
+ const instance = getCurrentInstance();
|
|
|
+ const routeName = instance?.type.name;
|
|
|
+ if (routeName && ![ParentLayoutName].includes(routeName)) {
|
|
|
+ name.value = routeName;
|
|
|
+ } else {
|
|
|
+ const matched = currentRoute.value?.matched;
|
|
|
+ if (!matched) {
|
|
|
+ return;
|
|
|
}
|
|
|
- });
|
|
|
+ const len = matched.length;
|
|
|
+ if (len < 2) return;
|
|
|
+ name.value = matched[len - 2].name as string;
|
|
|
+ }
|
|
|
|
|
|
const { getOpenKeepAlive } = useRootSetting();
|
|
|
|