mirror of
https://github.com/koel/koel
synced 2024-11-24 21:23:06 +00:00
Move shared song logic to router
This commit is contained in:
parent
60440a4578
commit
4f6226d224
2 changed files with 15 additions and 19 deletions
|
@ -25,7 +25,6 @@
|
|||
<script>
|
||||
import Vue from 'vue';
|
||||
import $ from 'jquery';
|
||||
import isMobile from 'ismobilejs';
|
||||
|
||||
import siteHeader from './components/site-header/index.vue';
|
||||
import siteFooter from './components/site-footer/index.vue';
|
||||
|
@ -35,7 +34,7 @@ import loginForm from './components/auth/login-form.vue';
|
|||
import editSongsForm from './components/modals/edit-songs-form.vue';
|
||||
|
||||
import { event, showOverlay, hideOverlay, loadMainView, forceReloadWindow, url } from './utils';
|
||||
import { sharedStore, queueStore, songStore, userStore, preferenceStore as preferences } from './stores';
|
||||
import { sharedStore, songStore, userStore, preferenceStore as preferences } from './stores';
|
||||
import { playback, ls } from './services';
|
||||
import { focusDirective, clickawayDirective } from './directives';
|
||||
import router from './router';
|
||||
|
@ -201,21 +200,6 @@ export default {
|
|||
*/
|
||||
'koel:ready': () => {
|
||||
router.init();
|
||||
|
||||
const songId = url.parseSongId();
|
||||
if (!songId) return;
|
||||
const song = songStore.byId(songId);
|
||||
if (!song) return;
|
||||
|
||||
if (isMobile.apple.device) {
|
||||
// Mobile Safari doesn't allow autoplay, so we just queue.
|
||||
queueStore.queue(song);
|
||||
loadMainView('queue');
|
||||
} else {
|
||||
playback.queueAndPlay(song);
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
});
|
||||
},
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import isMobile from 'ismobilejs';
|
||||
|
||||
import { loadMainView } from './utils';
|
||||
import { artistStore, albumStore, songStore, playlistStore } from './stores';
|
||||
import { artistStore, albumStore, songStore, queueStore, playlistStore } from './stores';
|
||||
import { playback } from './services';
|
||||
|
||||
export default {
|
||||
routes: {
|
||||
|
@ -65,7 +68,16 @@ export default {
|
|||
},
|
||||
|
||||
'/song/([a-z0-9]{32})'(id) {
|
||||
console.log(id)
|
||||
const song = songStore.byId(id);
|
||||
if (!song) return;
|
||||
|
||||
if (isMobile.apple.device) {
|
||||
// Mobile Safari doesn't allow autoplay, so we just queue.
|
||||
queueStore.queue(song);
|
||||
this.go('/#!/queue');
|
||||
} else {
|
||||
playback.queueAndPlay(song);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue