mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
Merge branch 'master' into edit
This commit is contained in:
commit
3dadb7d741
3 changed files with 14 additions and 11 deletions
|
@ -2,19 +2,14 @@ import Vue from 'vue';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responsible for all HTTP requests.
|
* Responsible for all HTTP requests.
|
||||||
*
|
|
||||||
* IMPORTANT:
|
|
||||||
* If the user has a good enough connection to stream music, he or she shouldn't
|
|
||||||
* encounter any HTTP errors. That's why Koel doesn't handle HTTP errors.
|
|
||||||
* After all, even if there were errors, how bad can it be?
|
|
||||||
*/
|
*/
|
||||||
export default {
|
export default {
|
||||||
request(method, url, data, successCb = null, errorCb = null) {
|
request(method, url, data, successCb = null, errorCb = null) {
|
||||||
return Vue.http[method](url, data).then(successCb, errorCb);
|
return Vue.http[method](url, data).then(successCb).catch(errorCb);
|
||||||
},
|
},
|
||||||
|
|
||||||
get(url, data = {}, successCb = null, errorCb = null) {
|
get(url, successCb = null, errorCb = null) {
|
||||||
return this.request('get', url, data, successCb, errorCb);
|
return this.request('get', url, {}, successCb, errorCb);
|
||||||
},
|
},
|
||||||
|
|
||||||
post(url, data, successCb = null, errorCb = null) {
|
post(url, data, successCb = null, errorCb = null) {
|
||||||
|
|
|
@ -30,7 +30,9 @@ export default {
|
||||||
init(successCb = null, errorCb = null) {
|
init(successCb = null, errorCb = null) {
|
||||||
this.reset();
|
this.reset();
|
||||||
|
|
||||||
http.get('data', data => {
|
http.get('data', response => {
|
||||||
|
var data = response.data;
|
||||||
|
|
||||||
assign(this.state, data);
|
assign(this.state, data);
|
||||||
|
|
||||||
// If this is a new user, initialize his preferences to be an empty object.
|
// If this is a new user, initialize his preferences to be an empty object.
|
||||||
|
@ -47,7 +49,11 @@ export default {
|
||||||
settingStore.init(this.state.settings);
|
settingStore.init(this.state.settings);
|
||||||
|
|
||||||
window.useLastfm = this.state.useLastfm = data.useLastfm;
|
window.useLastfm = this.state.useLastfm = data.useLastfm;
|
||||||
}, successCb, errorCb);
|
|
||||||
|
if (successCb) {
|
||||||
|
successCb();
|
||||||
|
}
|
||||||
|
}, errorCb);
|
||||||
},
|
},
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
|
|
|
@ -180,7 +180,9 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
http.get(`${song.id}/info`, data => {
|
http.get(`${song.id}/info`, response => {
|
||||||
|
var data = response.data;
|
||||||
|
|
||||||
song.lyrics = data.lyrics;
|
song.lyrics = data.lyrics;
|
||||||
|
|
||||||
// If the artist image is not in a nice form, don't use it.
|
// If the artist image is not in a nice form, don't use it.
|
||||||
|
|
Loading…
Reference in a new issue