Showing
3 changed files
with
18 additions
and
27 deletions
| ... | @@ -8,9 +8,10 @@ | ... | @@ -8,9 +8,10 @@ |
| 8 | </template> | 8 | </template> |
| 9 | 9 | ||
| 10 | <script setup lang="ts"> | 10 | <script setup lang="ts"> |
| 11 | -import { mainStore } from '@/store' | 11 | +import { mainStore, useTitle } from '@/utils/generatePackage' |
| 12 | import { storeToRefs } from 'pinia' | 12 | import { storeToRefs } from 'pinia' |
| 13 | -import { computed, ref } from 'vue'; | 13 | +import { computed, ref, watch } from 'vue'; |
| 14 | +import { useRoute } from 'vue-router' | ||
| 14 | 15 | ||
| 15 | import vConsole from '@/utils/vconsole' | 16 | import vConsole from '@/utils/vconsole' |
| 16 | 17 | ||
| ... | @@ -21,6 +22,14 @@ const keepPages = computed(() => { | ... | @@ -21,6 +22,14 @@ const keepPages = computed(() => { |
| 21 | return store.getKeepPages | 22 | return store.getKeepPages |
| 22 | }) | 23 | }) |
| 23 | 24 | ||
| 25 | +// 设置页面标题 | ||
| 26 | +const $route = useRoute(); | ||
| 27 | +watch( | ||
| 28 | + () => $route.path, | ||
| 29 | + () => { | ||
| 30 | + useTitle($route.meta.title) | ||
| 31 | + } | ||
| 32 | +) | ||
| 24 | </script> | 33 | </script> |
| 25 | 34 | ||
| 26 | <style lang="less"> | 35 | <style lang="less"> | ... | ... |
| ... | @@ -47,16 +47,16 @@ | ... | @@ -47,16 +47,16 @@ |
| 47 | 47 | ||
| 48 | <script setup> | 48 | <script setup> |
| 49 | import { ref, reactive, onMounted } from 'vue' | 49 | import { ref, reactive, onMounted } from 'vue' |
| 50 | -import { useRoute, useRouter } from 'vue-router' | 50 | +import { useRoute } from 'vue-router' |
| 51 | 51 | ||
| 52 | import { Cookies, _, axios, mainStore, Toast, useTitle } from '@/utils/generatePackage' | 52 | import { Cookies, _, axios, mainStore, Toast, useTitle } from '@/utils/generatePackage' |
| 53 | import { no_image, icon_avatar } from '@/utils/generateIcons' | 53 | import { no_image, icon_avatar } from '@/utils/generateIcons' |
| 54 | import { MyButton, ShortcutFixed, BookCard } from '@/utils/generateModules' | 54 | import { MyButton, ShortcutFixed, BookCard } from '@/utils/generateModules' |
| 55 | 55 | ||
| 56 | import { useBookList } from '@/composables'; | 56 | import { useBookList } from '@/composables'; |
| 57 | - | 57 | +import { useGo } from '@/hooks/useGo' |
| 58 | +const go = useGo() | ||
| 58 | const $route = useRoute(); | 59 | const $route = useRoute(); |
| 59 | -const $router = useRouter(); | ||
| 60 | 60 | ||
| 61 | // 删除所有的 keep-alive 缓存 | 61 | // 删除所有的 keep-alive 缓存 |
| 62 | const store = mainStore() | 62 | const store = mainStore() |
| ... | @@ -64,9 +64,6 @@ store.changeKeepPages(); | ... | @@ -64,9 +64,6 @@ store.changeKeepPages(); |
| 64 | // 清空记录位置 | 64 | // 清空记录位置 |
| 65 | store.changeScrollTop(0); | 65 | store.changeScrollTop(0); |
| 66 | 66 | ||
| 67 | -// 设置页面标题 | ||
| 68 | -useTitle($route.meta.title) | ||
| 69 | - | ||
| 70 | const { kg_id, kgInfo, emptyStatus } = useBookList($route) | 67 | const { kg_id, kgInfo, emptyStatus } = useBookList($route) |
| 71 | 68 | ||
| 72 | // 配置快捷跳转条 | 69 | // 配置快捷跳转条 |
| ... | @@ -86,12 +83,7 @@ const styleObject = reactive({ | ... | @@ -86,12 +83,7 @@ const styleObject = reactive({ |
| 86 | 83 | ||
| 87 | // 跳转书籍详情页 | 84 | // 跳转书籍详情页 |
| 88 | const onClick = (item) => { | 85 | const onClick = (item) => { |
| 89 | - $router.push({ | 86 | + go('/client/bookDetail', { id: item.id }) |
| 90 | - path: '/client/bookDetail', | ||
| 91 | - query: { | ||
| 92 | - id: item.id | ||
| 93 | - } | ||
| 94 | - }); | ||
| 95 | } | 87 | } |
| 96 | </script> | 88 | </script> |
| 97 | 89 | ... | ... |
| ... | @@ -11,31 +11,22 @@ | ... | @@ -11,31 +11,22 @@ |
| 11 | 11 | ||
| 12 | <script setup> | 12 | <script setup> |
| 13 | import { mainStore } from '@/store' | 13 | import { mainStore } from '@/store' |
| 14 | - | ||
| 15 | import RightSideList from '@/components/RightSideList/index' | 14 | import RightSideList from '@/components/RightSideList/index' |
| 15 | +import { useGo } from '@/hooks/useGo' | ||
| 16 | 16 | ||
| 17 | -import { useRouter } from 'vue-router' | 17 | +const go = useGo() |
| 18 | - | ||
| 19 | -const $router = useRouter(); | ||
| 20 | - | ||
| 21 | // 删除所有的 keep-alive 缓存 | 18 | // 删除所有的 keep-alive 缓存 |
| 22 | const store = mainStore() | 19 | const store = mainStore() |
| 23 | store.changeKeepPages('clear'); | 20 | store.changeKeepPages('clear'); |
| 24 | 21 | ||
| 25 | // 跳转幼儿园爱心书籍列表页 | 22 | // 跳转幼儿园爱心书籍列表页 |
| 26 | const onClick = (item) => { | 23 | const onClick = (item) => { |
| 27 | - $router.push({ | 24 | + go('/client/chooseBook', { kg_id: item.id }) |
| 28 | - path: '/client/chooseBook', | ||
| 29 | - query: { | ||
| 30 | - kg_id: item.id | ||
| 31 | - } | ||
| 32 | - }); | ||
| 33 | } | 25 | } |
| 34 | 26 | ||
| 35 | </script> | 27 | </script> |
| 36 | 28 | ||
| 37 | <script> | 29 | <script> |
| 38 | -import mixin from 'common/mixin' | ||
| 39 | import { kgListAPI } from '@/api/C/kg.js' | 30 | import { kgListAPI } from '@/api/C/kg.js' |
| 40 | 31 | ||
| 41 | export default { | 32 | export default { |
| ... | @@ -46,7 +37,6 @@ export default { | ... | @@ -46,7 +37,6 @@ export default { |
| 46 | next(); | 37 | next(); |
| 47 | })() | 38 | })() |
| 48 | }, | 39 | }, |
| 49 | - mixins: [mixin.init], | ||
| 50 | data () { | 40 | data () { |
| 51 | return { | 41 | return { |
| 52 | schoolList: this.$route.params.schoolList | 42 | schoolList: this.$route.params.schoolList | ... | ... |
-
Please register or login to post a comment