Big refactor

This commit is contained in:
Phan An 2018-01-30 00:13:54 +01:00
parent 2f65fe6642
commit a2ee56df4d
40 changed files with 88 additions and 106 deletions

View file

@ -17,15 +17,6 @@
"presets": [
"es2015",
"stage-0"
],
"plugins": [
[
"babel-plugin-root-import",
{
"rootPathSuffix": "resources/assets/js",
"rootPathPrefix": "@"
}
]
]
},
"eslintConfig": {
@ -59,7 +50,6 @@
"babel-core": "^6.26.0",
"babel-eslint": "^7.2.3",
"babel-loader": "^7.1.2",
"babel-plugin-root-import": "^5.1.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.23.0",
"babel-preset-stage-0": "^6.24.1",

View file

@ -67,7 +67,7 @@ export default {
// Add an ugly mac/non-mac class for OS-targeting styles.
// I'm crying inside.
$.addClass(document.documentElement, navigator.userAgent.indexOf('Mac') !== -1 ? 'mac' : 'non-mac')
$.addClass(document.documentElement, navigator.userAgent.includes('Mac') ? 'mac' : 'non-mac')
},
methods: {

View file

@ -37,9 +37,9 @@ export default {
</script>
<style lang="scss" scoped>
@import "../../../sass/partials/_vars.scss";
@import "../../../sass/partials/_mixins.scss";
@import "../../../sass/partials/_shared.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
@import "~#/partials/_shared.scss";
/**
* I like to move it move it

View file

@ -48,7 +48,7 @@ export default {
mode: {
type: String,
default: 'sidebar',
validator: value => ['sidebar', 'full'].indexOf(value) !== -1
validator: value => ['sidebar', 'full'].includes(value)
}
},
components: { trackListItem },
@ -96,8 +96,8 @@ export default {
</script>
<style lang="scss">
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
#albumInfo {
@include artist-album-info();

View file

@ -37,7 +37,7 @@ export default {
mode: {
type: String,
default: 'sidebar',
validator: value => ['sidebar', 'full'].indexOf(value) !== -1
validator: value => ['sidebar', 'full'].includes(value)
}
},
@ -79,8 +79,8 @@ export default {
</script>
<style lang="scss">
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
#artistInfo {
@include artist-album-info();

View file

@ -125,8 +125,8 @@ export default {
</script>
<style lang="scss">
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
#extra {
flex: 0 0 $extraPanelWidth;

View file

@ -19,6 +19,6 @@ export default {
</script>
<style lang="scss">
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
</style>

View file

@ -56,7 +56,7 @@ import { playback, download, albumInfo as albumInfoService } from '@/services'
import router from '@/router'
import hasSongList from '@/mixins/has-song-list'
import albumAttributes from '@/mixins/album-attributes'
import albumInfo from '../extra/album-info.vue'
import albumInfo from '@/components/main-wrapper/extra/album-info.vue'
import soundBar from '@/components/shared/sound-bar.vue'
export default {
@ -148,8 +148,8 @@ export default {
</script>
<style lang="scss" scoped>
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
#albumWrapper {
button.play-shuffle {

View file

@ -63,8 +63,8 @@ export default {
</script>
<style lang="scss">
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
#albumsWrapper {
.albums {

View file

@ -49,14 +49,14 @@
</template>
<script>
import { pluralize, event } from '../../../utils'
import { sharedStore, artistStore } from '../../../stores'
import { playback, download, artistInfo as artistInfoService } from '../../../services'
import router from '../../../router'
import hasSongList from '../../../mixins/has-song-list'
import artistAttributes from '../../../mixins/artist-attributes'
import artistInfo from '../extra/artist-info.vue'
import soundBar from '../../shared/sound-bar.vue'
import { pluralize, event } from '@/utils'
import { sharedStore, artistStore } from '@/stores'
import { playback, download, artistInfo as artistInfoService } from '@/services'
import router from '@/router'
import hasSongList from '@/mixins/has-song-list'
import artistAttributes from '@/mixins/artist-attributes'
import artistInfo from '@/components/main-wrapper/extra/artist-info.vue'
import soundBar from '@/components/shared/sound-bar.vue'
export default {
name: 'main-wrapper--main-content--artist',
@ -142,8 +142,8 @@ export default {
</script>
<style lang="scss" scoped>
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
#artistWrapper {
button.play-shuffle {

View file

@ -66,8 +66,8 @@ export default {
</script>
<style lang="scss">
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
#artistsWrapper {
.artists {

View file

@ -66,8 +66,8 @@ export default {
</script>
<style lang="scss">
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
#favoritesWrapper {
.none {

View file

@ -158,8 +158,8 @@ export default {
</script>
<style lang="scss">
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
#homeWrapper {
.two-cols {

View file

@ -69,8 +69,8 @@ export default {
</script>
<style lang="scss">
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
#mainContent {
flex: 1;

View file

@ -144,8 +144,8 @@ export default {
</script>
<style lang="scss">
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
#playlistWrapper {
button.play-shuffle, button.del {

View file

@ -193,8 +193,8 @@ export default {
</script>
<style lang="scss">
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
#profileWrapper {
input {

View file

@ -82,8 +82,8 @@ export default {
</script>
<style lang="scss">
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
#queueWrapper {
.none {

View file

@ -88,8 +88,8 @@ export default {
</script>
<style lang="scss">
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
#settingsWrapper {
input[type="text"] {

View file

@ -43,7 +43,7 @@ export default {
</script>
<style lang="scss">
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
</style>

View file

@ -66,8 +66,8 @@ export default {
</script>
<style lang="scss">
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
#usersWrapper {
.users {

View file

@ -64,8 +64,8 @@ export default {
</script>
<style lang="scss" scoped>
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
.none {
color: $color2ndText;

View file

@ -155,8 +155,8 @@ export default {
</script>
<style lang="scss">
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
#sidebar {
flex: 0 0 256px;

View file

@ -34,7 +34,7 @@ export default {
type: {
type: String,
default: 'playlist',
validator: value => ['playlist', 'favorites'].indexOf(value) !== -1
validator: value => ['playlist', 'favorites'].includes(value)
}
},
@ -167,8 +167,8 @@ export default {
</script>
<style lang="scss" scoped>
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
.playlist {
user-select: none;

View file

@ -16,9 +16,9 @@
<ul class="menu">
<playlist-item type="favorites" :playlist="{ name: 'Favorites', songs: favoriteState.songs }"/>
<playlist-item
v-for="playlist in playlistState.playlists"
type="playlist"
<playlist-item
v-for="playlist in playlistState.playlists"
type="playlist"
:playlist="playlist"
:key="playlist.id"/>
</ul>
@ -61,8 +61,8 @@ export default {
</script>
<style lang="scss">
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
@import "~#/partials/_vars.scss";
@import "~#/partials/_mixins.scss";
#playlists {
.control.create {

View file

@ -31,7 +31,7 @@
<script>
import { clone } from 'lodash'
import soundBar from '../shared/sound-bar.vue'
import soundBar from '@/components/shared/sound-bar.vue'
import { userStore } from '@/stores'
export default {

View file

@ -84,8 +84,8 @@ import { songInfo } from '@/services/info'
import { artistStore, albumStore, songStore } from '@/stores'
import config from '@/config'
import soundBar from '../shared/sound-bar.vue'
import typeahead from '../shared/typeahead.vue'
import soundBar from '@/components/shared/sound-bar.vue'
import typeahead from '@/components/shared/typeahead.vue'
const COMPILATION_STATES = {
NONE: 0, // No songs belong to a compilation album

View file

@ -31,7 +31,7 @@
<script>
import { clone } from 'lodash'
import soundBar from '../shared/sound-bar.vue'
import soundBar from '@/components/shared/sound-bar.vue'
import { userStore } from '@/stores'
export default {

View file

@ -39,7 +39,6 @@
</template>
<script>
import { assign } from 'lodash'
import addToMenu from './add-to-menu.vue'
export default {
@ -83,7 +82,7 @@ export default {
},
mounted () {
assign(this.fullConfig, this.config)
this.fullConfig = Object.assign(this.fullConfig, this.config)
},
methods: {

View file

@ -49,7 +49,6 @@
<script>
import isMobile from 'ismobilejs'
import { each } from 'lodash'
import { filterBy, orderBy, event, pluralize, $ } from '@/utils'
import { playlistStore, queueStore, songStore, favoriteStore } from '@/stores'
@ -286,7 +285,7 @@ export default {
* Select all (filtered) rows in the current list.
*/
selectAllRows () {
each(this.filteredItems, row => {
this.filteredItems.forEach(row => {
row.selected = true
})
},
@ -352,7 +351,7 @@ export default {
* Clear the current selection on this song list.
*/
clearSelection () {
each(this.filteredItems, row => {
this.filteredItems.forEach(row => {
row.selected = false
})
},

View file

@ -28,7 +28,7 @@
</template>
<script>
import { map, cloneDeep, each } from 'lodash'
import { cloneDeep } from 'lodash'
import nouislider from 'nouislider'
import { isAudioContextSupported, event, $ } from '@/utils'
@ -98,7 +98,7 @@ export default {
// Create 10 bands with the frequencies similar to those of Winamp and connect them together.
const frequencies = [60, 170, 310, 600, 1000, 3000, 6000, 12000, 14000, 16000]
each(frequencies, (frequency, i) => {
frequencies.forEach((frequency, i) => {
const filter = context.createBiquadFilter()
if (i === 0) {
@ -132,7 +132,7 @@ export default {
*/
createSliders () {
const config = equalizerStore.get()
each(Array.from(document.querySelectorAll('#equalizer .slider')), (el, i) => {
Array.from(document.querySelectorAll('#equalizer .slider')).forEach((el, i) => {
nouislider.create(el, {
connect: [false, true],
// the first element is the preamp. The rest are gains.
@ -192,7 +192,7 @@ export default {
* Load a preset when the user select it from the dropdown.
*/
loadPreset (preset) {
each(Array.from(document.querySelectorAll('#equalizer .slider')), (el, i) => {
Array.from(document.querySelectorAll('#equalizer .slider')).forEach((el, i) => {
// We treat our preamp slider differently.
if ($.is(el.parentNode, '.preamp')) {
this.changePreampGain(preset.preamp)
@ -212,7 +212,7 @@ export default {
* Save the current user's equalizer preferences into local storage.
*/
save () {
equalizerStore.set(this.preampGainValue, map(this.bands, 'filter.gain.value'))
equalizerStore.set(this.preampGainValue, this.bands.map(band => band.filter.gain.value))
}
},

View file

@ -3,9 +3,7 @@ import { secondsToHis } from '@/utils'
export default {
computed: {
length () {
return this.album.songs.reduce((acc, song) => {
return acc + song.length
}, 0)
return this.album.songs.reduce((acc, song) => acc + song.length, 0)
},
fmtLength () {

View file

@ -46,7 +46,7 @@ export const download = {
* Download all favorite songs.
*/
fromFavorites () {
return favoriteStore.all.length ? this.trigger('favorites') : null
return favoriteStore.all.length ? this.trigger('favorites') : null
},
/**
@ -56,7 +56,7 @@ export const download = {
* artist, playlist, or album.
*/
trigger (uri) {
const sep = uri.indexOf('?') === -1 ? '?' : '&'
const sep = uri.includes('?') ? '&' : '?'
const iframe = document.createElement('iframe')
iframe.style.display = 'none'
iframe.setAttribute('src', `${window.BASE_URL}api/download/${uri}${sep}jwt-token=${ls.get('jwt-token')}`)

View file

@ -9,8 +9,7 @@ import { ls } from '@/services'
*/
export const http = {
request (method, url, data, successCb = null, errorCb = null) {
method = method.toLowerCase()
axios.request({ url, data, method }).then(successCb).catch(errorCb)
axios.request({ url, data, method: method.toLowerCase() }).then(successCb).catch(errorCb)
},
get (url, successCb = null, errorCb = null) {

View file

@ -10,8 +10,8 @@ export const youtube = {
*/
searchVideosRelatedToSong (song) {
song.youtube = song.youtube || {}
const pageToken = song.youtube.nextPageToken || ''
return new Promise((resolve, reject) => {
http.get(`youtube/search/song/${song.id}?pageToken=${pageToken}`,
({ data: { nextPageToken, items }}) => {

View file

@ -67,7 +67,7 @@ export const albumStore = {
* @param {Array.<Object>|Object} albums
*/
add (albums) {
[].concat(albums).forEach(album => {
[].concat(albums).forEach(album => {
this.setupAlbum(album, album.artist)
album.playCount = album.songs.reduce((count, song) => count + song.playCount, 0)
})

View file

@ -26,7 +26,7 @@ export const preferenceStore = {
* @param {Object} user The user whose preferences we are managing.
*/
init (user = null) {
user = user ||userStore.current
user = user || userStore.current
this.storeKey = `preferences_${user.id}`
this.state = Object.assign(this.state, ls.get(this.storeKey, this.state))
this.setupProxy()

View file

@ -1,4 +1,4 @@
import { each, isObject, isNumber, get } from 'lodash'
import { isObject, isNumber, get } from 'lodash'
export function orderBy (arr, sortKey, reverse) {
if (!sortKey) {
@ -63,9 +63,9 @@ export function filterBy (arr, search, ...keys) {
const res = []
each(arr, item => {
each(keys, key => {
if (`${get(item, key)}`.toLowerCase().indexOf(search) !== -1) {
arr.forEach(item => {
keys.forEach(key => {
if (`${get(item, key)}`.toLowerCase().includes(search)) {
res.push(item)
return false
}

View file

@ -3,7 +3,8 @@ const path = require('path')
module.exports = {
resolve: {
alias: {
'@': path.resolve(__dirname, 'resources/assets/js')
'@': path.resolve(__dirname, 'resources/assets/js'),
'#': path.resolve(__dirname, 'resources/assets/sass')
}
},
module: {

View file

@ -1,6 +1,8 @@
const mix = require('laravel-mix')
const fs = require('fs')
const resolve = require('./webpack.config.js').resolve
mix.webpackConfig({ resolve })
mix.setResourceRoot('./public/')
mix.config.detectHotReloading()

View file

@ -564,12 +564,6 @@ babel-plugin-check-es2015-constants@^6.22.0:
dependencies:
babel-runtime "^6.22.0"
babel-plugin-root-import@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/babel-plugin-root-import/-/babel-plugin-root-import-5.1.0.tgz#80ea1cd5945b463a5e3f7e204a69478c573e328c"
dependencies:
slash "^1.0.0"
babel-plugin-syntax-async-functions@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95"