@vobs/router 1.2.1 → 1.3.0
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.
- package/dist/debug.cjs +31 -7
- package/dist/debug.cjs.map +1 -1
- package/dist/debug.js +5 -3
- package/dist/debug.js.map +1 -1
- package/dist/index.cjs +71 -847
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +32 -821
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +5 -2
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "git+https://github.com/vobsjs/vobs.git"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.3.0",
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"./source/*": "./src/*"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@vobs/
|
|
37
|
-
"@vobs/
|
|
38
|
-
"@vobs/
|
|
36
|
+
"@vobs/runtime": "1.3.0",
|
|
37
|
+
"@vobs/reactivity": "1.3.0",
|
|
38
|
+
"@vobs/vobs": "1.3.0"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/src/index.ts
CHANGED
|
@@ -252,7 +252,8 @@ export interface Router {
|
|
|
252
252
|
|
|
253
253
|
export interface RouterViewProps {
|
|
254
254
|
readonly router?: Router
|
|
255
|
-
|
|
255
|
+
/** 加载占位:JSX 属性经编译器编译为惰性 getter,手写对象字面量可传节点或工厂。 */
|
|
256
|
+
readonly loading?: VobsNode | (() => VobsNode | null | undefined)
|
|
256
257
|
readonly notFound?: (route: RouteLocation) => VobsNode | null | undefined
|
|
257
258
|
readonly error?: (error: Error, retry: () => void) => VobsNode | null | undefined
|
|
258
259
|
}
|
|
@@ -817,7 +818,9 @@ export function RouterView(props: RouterViewProps = {}): VobsNode {
|
|
|
817
818
|
const route = router.currentRoute.value
|
|
818
819
|
const view = router.getViewState(route)
|
|
819
820
|
routeRetry = view.retry
|
|
820
|
-
if (view.status === 'loading')
|
|
821
|
+
if (view.status === 'loading') {
|
|
822
|
+
return (typeof props.loading === 'function' ? props.loading() : props.loading) ?? null
|
|
823
|
+
}
|
|
821
824
|
if (view.status === 'not-found') return props.notFound?.(route) ?? null
|
|
822
825
|
if (view.status === 'error') {
|
|
823
826
|
throw view.error ?? new Error('路由组件加载失败')
|