diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index ce874f7fcb1..ef43714ac50 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -17,6 +17,7 @@ - 修复在`editComponentProps`中为编辑组件提供的`size`属性无效的问题 - **Qrcode** 修复二维码组件在创建时未能及时绘制的问题 - **BasicModal** 修复`helpMessage`属性不起作用的问题 +- **其它** 修复`useRedo`(重新加载当前路由)会丢失路由`params`数据的问题 ## 2.7.0(2021-08-03) diff --git a/src/components/Table/src/BasicTable.vue b/src/components/Table/src/BasicTable.vue index 2a97b131372..9cb30df6618 100644 --- a/src/components/Table/src/BasicTable.vue +++ b/src/components/Table/src/BasicTable.vue @@ -110,7 +110,7 @@ watchEffect(() => { unref(isFixedHeightPage) && props.canResize && - warn("[BasicTable] 'canRize' not worked with PageWrapper while 'fixedHeight' is true"); + warn("[BasicTable] 'canResize' may not worked in PageWrapper with 'fixedHeight'"); }); const { getLoading, setLoading } = useLoading(getProps); diff --git a/src/hooks/web/usePage.ts b/src/hooks/web/usePage.ts index c05e420a72f..eab05c9fad7 100644 --- a/src/hooks/web/usePage.ts +++ b/src/hooks/web/usePage.ts @@ -5,6 +5,7 @@ import { isString } from '/@/utils/is'; import { unref } from 'vue'; import { useRouter } from 'vue-router'; +import { REDIRECT_NAME } from '/@/router/constant'; export type RouteLocationRawEx = Omit & { path: PageEnum }; @@ -37,19 +38,18 @@ export function useGo(_router?: Router) { * @description: redo current page */ export const useRedo = (_router?: Router) => { - let router; - if (!_router) { - router = useRouter(); - } - const { push, currentRoute } = _router || router; - const { query, params } = currentRoute.value; + const { push, currentRoute } = _router || useRouter(); + const { query, params = {}, name, fullPath } = unref(currentRoute.value); function redo(): Promise { return new Promise((resolve) => { - push({ - path: '/redirect' + unref(currentRoute).fullPath, - query, - params, - }).then(() => resolve(true)); + if (name && Object.keys(params).length > 0) { + params['_redirect_type'] = 'name'; + params['path'] = String(name); + } else { + params['_redirect_type'] = 'path'; + params['path'] = fullPath; + } + push({ name: REDIRECT_NAME, params, query }).then(() => resolve(true)); }); } return redo; diff --git a/src/router/routes/basic.ts b/src/router/routes/basic.ts index e2dd1ec5ce3..58db49448d4 100644 --- a/src/router/routes/basic.ts +++ b/src/router/routes/basic.ts @@ -33,8 +33,8 @@ export const PAGE_NOT_FOUND_ROUTE: AppRouteRecordRaw = { export const REDIRECT_ROUTE: AppRouteRecordRaw = { path: '/redirect', - name: REDIRECT_NAME, component: LAYOUT, + name: 'RedirectTo', meta: { title: REDIRECT_NAME, hideBreadcrumb: true, diff --git a/src/views/sys/redirect/index.vue b/src/views/sys/redirect/index.vue index 726c6f04e83..7aa54635fe3 100644 --- a/src/views/sys/redirect/index.vue +++ b/src/views/sys/redirect/index.vue @@ -8,12 +8,23 @@ const { currentRoute, replace } = useRouter(); const { params, query } = unref(currentRoute); - const { path } = params; + const { path, _redirect_type = 'path' } = params; + + Reflect.deleteProperty(params, '_redirect_type'); + Reflect.deleteProperty(params, 'path'); const _path = Array.isArray(path) ? path.join('/') : path; - replace({ - path: '/' + _path, - query, - }); + if (_redirect_type === 'name') { + replace({ + name: _path, + query, + params, + }); + } else { + replace({ + path: _path.startsWith('/') ? _path : '/' + _path, + query, + }); + }