mirror of
https://github.com/qier222/YesPlayMusic.git
synced 2024-11-22 12:15:54 +08:00
fix: retry when personalFM not found data (#1231)
* fix: retry when personalFM not found data * fix * fix: retry count
This commit is contained in:
parent
d716bb8cde
commit
75fed70c38
|
@ -15,6 +15,12 @@ const electron =
|
||||||
process.env.IS_ELECTRON === true ? window.require('electron') : null;
|
process.env.IS_ELECTRON === true ? window.require('electron') : null;
|
||||||
const ipcRenderer =
|
const ipcRenderer =
|
||||||
process.env.IS_ELECTRON === true ? electron.ipcRenderer : null;
|
process.env.IS_ELECTRON === true ? electron.ipcRenderer : null;
|
||||||
|
const delay = ms =>
|
||||||
|
new Promise(resolve => {
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve('');
|
||||||
|
}, ms);
|
||||||
|
});
|
||||||
const excludeSaveKeys = [
|
const excludeSaveKeys = [
|
||||||
'_playing',
|
'_playing',
|
||||||
'_personalFMLoading',
|
'_personalFMLoading',
|
||||||
|
@ -577,10 +583,27 @@ export default class {
|
||||||
this._isPersonalFM = true;
|
this._isPersonalFM = true;
|
||||||
if (!this._personalFMNextTrack) {
|
if (!this._personalFMNextTrack) {
|
||||||
this._personalFMLoading = true;
|
this._personalFMLoading = true;
|
||||||
let result = await personalFM().catch(() => null);
|
let result = null;
|
||||||
|
let retryCount = 5;
|
||||||
|
for (; retryCount >= 0; retryCount--) {
|
||||||
|
result = await personalFM().catch(() => null);
|
||||||
|
if (!result) {
|
||||||
|
this._personalFMLoading = false;
|
||||||
|
store.dispatch('showToast', 'personal fm timeout');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (result.data?.length > 0) {
|
||||||
|
break;
|
||||||
|
} else if (retryCount > 0) {
|
||||||
|
await delay(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
this._personalFMLoading = false;
|
this._personalFMLoading = false;
|
||||||
if (!result || !result.data) {
|
|
||||||
store.dispatch('showToast', 'personal fm timeout');
|
if (retryCount < 0) {
|
||||||
|
let content = '获取私人FM数据时重试次数过多,请手动切换下一首';
|
||||||
|
store.dispatch('showToast', content);
|
||||||
|
console.log(content);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 这里只能拿到一条数据
|
// 这里只能拿到一条数据
|
||||||
|
|
Loading…
Reference in New Issue
Block a user