Update vueapp.js

This commit is contained in:
booploops 2022-04-28 22:30:24 -07:00
parent 07f2b3f1a3
commit 4f93124416

View file

@ -972,7 +972,7 @@ const app = new Vue({
async reloadStyles() { async reloadStyles() {
const styles = this.cfg.visual.styles const styles = this.cfg.visual.styles
document.querySelectorAll(`[id*='less']`).forEach(el => { document.querySelectorAll(`[id*='less']`).forEach(el => {
if(el.id != "less:style") { if (el.id != "less:style") {
el.remove() el.remove()
} }
}); });
@ -1255,12 +1255,12 @@ const app = new Vue({
}) })
}, },
copyToClipboard(str) { copyToClipboard(str) {
if (navigator.userAgent.includes('Darwin') || navigator.appVersion.indexOf("Mac") != -1) { // if (navigator.userAgent.includes('Darwin') || navigator.appVersion.indexOf("Mac") != -1) {
this.darwinShare(str) // this.darwinShare(str)
} else { // } else {
notyf.success(app.getLz('term.share.success')) notyf.success(app.getLz('term.share.success'))
navigator.clipboard.writeText(str).then(r => console.log("Copied to clipboard.")) navigator.clipboard.writeText(str).then(r => console.log("Copied to clipboard."))
} // }
}, },
newPlaylist(name = app.getLz('term.newPlaylist'), tracks = []) { newPlaylist(name = app.getLz('term.newPlaylist'), tracks = []) {
let self = this let self = this
@ -1667,7 +1667,7 @@ const app = new Vue({
} }
// if (this.cfg.advanced.experiments.includes('inline-playlists')) { // if (this.cfg.advanced.experiments.includes('inline-playlists')) {
if(false) { if (false) {
let showModal = kind.toString().includes("album") || kind.toString().includes("playlist") let showModal = kind.toString().includes("album") || kind.toString().includes("playlist")
if (app.page.includes("playlist") || app.page.includes("album")) { if (app.page.includes("playlist") || app.page.includes("album")) {
showModal = false showModal = false
@ -2908,7 +2908,7 @@ const app = new Vue({
const track = encodeURIComponent((this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.title ?? '' : ''); const track = encodeURIComponent((this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.title ?? '' : '');
const artist = encodeURIComponent((this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.artistName ?? '' : ''); const artist = encodeURIComponent((this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.artistName ?? '' : '');
const time = encodeURIComponent((this.mk.nowPlayingItem != null) ? (Math.round((this.mk.nowPlayingItem.attributes["durationInMillis"] ?? -1000) / 1000) ?? -1) : -1); const time = encodeURIComponent((this.mk.nowPlayingItem != null) ? (Math.round((this.mk.nowPlayingItem.attributes["durationInMillis"] ?? -1000) / 1000) ?? -1) : -1);
var url = `http://music.163.com/api/search/get/?csrf_token=hlpretag=&hlposttag=&s=${track+" "+artist}&type=1&offset=0&total=true&limit=6`; var url = `http://music.163.com/api/search/get/?csrf_token=hlpretag=&hlposttag=&s=${track + " " + artist}&type=1&offset=0&total=true&limit=6`;
var req = new XMLHttpRequest(); var req = new XMLHttpRequest();
req.overrideMimeType("application/json"); req.overrideMimeType("application/json");
req.open('GET', url, true); req.open('GET', url, true);
@ -2936,7 +2936,8 @@ const app = new Vue({
endTime: end, endTime: end,
line: xline[2], line: xline[2],
translation: '' translation: ''
})} })
}
} }
if (preLrc.length > 0) if (preLrc.length > 0)
preLrc.push({ preLrc.push({
@ -2951,7 +2952,7 @@ const app = new Vue({
app.lyrics = ""; app.lyrics = "";
} }
}; };
req2.onerror = function(){ req2.onerror = function () {
} }
req2.send(); req2.send();
@ -2960,7 +2961,7 @@ const app = new Vue({
} }
}; };
req.send(); req.send();
req.onerror = function(){ req.onerror = function () {
} }
}, },
@ -2969,7 +2970,7 @@ const app = new Vue({
const track = encodeURIComponent((this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.title ?? '' : ''); const track = encodeURIComponent((this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.title ?? '' : '');
const artist = encodeURIComponent((this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.artistName ?? '' : ''); const artist = encodeURIComponent((this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.artistName ?? '' : '');
const time = encodeURIComponent((this.mk.nowPlayingItem != null) ? (Math.round((this.mk.nowPlayingItem.attributes["durationInMillis"] ?? -1000) / 1000) ?? -1) : -1); const time = encodeURIComponent((this.mk.nowPlayingItem != null) ? (Math.round((this.mk.nowPlayingItem.attributes["durationInMillis"] ?? -1000) / 1000) ?? -1) : -1);
var url = `https://c.y.qq.com/soso/fcgi-bin/client_search_cp?w=${track+" "+artist}&t=0&n=1&page=1&cr=1&new_json=1&format=json&platform=yqq.json`; var url = `https://c.y.qq.com/soso/fcgi-bin/client_search_cp?w=${track + " " + artist}&t=0&n=1&page=1&cr=1&new_json=1&format=json&platform=yqq.json`;
var req = new XMLHttpRequest(); var req = new XMLHttpRequest();
req.overrideMimeType("application/json"); req.overrideMimeType("application/json");
@ -2986,14 +2987,14 @@ const app = new Vue({
req2.open('GET', url2, true); req2.open('GET', url2, true);
req2.onload = function () { req2.onload = function () {
try { try {
function b64_to_utf8( str ) { function b64_to_utf8(str) {
return decodeURIComponent(escape(window.atob( str ))); return decodeURIComponent(escape(window.atob(str)));
} }
const htmlDecode = (input) => { const htmlDecode = (input) => {
const doc = new DOMParser().parseFromString(input, "text/html"); const doc = new DOMParser().parseFromString(input, "text/html");
return doc.documentElement.textContent; return doc.documentElement.textContent;
} }
var jsonResponse2 = JSON.parse(req2.responseText.replace("MusicJsonCallback(","").replace("})","}")); var jsonResponse2 = JSON.parse(req2.responseText.replace("MusicJsonCallback(", "").replace("})", "}"));
var lrcfile = htmlDecode(b64_to_utf8(jsonResponse2["lyric"])); var lrcfile = htmlDecode(b64_to_utf8(jsonResponse2["lyric"]));
app.lyricsMediaItem = lrcfile app.lyricsMediaItem = lrcfile
let u = app.lyricsMediaItem.split(/[\n]/); let u = app.lyricsMediaItem.split(/[\n]/);
@ -3008,7 +3009,8 @@ const app = new Vue({
endTime: end, endTime: end,
line: xline[2], line: xline[2],
translation: '' translation: ''
})} })
}
} }
if (preLrc.length > 0) if (preLrc.length > 0)
preLrc.push({ preLrc.push({
@ -3025,7 +3027,7 @@ const app = new Vue({
app.lyrics = ""; app.lyrics = "";
} }
}; };
req2.onerror = function(){ req2.onerror = function () {
app.loadNeteaseLyrics(); app.loadNeteaseLyrics();
} }
req2.send(); req2.send();
@ -3035,7 +3037,7 @@ const app = new Vue({
app.lyrics = ""; app.lyrics = "";
} }
} }
req.onerror = function(){ req.onerror = function () {
app.loadNeteaseLyrics(); app.loadNeteaseLyrics();
} }
req.send(); req.send();
@ -4272,7 +4274,7 @@ const app = new Vue({
document.getElementById('settings.option.general.updateCider.check').innerHTML = app.getLz('term.check') document.getElementById('settings.option.general.updateCider.check').innerHTML = app.getLz('term.check')
}) })
}, },
authCC(){ authCC() {
ipcRenderer.send('cc-auth') ipcRenderer.send('cc-auth')
} }
} }