fix: 后退前进功能

This commit is contained in:
chenjinsong
2022-10-09 18:47:09 +08:00
parent 313591a5ef
commit 705bc0d58d
11 changed files with 42 additions and 96 deletions

View File

@@ -976,7 +976,7 @@ export function urlParamsHandler (url, oldParams, newParams, cleanOldParams) {
}
export function overwriteUrl (url) {
window.history.pushState('', '', url)
window.history.replaceState('', '', url)
}
/*
@@ -1005,15 +1005,3 @@ export function colorGradientCalculation (startColor, endColor, values) {
export function colorHexToRgbArr (hex) {
return [1, 3, 5].map((h) => parseInt(hex.substring(h, h + 2), 16))
}
export function setHistory (to) {
const historyJson = sessionStorage.getItem(storageKey.history)
const query = { ...to.query, t: new Date().getTime() }
if (historyJson) {
const history = JSON.parse(historyJson)
history.history.push({ path: to.path, query: query })
sessionStorage.setItem(storageKey.history, JSON.stringify(history))
} else {
sessionStorage.setItem(storageKey.history, JSON.stringify({ index: 0, history: [query] }))
}
}