mixin-top.ts 762 B

123456789101112131415161718192021222324252627282930313233
  1. import { mapMutations } from 'vuex'
  2. export const MixinTop = {
  3. data: function () {
  4. return {
  5. TopConfig: {}
  6. }
  7. },
  8. methods: {
  9. ...mapMutations({
  10. updateLayoutConfig: 'updateLayoutConfig',
  11. clearLayoutConfig: 'clearLayoutConfig'
  12. }),
  13. upTopConfig () {
  14. ;(this as any).updateLayoutConfig((this as any).TopConfig)
  15. }
  16. },
  17. beforeRouteEnter (to: any, form: any, next: any) {
  18. next((vm: any) => {
  19. console.log(vm.TopConfig.actionRightCallback)
  20. vm.upTopConfig()
  21. })
  22. },
  23. beforeRouteUpdate (to: any, form: any, next: any) {
  24. // 暂无场景
  25. console.log('beforeRouteUpdate')
  26. next()
  27. },
  28. beforeRouteLeave (to: any, form: any, next: any) {
  29. ;(this as any).clearLayoutConfig()
  30. next()
  31. }
  32. }