refactor: only show NProgress when loading time is too long

This commit is contained in:
qier222 2021-06-08 16:37:05 +08:00
parent 723cf1b3b3
commit f89fc84f95
No known key found for this signature in database
GPG key ID: 9C85007ED905F14D
11 changed files with 33 additions and 35 deletions

View file

@ -159,12 +159,13 @@ export default {
ContextMenu,
},
beforeRouteUpdate(to, from, next) {
NProgress.start();
this.show = false;
this.loadData(to.params.id);
next();
},
data() {
return {
show: false,
album: {
id: 0,
picUrl: '',
@ -174,7 +175,6 @@ export default {
},
tracks: [],
showFullDescription: false,
show: false,
moreAlbums: [],
dynamicDetail: {},
subtitle: '',
@ -206,11 +206,6 @@ export default {
}
},
},
watch: {
album: function () {
this.$parent.$refs.main.scrollTo({ top: 0 });
},
},
created() {
this.loadData(this.$route.params.id);
},
@ -256,6 +251,9 @@ export default {
}
},
loadData(id) {
setTimeout(() => {
if (!this.show) NProgress.start();
}, 1000);
getAlbum(id).then(data => {
this.album = data.album;
this.tracks = data.songs;

View file

@ -207,7 +207,6 @@ export default {
ContextMenu,
},
beforeRouteUpdate(to, from, next) {
NProgress.start();
this.artist.img1v1Url =
'https://p1.music.126.net/VnZiScyynLG7atLIZ2YPkw==/18686200114669622.jpg';
this.loadData(to.params.id, next);
@ -257,9 +256,6 @@ export default {
};
},
},
created() {
this.loadData(this.$route.params.id);
},
activated() {
if (this.artist?.id?.toString() !== this.$route.params.id) {
this.loadData(this.$route.params.id);
@ -271,7 +267,9 @@ export default {
...mapMutations(['appendTrackToPlayerList']),
...mapActions(['playFirstTrackOnList', 'playTrackOnListByID', 'showToast']),
loadData(id, next = undefined) {
NProgress.start();
setTimeout(() => {
if (!this.show) NProgress.start();
}, 1000);
this.show = false;
this.$parent.$refs.main.scrollTo({ top: 0 });
getArtist(id).then(data => {

View file

@ -22,13 +22,12 @@ import ButtonTwoTone from '@/components/ButtonTwoTone.vue';
import MvRow from '@/components/MvRow.vue';
export default {
name: 'artistMV',
name: 'ArtistMV',
components: {
MvRow,
ButtonTwoTone,
},
beforeRouteUpdate(to, from, next) {
NProgress.start();
this.id = to.params.id;
this.loadData();
next();
@ -58,6 +57,9 @@ export default {
},
methods: {
loadData() {
setTimeout(() => {
if (!this.show) NProgress.start();
}, 1000);
getArtist(this.id).then(data => {
this.artist = data.artist;
});

View file

@ -35,7 +35,9 @@ export default {
},
created() {
if (this.dailyTracks.length === 0) {
NProgress.start();
setTimeout(() => {
if (!this.show) NProgress.start();
}, 1000);
this.loadDailyTracks();
} else {
this.show = true;

View file

@ -86,7 +86,6 @@ export default {
SvgIcon,
},
beforeRouteUpdate(to, from, next) {
NProgress.start();
this.showLoadMoreButton = false;
this.hasMore = true;
this.playlists = [];
@ -122,7 +121,9 @@ export default {
methods: {
...mapMutations(['togglePlaylistCategory']),
loadData() {
if (!this.show) NProgress.start();
setTimeout(() => {
if (!this.show) NProgress.start();
}, 1000);
this.activeCategory =
this.$route.query.category === undefined
? '全部'

View file

@ -110,7 +110,9 @@ export default {
},
methods: {
loadData() {
if (!this.show) NProgress.start();
setTimeout(() => {
if (!this.show) NProgress.start();
}, 1000);
recommendPlaylist({
limit: 10,
}).then(data => {

View file

@ -230,7 +230,9 @@ export default {
},
},
created() {
NProgress.start();
setTimeout(() => {
if (!this.show) NProgress.start();
}, 1000);
this.loadData();
},
activated() {

View file

@ -407,6 +407,9 @@ export default {
} else {
this.loadData(this.$route.params.id);
}
setTimeout(() => {
if (!this.show) NProgress.start();
}, 1000);
},
methods: {
...mapMutations(['appendTrackToPlayerList']),

View file

@ -157,7 +157,9 @@ export default {
});
},
getData() {
NProgress.start();
setTimeout(() => {
if (!this.show) NProgress.start();
}, 1000);
this.show = false;
const requestAll = requests => {