add setHash helper
This commit is contained in:
7
src/core/plugins/deep-linking/helpers.js
Normal file
7
src/core/plugins/deep-linking/helpers.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export const setHash = (value) => {
|
||||||
|
if(value) {
|
||||||
|
return history.pushState(null, null, `#${value}`)
|
||||||
|
} else {
|
||||||
|
return window.location.hash = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { setHash } from "./helpers"
|
||||||
|
|
||||||
export const show = (ori, system) => (...args) => {
|
export const show = (ori, system) => (...args) => {
|
||||||
ori(...args)
|
ori(...args)
|
||||||
try {
|
try {
|
||||||
@@ -6,17 +8,17 @@ export const show = (ori, system) => (...args) => {
|
|||||||
|
|
||||||
if(type === "operations-tag" || type === "operations") {
|
if(type === "operations-tag" || type === "operations") {
|
||||||
if(!shown) {
|
if(!shown) {
|
||||||
return window.location.hash = ""
|
return setHash("/")
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type === "operations") {
|
if(type === "operations") {
|
||||||
let [, operationId, tag] = thing
|
let [, operationId, tag] = thing
|
||||||
window.location.hash = `/${tag}/${operationId}`
|
setHash(`/${tag}/${operationId}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type === "operations-tag") {
|
if(type === "operations-tag") {
|
||||||
let [, tag] = thing
|
let [, tag] = thing
|
||||||
window.location.hash = `/${tag}`
|
setHash(`/${tag}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user