beginning of adding history routing
This commit is contained in:
parent
f6a5d19d52
commit
27f49fc8e8
1 changed files with 38 additions and 6 deletions
|
@ -233,7 +233,8 @@ const app = new Vue({
|
||||||
pageHistory: [],
|
pageHistory: [],
|
||||||
songstest: false,
|
songstest: false,
|
||||||
hangtimer: null,
|
hangtimer: null,
|
||||||
selectedMediaItems: []
|
selectedMediaItems: [],
|
||||||
|
routes: ["browse", "listen_now", "radio"]
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
page: () => {
|
page: () => {
|
||||||
|
@ -257,7 +258,7 @@ const app = new Vue({
|
||||||
this.mk.authorize()
|
this.mk.authorize()
|
||||||
this.$forceUpdate()
|
this.$forceUpdate()
|
||||||
this.mk.privateEnabled = true
|
this.mk.privateEnabled = true
|
||||||
this.platform = ipcRenderer.sendSync('cider-platform');
|
// this.platform = ipcRenderer.sendSync('cider-platform');
|
||||||
// Set profile name
|
// Set profile name
|
||||||
this.chrome.userinfo = await this.mkapi("personalSocialProfile", false, "")
|
this.chrome.userinfo = await this.mkapi("personalSocialProfile", false, "")
|
||||||
// API Fallback
|
// API Fallback
|
||||||
|
@ -356,6 +357,9 @@ const app = new Vue({
|
||||||
self.playlists.listing = res.data
|
self.playlists.listing = res.data
|
||||||
})
|
})
|
||||||
document.body.removeAttribute("loading")
|
document.body.removeAttribute("loading")
|
||||||
|
if(window.location.hash != "") {
|
||||||
|
this.appRoute(window.location.hash)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
invokeDrawer(panel) {
|
invokeDrawer(panel) {
|
||||||
if(this.drawer.panel == panel && this.drawer.open) {
|
if(this.drawer.panel == panel && this.drawer.open) {
|
||||||
|
@ -541,6 +545,29 @@ const app = new Vue({
|
||||||
}
|
}
|
||||||
return hash;
|
return hash;
|
||||||
},
|
},
|
||||||
|
appRoute(route) {
|
||||||
|
if(route == "" || route == "#" || route == "/") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
route = route.replace(/#/g, "")
|
||||||
|
// if the route contains does not include a / then route to the page directly
|
||||||
|
if (route.indexOf("/") == -1) {
|
||||||
|
this.page = route
|
||||||
|
window.location.hash = `${page}/${id}`
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let hash = route.split("/")
|
||||||
|
let page = hash[0]
|
||||||
|
let id = hash[1]
|
||||||
|
console.log(`page: ${page} id: ${id}`)
|
||||||
|
this.routeView({
|
||||||
|
kind: page,
|
||||||
|
id: id,
|
||||||
|
attributes: {
|
||||||
|
playParams: {kind: page, id: id}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
routeView(item) {
|
routeView(item) {
|
||||||
let self = this
|
let self = this
|
||||||
|
|
||||||
|
@ -575,12 +602,14 @@ const app = new Vue({
|
||||||
}
|
}
|
||||||
document.querySelector("#app-content").scrollTop = 0
|
document.querySelector("#app-content").scrollTop = 0
|
||||||
}
|
}
|
||||||
|
window.location.hash = `${kind}/${id}`
|
||||||
},
|
},
|
||||||
async getNowPlayingItemDetailed(target) {
|
async getNowPlayingItemDetailed(target) {
|
||||||
let u = await app.mkapi(app.mk.nowPlayingItem.playParams.kind, (app.mk.nowPlayingItem.songId == -1), (app.mk.nowPlayingItem.songId != -1) ? app.mk.nowPlayingItem.songId : app.mk.nowPlayingItem["id"], {"include[songs]": "albums,artists"});
|
let u = await app.mkapi(app.mk.nowPlayingItem.playParams.kind, (app.mk.nowPlayingItem.songId == -1), (app.mk.nowPlayingItem.songId != -1) ? app.mk.nowPlayingItem.songId : app.mk.nowPlayingItem["id"], {"include[songs]": "albums,artists"});
|
||||||
app.searchAndNavigate(u, target)
|
app.searchAndNavigate(u, target)
|
||||||
},
|
},
|
||||||
async searchAndNavigate(item, target) {
|
async searchAndNavigate(item, target) {
|
||||||
|
let self = this
|
||||||
app.tmpVar = item;
|
app.tmpVar = item;
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case "artist":
|
case "artist":
|
||||||
|
@ -615,7 +644,7 @@ const app = new Vue({
|
||||||
}
|
}
|
||||||
console.log(artistId);
|
console.log(artistId);
|
||||||
if (artistId != "")
|
if (artistId != "")
|
||||||
app.getArtistFromID(artistId);
|
self.appRoute(`artist/${artistId}`)
|
||||||
break;
|
break;
|
||||||
case "album":
|
case "album":
|
||||||
let albumId = '';
|
let albumId = '';
|
||||||
|
@ -642,8 +671,7 @@ const app = new Vue({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (albumId != "") {
|
if (albumId != "") {
|
||||||
app.getTypeFromID("album", albumId, false);
|
self.appRoute(`album/${albumId}`)
|
||||||
app.page = "album_" + albumId;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "recordLabel":
|
case "recordLabel":
|
||||||
|
@ -668,7 +696,6 @@ const app = new Vue({
|
||||||
}
|
}
|
||||||
if (labelId != "") {
|
if (labelId != "") {
|
||||||
app.showingPlaylist = []
|
app.showingPlaylist = []
|
||||||
|
|
||||||
await app.getTypeFromID("recordLabel", labelId, false, {views: 'top-releases,latest-releases,top-artists'});
|
await app.getTypeFromID("recordLabel", labelId, false, {views: 'top-releases,latest-releases,top-artists'});
|
||||||
app.page = "recordLabel_" + labelId;
|
app.page = "recordLabel_" + labelId;
|
||||||
}
|
}
|
||||||
|
@ -1818,6 +1845,11 @@ app.hangtimer = setTimeout(()=>{
|
||||||
}
|
}
|
||||||
}, 10000)
|
}, 10000)
|
||||||
|
|
||||||
|
// add event listener for when window.location.hash changes
|
||||||
|
window.addEventListener("hashchange", function () {
|
||||||
|
app.appRoute(window.location.hash)
|
||||||
|
});
|
||||||
|
|
||||||
document.addEventListener('musickitloaded', function () {
|
document.addEventListener('musickitloaded', function () {
|
||||||
// MusicKit global is now defined
|
// MusicKit global is now defined
|
||||||
function initMusicKit() {
|
function initMusicKit() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue