mirror of
https://github.com/koel/koel
synced 2024-11-25 05:30:20 +00:00
More refactoring
This commit is contained in:
parent
70464a8977
commit
fbeef63255
2 changed files with 5 additions and 10 deletions
|
@ -9,11 +9,8 @@ import { ls } from '../services'
|
|||
*/
|
||||
export const http = {
|
||||
request (method, url, data, successCb = null, errorCb = null) {
|
||||
axios.request({
|
||||
url,
|
||||
data,
|
||||
method: method.toLowerCase()
|
||||
}).then(successCb).catch(errorCb)
|
||||
method = method.toLowerCase()
|
||||
axios.request({ url, data, method }).then(successCb).catch(errorCb)
|
||||
},
|
||||
|
||||
get (url, successCb = null, errorCb = null) {
|
||||
|
@ -50,9 +47,7 @@ export const http = {
|
|||
|
||||
// …get the token from the header or response data if exists, and save it.
|
||||
const token = response.headers['Authorization'] || response.data['token']
|
||||
if (token) {
|
||||
ls.set('jwt-token', token)
|
||||
}
|
||||
token && ls.set('jwt-token', token)
|
||||
|
||||
return response
|
||||
}, error => {
|
||||
|
|
|
@ -31,10 +31,10 @@ export const sharedStore = {
|
|||
http.get('data', ({ data }) => {
|
||||
assign(this.state, data)
|
||||
// Don't allow downloading on mobile devices
|
||||
this.state.allowDownload = this.state.allowDownload && !isMobile.any
|
||||
this.state.allowDownload &= !isMobile.any
|
||||
|
||||
// Always disable YouTube integration on mobile.
|
||||
this.state.useYouTube = this.state.useYouTube && !isMobile.phone
|
||||
this.state.useYouTube &= !isMobile.phone
|
||||
|
||||
// If this is a new user, initialize his preferences to be an empty object.
|
||||
if (!this.state.currentUser.preferences) {
|
||||
|
|
Loading…
Reference in a new issue