Skip to content

Commit

Permalink
renderer: remove transition and keep-alive workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
rocka committed Apr 12, 2020
1 parent f820d77 commit bd7b16e
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 69 deletions.
17 changes: 3 additions & 14 deletions src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
<div>
<AppNav></AppNav>
<div class="router-view">
<transition :name="transitionName"
@after-leave="handleAfterLeave">
<keep-alive-patched :include="KeepAlive">
<transition :name="transitionName">
<keep-alive :include="KeepAlive">
<router-view></router-view>
</keep-alive-patched>
</keep-alive>
</transition>
</div>
<PlayerBar></PlayerBar>
Expand All @@ -31,16 +30,6 @@ export default {
transitionName: 'fade-up'
};
},
methods: {
/** @param {HTMLElement} el */
handleAfterLeave(el) {
for (const k of this.KeepAlive) {
if (el.classList.contains(k)) return;
}
// clear DOM nodes to workaround memory leak issue
el.textContent = '';
}
},
created() {
this.KeepAlive = ['index', 'player', 'favorite'];
this.$router.beforeEach((to, from, next) => {
Expand Down
12 changes: 3 additions & 9 deletions src/renderer/components/ArtistDetail/ArtistDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@
:value="tab[0]">{{tab[1]}}</mu-tab>
</mu-tabs>
<transition mode="out-in"
:name="transitionName"
@after-leave="handleAfterLeave">
<keep-alive-patched>
:name="transitionName">
<keep-alive>
<component :is="detailCompo"
:artist="artist"
@scroll="handleScroll"></component>
</keep-alive-patched>
</keep-alive>
</transition>
</div>
</template>
Expand Down Expand Up @@ -151,11 +150,6 @@ export default {
if (el) {
el.scrollTo({ top: 300, behavior: 'smooth' });
}
},
/** @param {HTMLElement} el */
handleAfterLeave(el) {
// clear DOM nodes to workaround memory leak issue
el.textContent = '';
}
},
created() {
Expand Down
12 changes: 3 additions & 9 deletions src/renderer/components/UserDetail/UserDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@
:value="tab[0]">{{tab[1]}}</mu-tab>
</mu-tabs>
<transition mode="out-in"
:name="transitionName"
@after-leave="handleAfterLeave">
<keep-alive-patched>
:name="transitionName">
<keep-alive>
<component :is="detailCompo"
:user="user"
:isSelf="isSelf"></component>
</keep-alive-patched>
</keep-alive>
</transition>
</div>
</template>
Expand Down Expand Up @@ -189,11 +188,6 @@ export default {
this.transitionName = 'slide-left';
}
this.tab = val;
},
/** @param {HTMLElement} el */
handleAfterLeave(el) {
// clear DOM nodes to workaround memory leak issue
el.textContent = '';
}
},
watch: {
Expand Down
2 changes: 0 additions & 2 deletions src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import routes from './routes';
import { isLinux } from './util/globals';
import { initTheme } from './util/theme';
import DblclickRipple from './util/dblclick-ripple';
import KeepAlivePatched from './util/keep-alive-patched';
import './style.css';
import './transition.css';
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css';
Expand All @@ -22,7 +21,6 @@ Vue.use(MuseUI);
Vue.use(Toast);
Vue.use(Message);
Vue.use(DblclickRipple);
Vue.use(KeepAlivePatched);
Vue.component('RecycleScroller', RecycleScroller);

try {
Expand Down
12 changes: 3 additions & 9 deletions src/renderer/page/Comment/Comment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
</mu-tabs>
<div class="list-wrapper">
<transition mode="out-in"
:name="transitionName"
@after-leave="handleAfterLeave">
<keep-alive-patched>
:name="transitionName">
<keep-alive>
<CommentList :key="tab"
:thread="thread"
v-bind="comment[tab]"
@page="loadComments"
@reply="handleReply"></CommentList>
</keep-alive-patched>
</keep-alive>
</transition>
</div>
<mu-dialog dialog-class="comment-editor-dlg"
Expand Down Expand Up @@ -193,11 +192,6 @@ export default {
} else {
this.$toast.message(`发布评论失败 ... ${resp.code}: ${resp.msg}`);
}
},
/** @param {HTMLElement} el */
handleAfterLeave(el) {
// clear DOM nodes to workaround memory leak issue
el.textContent = '';
}
},
watch: {
Expand Down
8 changes: 1 addition & 7 deletions src/renderer/page/Favorite/Favorite.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
</mu-tabs>
<div class="fav-content">
<transition mode="out-in"
:name="transitionName"
@after-leave="handleAfterLeave">
:name="transitionName">
<component :is="favCompo"></component>
</transition>
</div>
Expand Down Expand Up @@ -67,11 +66,6 @@ export default {
this.transitionName = 'slide-left';
}
this.tab = val;
},
/** @param {HTMLElement} el */
handleAfterLeave(el) {
// clear DOM nodes to workaround memory leak issue
el.textContent = '';
}
},
created() {
Expand Down
19 changes: 0 additions & 19 deletions src/renderer/util/keep-alive-patched.js

This file was deleted.

0 comments on commit bd7b16e

Please sign in to comment.