Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

45 linhas
1.6 KiB

  1. import Vue from 'vue'
  2. import store from './store';
  3. Vue.mixin({
  4. beforeRouteEnter: function (to, from, next) {
  5. next(() => {
  6. let avueView = document.getElementById('avue-view');
  7. if (avueView && to.meta.savedPosition) {
  8. avueView.scrollTop = to.meta.savedPosition
  9. }
  10. })
  11. },
  12. beforeRouteLeave: function (to, from, next) {
  13. let avueView = document.getElementById('avue-view');
  14. if (from && from.meta.keepAlive) {
  15. if (avueView) {
  16. from.meta.savedPosition = avueView.scrollTop
  17. }
  18. const result = this.$route.meta.keepAlive === true && store.state.tags.tagList.some(ele => {
  19. return ele.value === this.$route.fullPath;
  20. })
  21. if (this.$vnode && !result) {
  22. from.meta.savedPosition = 0
  23. if (this.$vnode.parent && this.$vnode.parent.componentInstance && this.$vnode.parent.componentInstance.cache) {
  24. if (this.$vnode.componentOptions) {
  25. var key = this.$vnode.key == null
  26. ? this.$vnode.componentOptions.Ctor.cid + (this.$vnode.componentOptions.tag ? `::${this.$vnode.componentOptions.tag}` : '')
  27. : this.$vnode.key;
  28. var cache = this.$vnode.parent.componentInstance.cache;
  29. var keys = this.$vnode.parent.componentInstance.keys;
  30. if (cache[key]) {
  31. if (keys.length) {
  32. var index = keys.indexOf(key);
  33. if (index > -1) {
  34. keys.splice(index, 1);
  35. }
  36. }
  37. delete cache[key];
  38. }
  39. }
  40. }
  41. }
  42. }
  43. next();
  44. },
  45. });