Commit e04aaa06459c6613e59aa6ae5906b998b0685bdb

Authored by vben
1 parent 2f75a948

fix(use-redo): refresh the page to keep the parameters(#104)

CHANGELOG.zh_CN.md
@@ -22,6 +22,7 @@ @@ -22,6 +22,7 @@
22 ### 🐛 Bug Fixes 22 ### 🐛 Bug Fixes
23 23
24 - 修复 tree 文本超出挡住操作按钮问题 24 - 修复 tree 文本超出挡住操作按钮问题
  25 +- 修复通过 useRedo 刷新页面参数丢失问题
25 26
26 ### 🎫 Chores 27 ### 🎫 Chores
27 28
src/hooks/web/usePage.ts
@@ -36,9 +36,12 @@ export function useGo() { @@ -36,9 +36,12 @@ export function useGo() {
36 */ 36 */
37 export const useRedo = () => { 37 export const useRedo = () => {
38 const { push, currentRoute } = useRouter(); 38 const { push, currentRoute } = useRouter();
  39 + const { query, params } = currentRoute.value;
39 function redo() { 40 function redo() {
40 push({ 41 push({
41 path: '/redirect' + unref(currentRoute).fullPath, 42 path: '/redirect' + unref(currentRoute).fullPath,
  43 + query,
  44 + params,
42 }); 45 });
43 } 46 }
44 return redo; 47 return redo;
src/hooks/web/useTitle.ts deleted 100644 → 0
1 -import { watch } from 'vue';  
2 -import { useRouter } from 'vue-router';  
3 -import { useGlobSetting } from '../setting';  
4 -import { useI18n } from './useI18n';  
5 -import { setTitle } from '/@/utils/browser';  
6 -  
7 -export function useTitle() {  
8 - const { currentRoute } = useRouter();  
9 - const { t } = useI18n();  
10 - watch(  
11 - () => currentRoute.value.path,  
12 - () => {  
13 - const globSetting = useGlobSetting();  
14 - setTitle(t(currentRoute.value.meta.title), globSetting.title);  
15 - },  
16 - { immediate: true, flush: 'post' }  
17 - );  
18 -}  
src/locales/lang/en/routes/demo/page.ts
@@ -24,4 +24,5 @@ export default { @@ -24,4 +24,5 @@ export default {
24 24
25 list: 'List page', 25 list: 'List page',
26 listCard: 'Card list', 26 listCard: 'Card list',
  27 + basic: 'Basic list',
27 }; 28 };
src/locales/lang/zh_CN/routes/demo/page.ts
@@ -24,4 +24,5 @@ export default { @@ -24,4 +24,5 @@ export default {
24 24
25 list: '列表页', 25 list: '列表页',
26 listCard: '卡片列表', 26 listCard: '卡片列表',
  27 + basic: '标准列表',
27 }; 28 };
src/router/guard/index.ts
@@ -57,7 +57,7 @@ export function createGuard(router: Router) { @@ -57,7 +57,7 @@ export function createGuard(router: Router) {
57 router.afterEach((to) => { 57 router.afterEach((to) => {
58 const { t } = useI18n(); 58 const { t } = useI18n();
59 // change html title 59 // change html title
60 - setTitle(t(to.meta.title), globSetting.title); 60 + to.name !== 'Redirect' && setTitle(t(to.meta.title), globSetting.title);
61 }); 61 });
62 createProgressGuard(router); 62 createProgressGuard(router);
63 createPermissionGuard(router); 63 createPermissionGuard(router);
src/router/routes/modules/demo/page.ts
@@ -223,7 +223,7 @@ const page: AppRouteModule = { @@ -223,7 +223,7 @@ const page: AppRouteModule = {
223 name: 'ListBasicPage', 223 name: 'ListBasicPage',
224 component: () => import('/@/views/demo/page/list/basic/index.vue'), 224 component: () => import('/@/views/demo/page/list/basic/index.vue'),
225 meta: { 225 meta: {
226 - title: '标准列表', 226 + title: 'routes.demo.page.basic',
227 }, 227 },
228 }, 228 },
229 { 229 {
src/views/sys/redirect/index.vue
1 -<template>  
2 - <div />  
3 -</template>  
4 <script lang="ts"> 1 <script lang="ts">
5 import { defineComponent, unref } from 'vue'; 2 import { defineComponent, unref } from 'vue';
6 3
@@ -26,7 +23,7 @@ @@ -26,7 +23,7 @@
26 appStore.setPageLoadingAction(false); 23 appStore.setPageLoadingAction(false);
27 }, 0); 24 }, 0);
28 } 25 }
29 - return {}; 26 + return () => null;
30 }, 27 },
31 }); 28 });
32 </script> 29 </script>