mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 08:12:49 +08:00
!138 fix: 修正添加query参数的时候ID获取异常,使用前置守卫把外部动态参数放入window.route.params,后续API动态接口可以拼接参数
Merge pull request !138 from guo_ddt/dev
This commit is contained in:
commit
03f91353c3
@ -5,6 +5,13 @@ import { loginCheck } from '@/utils'
|
|||||||
export function createRouterGuards(router: Router) {
|
export function createRouterGuards(router: Router) {
|
||||||
// 前置
|
// 前置
|
||||||
router.beforeEach(async (to, from, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
|
// http://localhost:3000/#/chart/preview/792622755697790976?t=123
|
||||||
|
// 把外部动态参数放入window.route.params,后续API动态接口可以用window.route?.params?.t来拼接参数
|
||||||
|
// @ts-ignore
|
||||||
|
if (!window.route) window.route = {params: {}}
|
||||||
|
// @ts-ignore
|
||||||
|
Object.assign(window.route.params, to.query)
|
||||||
|
|
||||||
const Loading = window['$loading'];
|
const Loading = window['$loading'];
|
||||||
Loading && Loading.start();
|
Loading && Loading.start();
|
||||||
const isErrorPage = router.getRoutes().findIndex((item) => item.name === to.name);
|
const isErrorPage = router.getRoutes().findIndex((item) => item.name === to.name);
|
||||||
|
@ -159,7 +159,8 @@ export const fetchRouteParams = () => {
|
|||||||
*/
|
*/
|
||||||
export const fetchRouteParamsLocation = () => {
|
export const fetchRouteParamsLocation = () => {
|
||||||
try {
|
try {
|
||||||
return document.location.hash.split('/').pop() || ''
|
// 防止添加query参数的时候,解析ID异常
|
||||||
|
return document.location.hash.split('?')[0].split('/').pop() || ''
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
window['$message'].warning('查询路由信息失败,请联系管理员!')
|
window['$message'].warning('查询路由信息失败,请联系管理员!')
|
||||||
return ''
|
return ''
|
||||||
|
Loading…
Reference in New Issue
Block a user