@viewfly/router 0.4.1 → 0.5.1

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/README.md CHANGED
@@ -12,6 +12,9 @@ npm install @viewfly/router
12
12
  ## 使用示例
13
13
 
14
14
  ```jsx
15
+ import { createApp } from '@viewfly/platform-browser'
16
+ import { RouterModule } from '@viewfly/router'
17
+
15
18
  function ListTab1() {
16
19
  return () => {
17
20
  return (
@@ -95,37 +98,35 @@ function App() {
95
98
  return () => {
96
99
  return (
97
100
  <div>
98
- <RootRouter>
99
- <div>
100
- <Link active="active" exact to="/">Home</Link>
101
- <Link active="active" to="/list" queryParams={{ a: 'xx' }}>List</Link>
102
- <Link active="active" to="/detail">Detail</Link>
103
- </div>
104
- <div>
105
- <RouterOutlet config={[
106
- {
107
- name: 'home',
108
- component: Home
109
- },
110
- {
111
- name: 'list',
112
- asyncComponent: () => Promise.resolve().then(() => List)
113
- },
114
- {
115
- name: 'detail',
116
- component: Detail
117
- }
118
- ]}>
119
- 未匹配到任何路由
120
- </RouterOutlet>
121
- </div>
122
- </RootRouter>
101
+ <div>
102
+ <Link active="active" exact to="/">Home</Link>
103
+ <Link active="active" to="/list" queryParams={{ a: 'xx' }}>List</Link>
104
+ <Link active="active" to="/detail">Detail</Link>
105
+ </div>
106
+ <div>
107
+ <RouterOutlet config={[
108
+ {
109
+ name: 'home',
110
+ component: Home
111
+ },
112
+ {
113
+ name: 'list',
114
+ asyncComponent: () => Promise.resolve().then(() => List)
115
+ },
116
+ {
117
+ name: 'detail',
118
+ component: Detail
119
+ }
120
+ ]}>
121
+ 未匹配到任何路由
122
+ </RouterOutlet>
123
+ </div>
123
124
  </div>
124
125
  )
125
126
  }
126
127
  }
127
128
 
128
- createApp(document.getElementById('app')!, <App/>)
129
+ createApp(<App/>)use(new RouterModule()).mount(document.getElementById('app')!)
129
130
  ```
130
131
 
131
132
  完整文档请参考官方网站:[viewfly.org](https://viewfly.org)
@@ -1,5 +1,5 @@
1
1
  import { jsx, Fragment } from '@viewfly/core/jsx-runtime';
2
- import { Injectable, inject, useSignal, onUnmounted, provide } from '@viewfly/core';
2
+ import { Injectable, inject, createSignal, onUnmounted, provide } from '@viewfly/core';
3
3
  import { Subject, Subscription, fromEvent } from '@tanbo/stream';
4
4
 
5
5
  /******************************************************************************
@@ -237,7 +237,7 @@ function Link(props) {
237
237
  (navigator.pathname + '/') === navigator.join(props.to, router)) :
238
238
  navigator.pathname.startsWith(navigator.join(props.to, router));
239
239
  }
240
- const isActive = useSignal(getActive());
240
+ const isActive = createSignal(getActive());
241
241
  const subscription = navigator.onUrlChanged.subscribe(() => {
242
242
  isActive.set(getActive());
243
243
  });
@@ -269,7 +269,7 @@ function Link(props) {
269
269
  }
270
270
 
271
271
  function RouterOutlet(props) {
272
- const children = useSignal(null);
272
+ const children = createSignal(null);
273
273
  const router = inject(Router);
274
274
  const childRouter = new Router(inject(Navigator), router, '');
275
275
  provide({
package/bundles/index.js CHANGED
@@ -239,7 +239,7 @@ function Link(props) {
239
239
  (navigator.pathname + '/') === navigator.join(props.to, router)) :
240
240
  navigator.pathname.startsWith(navigator.join(props.to, router));
241
241
  }
242
- const isActive = core.useSignal(getActive());
242
+ const isActive = core.createSignal(getActive());
243
243
  const subscription = navigator.onUrlChanged.subscribe(() => {
244
244
  isActive.set(getActive());
245
245
  });
@@ -271,7 +271,7 @@ function Link(props) {
271
271
  }
272
272
 
273
273
  function RouterOutlet(props) {
274
- const children = core.useSignal(null);
274
+ const children = core.createSignal(null);
275
275
  const router = core.inject(Router);
276
276
  const childRouter = new Router(core.inject(Navigator), router, '');
277
277
  core.provide({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viewfly/router",
3
- "version": "0.4.1",
3
+ "version": "0.5.1",
4
4
  "description": "A routing library based on the Viewfly framework that can be run in the browser or Nodejs background.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",
@@ -13,7 +13,7 @@
13
13
  "keywords": [],
14
14
  "dependencies": {
15
15
  "@tanbo/stream": "^1.2.3",
16
- "@viewfly/core": "^0.4.1",
16
+ "@viewfly/core": "^0.5.1",
17
17
  "url": "^0.11.1"
18
18
  },
19
19
  "devDependencies": {
@@ -34,5 +34,5 @@
34
34
  "bugs": {
35
35
  "url": "https://github.com/viewfly/viewfly.git/issues"
36
36
  },
37
- "gitHead": "7ca289c06cf646dab99157efea91ae9220b2abfd"
37
+ "gitHead": "343b1bff988837e5e0a2acee63c18c3f4a3e8721"
38
38
  }