hookehuyr

入口页面监听标题变化优化

...@@ -10,22 +10,20 @@ ...@@ -10,22 +10,20 @@
10 <script setup lang="ts"> 10 <script setup lang="ts">
11 import { mainStore, useTitle } from '@/utils/generatePackage' 11 import { mainStore, useTitle } from '@/utils/generatePackage'
12 import { storeToRefs } from 'pinia' 12 import { storeToRefs } from 'pinia'
13 -import { computed, ref, watch } from 'vue'; 13 +import { computed, watchEffect } from 'vue';
14 import { useRoute } from 'vue-router' 14 import { useRoute } from 'vue-router'
15 - 15 +// 会根据配置判断是否显示调试控件
16 import vConsole from '@/utils/vconsole' 16 import vConsole from '@/utils/vconsole'
17 17
18 // 使用 include + pinia 状态管理动态缓存页面 18 // 使用 include + pinia 状态管理动态缓存页面
19 const store = mainStore() 19 const store = mainStore()
20 -
21 const keepPages = computed(() => { 20 const keepPages = computed(() => {
22 return store.getKeepPages 21 return store.getKeepPages
23 }) 22 })
24 23
25 // 设置页面标题 24 // 设置页面标题
26 const $route = useRoute(); 25 const $route = useRoute();
27 -watch( 26 +watchEffect(
28 - () => $route.path,
29 () => { 27 () => {
30 useTitle($route.meta.title) 28 useTitle($route.meta.title)
31 } 29 }
......