vitarx-router 4.0.4 → 4.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -472,7 +472,7 @@ export class RouteManager {
|
|
|
472
472
|
(isFunction(route.redirect) || isNavIndex(route.redirect) || isNavTarget(route.redirect))) {
|
|
473
473
|
record.redirect = route.redirect;
|
|
474
474
|
}
|
|
475
|
-
if (!component && !
|
|
475
|
+
if (!component && !record.redirect && !isGroup) {
|
|
476
476
|
throw new Error(`[Router] Route component or redirect or children it cannot be empty at the same time for route "${record.path}"`);
|
|
477
477
|
}
|
|
478
478
|
if (route.meta) {
|
package/dist/core/router/web.js
CHANGED
|
@@ -142,7 +142,9 @@ export class WebRouter extends Router {
|
|
|
142
142
|
if (isString(el)) {
|
|
143
143
|
let element = null;
|
|
144
144
|
try {
|
|
145
|
-
|
|
145
|
+
// 如果选择器以 # 开头,则进行解码
|
|
146
|
+
const selector = el.startsWith('#') ? decodeURIComponent(el) : el;
|
|
147
|
+
element = document.querySelector(selector);
|
|
146
148
|
}
|
|
147
149
|
catch (e) {
|
|
148
150
|
logger.warn(`[Router] Invalid selector "${el}", skipping scroll to element`, e);
|
package/dist/core/shared/link.js
CHANGED
|
@@ -101,7 +101,7 @@ export function useLink(props) {
|
|
|
101
101
|
// 兼容纯锚点连接跳转
|
|
102
102
|
if (target.index.startsWith('#')) {
|
|
103
103
|
const route = cloneRouteLocation(router.route);
|
|
104
|
-
route.hash = target.index;
|
|
104
|
+
route.hash = decodeURIComponent(target.index);
|
|
105
105
|
route.href = router.buildUrl(route.path, route.query, route.hash);
|
|
106
106
|
return route;
|
|
107
107
|
}
|
|
@@ -109,7 +109,7 @@ export function useLink(props) {
|
|
|
109
109
|
if (target.index.includes('#')) {
|
|
110
110
|
const [index, hash] = target.index.split('#', 2);
|
|
111
111
|
target.index = index;
|
|
112
|
-
target.hash = hash ? `#${hash}` : '';
|
|
112
|
+
target.hash = hash ? `#${decodeURIComponent(hash)}` : '';
|
|
113
113
|
}
|
|
114
114
|
// 解析查询参数
|
|
115
115
|
if (target.index.includes('?')) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AnyProps, Component, DeepReadonly } from 'vitarx';
|
|
2
|
-
import { type
|
|
2
|
+
import { type NavigationGuard, type NavOptions, RouteLeaveGuard, RouteUpdateCallback, type URLParams, type URLQuery } from '../index.js';
|
|
3
3
|
import { Router } from '../router/index.js';
|
|
4
4
|
import type { NavTarget, RouteLocation } from './navigation.js';
|
|
5
5
|
/**
|
|
@@ -142,16 +142,8 @@ export interface Route {
|
|
|
142
142
|
props?: InjectProps | NamedInjectProps;
|
|
143
143
|
/**
|
|
144
144
|
* 路由进入前的钩子函数,用于权限控制或数据预加载
|
|
145
|
-
*
|
|
146
|
-
* 默认继承`RouterOptions.beforeEach`
|
|
147
145
|
*/
|
|
148
146
|
beforeEnter?: NavigationGuard;
|
|
149
|
-
/**
|
|
150
|
-
* 路由进入后的钩子函数,用于处理进入路由后的逻辑
|
|
151
|
-
*
|
|
152
|
-
* 默认继承`RouterOptions.afterEach`
|
|
153
|
-
*/
|
|
154
|
-
afterEnter?: AfterCallback;
|
|
155
147
|
}
|
|
156
148
|
/**
|
|
157
149
|
* 解析后的路线记录
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitarx-router",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.5",
|
|
4
4
|
"description": "Official routing solution for Vitarx framework with declarative routing, navigation guards, dynamic routes, file-based routing with HMR, and full TypeScript support.",
|
|
5
5
|
"author": "ZhuChonglin <8210856@qq.com>",
|
|
6
6
|
"license": "MIT",
|