mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 13:17:46 +00:00
refactor: only show NProgress when loading time is too long
This commit is contained in:
parent
723cf1b3b3
commit
f89fc84f95
11 changed files with 33 additions and 35 deletions
|
|
@ -9,6 +9,8 @@ import '@/utils/filters';
|
||||||
import './registerServiceWorker';
|
import './registerServiceWorker';
|
||||||
import { dailyTask } from '@/utils/common';
|
import { dailyTask } from '@/utils/common';
|
||||||
import '@/assets/css/global.scss';
|
import '@/assets/css/global.scss';
|
||||||
|
import NProgress from 'nprogress';
|
||||||
|
import '@/assets/css/nprogress.css';
|
||||||
|
|
||||||
window.resetApp = () => {
|
window.resetApp = () => {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
|
|
@ -20,7 +22,6 @@ window.resetApp = () => {
|
||||||
});
|
});
|
||||||
return '已重置应用,请刷新页面(按Ctrl/Command + R)';
|
return '已重置应用,请刷新页面(按Ctrl/Command + R)';
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
'如出现问题,可尝试在本页输入 %cresetApp()%c 然后按回车重置应用。',
|
'如出现问题,可尝试在本页输入 %cresetApp()%c 然后按回车重置应用。',
|
||||||
'background: #eaeffd;color:#335eea;padding: 4px 6px;border-radius:3px;',
|
'background: #eaeffd;color:#335eea;padding: 4px 6px;border-radius:3px;',
|
||||||
|
|
@ -31,9 +32,9 @@ Vue.use(VueAnalytics, {
|
||||||
id: 'UA-180189423-1',
|
id: 'UA-180189423-1',
|
||||||
router,
|
router,
|
||||||
});
|
});
|
||||||
|
|
||||||
Vue.config.productionTip = false;
|
Vue.config.productionTip = false;
|
||||||
|
|
||||||
|
NProgress.configure({ showSpinner: false, trickleSpeed: 100 });
|
||||||
dailyTask();
|
dailyTask();
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import VueRouter from 'vue-router';
|
import VueRouter from 'vue-router';
|
||||||
import NProgress from 'nprogress';
|
|
||||||
import '@/assets/css/nprogress.css';
|
|
||||||
import { isLooseLoggedIn, isAccountLoggedIn } from '@/utils/auth';
|
import { isLooseLoggedIn, isAccountLoggedIn } from '@/utils/auth';
|
||||||
|
|
||||||
NProgress.configure({ showSpinner: false, trickleSpeed: 100 });
|
|
||||||
|
|
||||||
Vue.use(VueRouter);
|
Vue.use(VueRouter);
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
|
|
@ -169,13 +165,4 @@ router.beforeEach((to, from, next) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.afterEach(to => {
|
|
||||||
if (
|
|
||||||
to.matched.some(record => !record.meta.keepAlive) &&
|
|
||||||
!['settings', 'dailySongs', 'lastfmCallback'].includes(to.name)
|
|
||||||
) {
|
|
||||||
NProgress.start();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|
|
||||||
|
|
@ -159,12 +159,13 @@ export default {
|
||||||
ContextMenu,
|
ContextMenu,
|
||||||
},
|
},
|
||||||
beforeRouteUpdate(to, from, next) {
|
beforeRouteUpdate(to, from, next) {
|
||||||
NProgress.start();
|
this.show = false;
|
||||||
this.loadData(to.params.id);
|
this.loadData(to.params.id);
|
||||||
next();
|
next();
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
show: false,
|
||||||
album: {
|
album: {
|
||||||
id: 0,
|
id: 0,
|
||||||
picUrl: '',
|
picUrl: '',
|
||||||
|
|
@ -174,7 +175,6 @@ export default {
|
||||||
},
|
},
|
||||||
tracks: [],
|
tracks: [],
|
||||||
showFullDescription: false,
|
showFullDescription: false,
|
||||||
show: false,
|
|
||||||
moreAlbums: [],
|
moreAlbums: [],
|
||||||
dynamicDetail: {},
|
dynamicDetail: {},
|
||||||
subtitle: '',
|
subtitle: '',
|
||||||
|
|
@ -206,11 +206,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
album: function () {
|
|
||||||
this.$parent.$refs.main.scrollTo({ top: 0 });
|
|
||||||
},
|
|
||||||
},
|
|
||||||
created() {
|
created() {
|
||||||
this.loadData(this.$route.params.id);
|
this.loadData(this.$route.params.id);
|
||||||
},
|
},
|
||||||
|
|
@ -256,6 +251,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
loadData(id) {
|
loadData(id) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!this.show) NProgress.start();
|
||||||
|
}, 1000);
|
||||||
getAlbum(id).then(data => {
|
getAlbum(id).then(data => {
|
||||||
this.album = data.album;
|
this.album = data.album;
|
||||||
this.tracks = data.songs;
|
this.tracks = data.songs;
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,6 @@ export default {
|
||||||
ContextMenu,
|
ContextMenu,
|
||||||
},
|
},
|
||||||
beforeRouteUpdate(to, from, next) {
|
beforeRouteUpdate(to, from, next) {
|
||||||
NProgress.start();
|
|
||||||
this.artist.img1v1Url =
|
this.artist.img1v1Url =
|
||||||
'https://p1.music.126.net/VnZiScyynLG7atLIZ2YPkw==/18686200114669622.jpg';
|
'https://p1.music.126.net/VnZiScyynLG7atLIZ2YPkw==/18686200114669622.jpg';
|
||||||
this.loadData(to.params.id, next);
|
this.loadData(to.params.id, next);
|
||||||
|
|
@ -257,9 +256,6 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
|
||||||
this.loadData(this.$route.params.id);
|
|
||||||
},
|
|
||||||
activated() {
|
activated() {
|
||||||
if (this.artist?.id?.toString() !== this.$route.params.id) {
|
if (this.artist?.id?.toString() !== this.$route.params.id) {
|
||||||
this.loadData(this.$route.params.id);
|
this.loadData(this.$route.params.id);
|
||||||
|
|
@ -271,7 +267,9 @@ export default {
|
||||||
...mapMutations(['appendTrackToPlayerList']),
|
...mapMutations(['appendTrackToPlayerList']),
|
||||||
...mapActions(['playFirstTrackOnList', 'playTrackOnListByID', 'showToast']),
|
...mapActions(['playFirstTrackOnList', 'playTrackOnListByID', 'showToast']),
|
||||||
loadData(id, next = undefined) {
|
loadData(id, next = undefined) {
|
||||||
NProgress.start();
|
setTimeout(() => {
|
||||||
|
if (!this.show) NProgress.start();
|
||||||
|
}, 1000);
|
||||||
this.show = false;
|
this.show = false;
|
||||||
this.$parent.$refs.main.scrollTo({ top: 0 });
|
this.$parent.$refs.main.scrollTo({ top: 0 });
|
||||||
getArtist(id).then(data => {
|
getArtist(id).then(data => {
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,12 @@ import ButtonTwoTone from '@/components/ButtonTwoTone.vue';
|
||||||
import MvRow from '@/components/MvRow.vue';
|
import MvRow from '@/components/MvRow.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'artistMV',
|
name: 'ArtistMV',
|
||||||
components: {
|
components: {
|
||||||
MvRow,
|
MvRow,
|
||||||
ButtonTwoTone,
|
ButtonTwoTone,
|
||||||
},
|
},
|
||||||
beforeRouteUpdate(to, from, next) {
|
beforeRouteUpdate(to, from, next) {
|
||||||
NProgress.start();
|
|
||||||
this.id = to.params.id;
|
this.id = to.params.id;
|
||||||
this.loadData();
|
this.loadData();
|
||||||
next();
|
next();
|
||||||
|
|
@ -58,6 +57,9 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadData() {
|
loadData() {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!this.show) NProgress.start();
|
||||||
|
}, 1000);
|
||||||
getArtist(this.id).then(data => {
|
getArtist(this.id).then(data => {
|
||||||
this.artist = data.artist;
|
this.artist = data.artist;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,9 @@ export default {
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.dailyTracks.length === 0) {
|
if (this.dailyTracks.length === 0) {
|
||||||
NProgress.start();
|
setTimeout(() => {
|
||||||
|
if (!this.show) NProgress.start();
|
||||||
|
}, 1000);
|
||||||
this.loadDailyTracks();
|
this.loadDailyTracks();
|
||||||
} else {
|
} else {
|
||||||
this.show = true;
|
this.show = true;
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,6 @@ export default {
|
||||||
SvgIcon,
|
SvgIcon,
|
||||||
},
|
},
|
||||||
beforeRouteUpdate(to, from, next) {
|
beforeRouteUpdate(to, from, next) {
|
||||||
NProgress.start();
|
|
||||||
this.showLoadMoreButton = false;
|
this.showLoadMoreButton = false;
|
||||||
this.hasMore = true;
|
this.hasMore = true;
|
||||||
this.playlists = [];
|
this.playlists = [];
|
||||||
|
|
@ -122,7 +121,9 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(['togglePlaylistCategory']),
|
...mapMutations(['togglePlaylistCategory']),
|
||||||
loadData() {
|
loadData() {
|
||||||
if (!this.show) NProgress.start();
|
setTimeout(() => {
|
||||||
|
if (!this.show) NProgress.start();
|
||||||
|
}, 1000);
|
||||||
this.activeCategory =
|
this.activeCategory =
|
||||||
this.$route.query.category === undefined
|
this.$route.query.category === undefined
|
||||||
? '全部'
|
? '全部'
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,9 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadData() {
|
loadData() {
|
||||||
if (!this.show) NProgress.start();
|
setTimeout(() => {
|
||||||
|
if (!this.show) NProgress.start();
|
||||||
|
}, 1000);
|
||||||
recommendPlaylist({
|
recommendPlaylist({
|
||||||
limit: 10,
|
limit: 10,
|
||||||
}).then(data => {
|
}).then(data => {
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,9 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
NProgress.start();
|
setTimeout(() => {
|
||||||
|
if (!this.show) NProgress.start();
|
||||||
|
}, 1000);
|
||||||
this.loadData();
|
this.loadData();
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
|
|
|
||||||
|
|
@ -407,6 +407,9 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
this.loadData(this.$route.params.id);
|
this.loadData(this.$route.params.id);
|
||||||
}
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!this.show) NProgress.start();
|
||||||
|
}, 1000);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(['appendTrackToPlayerList']),
|
...mapMutations(['appendTrackToPlayerList']),
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,9 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getData() {
|
getData() {
|
||||||
NProgress.start();
|
setTimeout(() => {
|
||||||
|
if (!this.show) NProgress.start();
|
||||||
|
}, 1000);
|
||||||
this.show = false;
|
this.show = false;
|
||||||
|
|
||||||
const requestAll = requests => {
|
const requestAll = requests => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue