[O] Encapsulate update history in updateIndex()
This commit is contained in:
@@ -60,22 +60,27 @@ export default class Navigation extends Vue
|
|||||||
|
|
||||||
// Debug output TODO: Remove this
|
// Debug output TODO: Remove this
|
||||||
console.log(`onNavigate: Previous: ${this.activeIndex}, New: ${index}`);
|
console.log(`onNavigate: Previous: ${this.activeIndex}, New: ${index}`);
|
||||||
|
|
||||||
// Check url
|
|
||||||
let url = `/${index}`;
|
|
||||||
|
|
||||||
// Push history state
|
|
||||||
window.history.pushState({lastTab: index}, '', url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update index
|
* Update index
|
||||||
*
|
*
|
||||||
* @param newIndex New index
|
* @param newIndex New index
|
||||||
|
* @param history Record in history or not (Default true)
|
||||||
*/
|
*/
|
||||||
private updateIndex(newIndex: string)
|
private updateIndex(newIndex: string, history?: boolean)
|
||||||
{
|
{
|
||||||
|
// Call custom event
|
||||||
this.$emit('update:activeIndex', newIndex);
|
this.$emit('update:activeIndex', newIndex);
|
||||||
|
|
||||||
|
// Record or not
|
||||||
|
if (history == null || !history) return;
|
||||||
|
|
||||||
|
// Check url
|
||||||
|
let url = `/${newIndex}`;
|
||||||
|
|
||||||
|
// Push history state
|
||||||
|
window.history.pushState({lastTab: newIndex}, '', url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user