Skip to content

Commit

Permalink
fix: back button is broken
Browse files Browse the repository at this point in the history
Ref: #21
  • Loading branch information
billyc committed Jul 12, 2021
1 parent 4041a4a commit 109d672
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/views/ScreenSplitter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import FolderBrowser from '@/views/FolderBrowser.vue'
import SplashPage from '@/views/SplashPage.vue'
import SqlThing from '@/views/SqlThing.vue'
import SqlThingTwo from '@/views/SqliteThing.vue'
import { Route } from 'vue-router'
@Component({
components: Object.assign(
Expand All @@ -55,6 +56,24 @@ class MyComponent extends Vue {
this.buildLayoutFromURL()
}
@Watch('$route') routeChanged(to: Route, from: Route) {
console.log({ to, from })
if (to.path === '/') {
// root node is not a normal splitpane, so we instead replace
// the full monty with a brand new clean startpage.
this.panels = [
{
component: 'SplashPage',
key: Math.random(),
props: {} as any,
},
]
} else {
this.buildLayoutFromURL()
globalStore.commit('resize')
}
}
private buildLayoutFromURL() {
const pathMatch = this.$route.params.pathMatch
if (!pathMatch) return
Expand Down Expand Up @@ -122,7 +141,7 @@ class MyComponent extends Vue {
private updateURL() {
const base64 = btoa(JSON.stringify(this.panels))
this.$router.replace(`/${base64}`)
this.$router.push(`/${base64}`)
}
}
Expand Down

0 comments on commit 109d672

Please sign in to comment.