Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
iuroc committed Aug 26, 2024
1 parent 07b3b97 commit 22e17c1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
5 changes: 0 additions & 5 deletions jsr.json

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"type": "module",
"name": "vanjs-router",
"version": "2.0.6",
"version": "2.0.7",
"main": "js/router.js",
"types": "src/router.ts"
}
6 changes: 3 additions & 3 deletions src/router.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import van, { State } from 'vanjs-core'

/** 返回当前的 Hash 值,自动去除前置 `#`,如果为空则返回 `home` */
export const nowHash = (): string => location.hash ? location.hash.slice(1) : 'home'
/** 返回当前的 `location.hash` 值的 `#/` 后面的部分,如果为空则返回 `home` */
export const nowHash = (): string => location.hash ? location.hash.slice(2) : 'home'

/** 当前的 Hash 状态,值通过 `nowHash()` 返回。 */
/** 当前的 Hash 值,不含开头的 #,值通过 `nowHash()` 返回。 */
export const now: State<string> = van.state(nowHash())

window.addEventListener('hashchange', event => {
Expand Down

0 comments on commit 22e17c1

Please sign in to comment.