Skip to content

Commit

Permalink
feat(ui): restore route mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Mar 18, 2018
1 parent d7700ff commit ec44835
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/@vue/cli-ui/src/mixins/RestoreRoute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export default function () {
let lastRoute

// @vue/component
return {
beforeRouteEnter (to, from, next) {
if (lastRoute) {
const { name, params, query } = lastRoute
next({ name, params, query })
lastRoute = null
} else {
next()
}
},

beforeRouteLeave (to, from, next) {
lastRoute = from
next()
}
}
}
6 changes: 6 additions & 0 deletions packages/@vue/cli-ui/src/views/ProjectTasks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@
</template>

<script>
import RestoreRoute from '../mixins/RestoreRoute'
import TASK_CHANGED from '../graphql/taskChanged.gql'
export default {
mixins: [
RestoreRoute()
],
apollo: {
$subscribe: {
taskChanged: {
Expand Down

0 comments on commit ec44835

Please sign in to comment.