Remove: node on spotify/tips/showOnTL.js #86

This commit is contained in:
Cutls 2019-06-15 02:10:11 +09:00
parent 7da16a7428
commit d146776b17
4 changed files with 75 additions and 86 deletions

View File

@ -38,9 +38,15 @@ onmessage = function (e) {
} else if (e.data[0] == "themeJsonCreate") { } else if (e.data[0] == "themeJsonCreate") {
ipc.send('theme-json-create', e.data[1]); ipc.send('theme-json-create', e.data[1]);
} else if (e.data[0] == "themeJsonRequest") { } else if (e.data[0] == "themeJsonRequest") {
ipc.send('theme-json-request', id); ipc.send('theme-json-request', e.data[1]);
} else if (e.data[0] == "ha") { } else if (e.data[0] == "ha") {
ipc.send('ha', had); ipc.send('ha', had);
} else if (e.data[0] == "itunes") {
if (ipc.listenerCount('itunes-np') > 0) {
return false;
}else{
ipc.send("itunes", e.data[1])
}
} }
} }
//version.js //version.js
@ -215,6 +221,17 @@ ipc.on('theme-json-create-complete', function (event, args) {
clearCustomImport() clearCustomImport()
ctLoad() ctLoad()
}); });
//spotify.js
ipc.once('itunes-np', function (event, arg) {
npCore(arg)
})
//tips.js
ipc.on('memory', function (event, arg) {
var use = arg[0];
var cpu = arg[1];
var total = arg[2]
renderMem(use, cpu, total)
})
/* /*
var webviewDom = document.getElementById('webview'); var webviewDom = document.getElementById('webview');
const { const {

View File

@ -1,21 +1,13 @@
function spotifyConnect() { function spotifyConnect() {
var auth = "https://accounts.spotify.com/authorize?client_id=0f18e54abe0b4aedb4591e353d3aff69&redirect_uri=https://thedesk.top/spotify-connect&response_type=code&scope=user-read-currently-playing"; var auth = "https://accounts.spotify.com/authorize?client_id=0f18e54abe0b4aedb4591e353d3aff69&redirect_uri=https://thedesk.top/spotify-connect&response_type=code&scope=user-read-currently-playing";
const { var platform = localStorage.getItem("platform");
shell
} = require('electron');
var electron = require("electron");
var remote = electron.remote;
var platform = remote.process.platform;
if (platform == "win32") { if (platform == "win32") {
shell.openExternal(auth); postMessage(["openUrl", auth], "*")
var ipc = electron.ipcRenderer; postMessage(["sendSinmpleIpc", "quit"], "*")
ipc.send('quit', 'go');
} else { } else {
auth = auth + "&state=code"; auth = auth + "&state=code";
$("#spotify-code-show").removeClass("hide"); $("#spotify-code-show").removeClass("hide");
shell.openExternal(auth); postMessage(["openUrl", auth], "*")
} }
@ -85,11 +77,9 @@ function nowplaying(mode) {
} }
var item = json.item; var item = json.item;
var img = item.album.images[0].url; var img = item.album.images[0].url;
var electron = require("electron");
var ipc = electron.ipcRenderer;
var flag = localStorage.getItem("artwork"); var flag = localStorage.getItem("artwork");
if (flag) { if (flag) {
ipc.send('bmp-image', [img, 0]); postMessage(["bmpImage", [img, 0]], "*")
} }
var content = localStorage.getItem("np-temp"); var content = localStorage.getItem("np-temp");
if (!content || content == "" || content == "null") { if (!content || content == "" || content == "null") {
@ -121,14 +111,10 @@ function nowplaying(mode) {
alert(lang.lang_spotify_acct); alert(lang.lang_spotify_acct);
} }
} else if (mode == "itunes") { } else if (mode == "itunes") {
var electron = require("electron"); postMessage(["itunes", ""], "*")
var ipc = electron.ipcRenderer;
if (ipc.listenerCount('itunes-np') > 0) {
return false;
} }
}
ipc.send('itunes', ""); function npCore(arg) {
ipc.once('itunes-np', function (event, arg) {
if (arg.cmd) { if (arg.cmd) {
console.error(arg); console.error(arg);
return; return;
@ -139,8 +125,7 @@ function nowplaying(mode) {
var content = "#NowPlaying {song} / {album} / {artist}\n{url}"; var content = "#NowPlaying {song} / {album} / {artist}\n{url}";
} }
var flag = localStorage.getItem("artwork"); var flag = localStorage.getItem("artwork");
var remote = electron.remote; var platform = localStorage.getItem("platform");
var platform = remote.process.platform;
if (platform == "win32") { if (platform == "win32") {
if (flag && arg.path) { if (flag && arg.path) {
media(arg.path, "image/png", "new"); media(arg.path, "image/png", "new");
@ -171,9 +156,6 @@ function nowplaying(mode) {
var regExp = new RegExp("{genre}", "g"); var regExp = new RegExp("{genre}", "g");
content = content.replace(regExp, arg.genre); content = content.replace(regExp, arg.genre);
$("#textarea").val(content); $("#textarea").val(content);
})
}
} }
function spotifySave() { function spotifySave() {
var temp = $("#np-temp").val(); var temp = $("#np-temp").val();
@ -194,9 +176,8 @@ function npprovider() {
M.toast({ html: lang.lang_setting_npprovide.replace("{{set}}", provd), displayLength: 3000 }) M.toast({ html: lang.lang_setting_npprovide.replace("{{set}}", provd), displayLength: 3000 })
} }
localStorage.setItem("np_provider", provd); localStorage.setItem("np_provider", provd);
var electron = require("electron"); postMessage(["itunes", ["set", provd]], "*")
var ipc = electron.ipcRenderer;
ipc.send('itunes', ["set", provd]);
} }
} }
if (location.search) { if (location.search) {

View File

@ -20,9 +20,7 @@ function bottomReverse() {
} }
} }
function tips(mode) { function tips(mode) {
var electron = require("electron"); postMessage(["sendSinmpleIpc", "endmem"], "*")
var ipc = electron.ipcRenderer;
ipc.send('endmem', "");
clearInterval(clockint); clearInterval(clockint);
clearInterval(spotStart); clearInterval(spotStart);
if (mode == "ver") { if (mode == "ver") {
@ -50,15 +48,10 @@ function tips(mode) {
} }
//メモリ //メモリ
function startmem() { function startmem() {
var electron = require("electron"); postMessage(["sendSinmpleIpc", "startmem"], "*")
var ipc = electron.ipcRenderer; }
ipc.send('startmem', ""); function renderMem(use, cpu, total){
ipc.on('memory', function (event, arg) {
var use = arg[0];
var cpu = arg[1];
var total = arg[2]
$("#tips-text").html(escapeHTML(cpu) + "<br>Memory:" + Math.floor(use / 1024 / 1024 / 102.4) / 10 + "/" + Math.floor(total / 1024 / 1024 / 102.4) / 10 + "GB(" + Math.floor(use / total * 100) + "%)") $("#tips-text").html(escapeHTML(cpu) + "<br>Memory:" + Math.floor(use / 1024 / 1024 / 102.4) / 10 + "/" + Math.floor(total / 1024 / 1024 / 102.4) / 10 + "GB(" + Math.floor(use / total * 100) + "%)")
})
} }
//トレンドタグ //トレンドタグ
function trendTagonTip() { function trendTagonTip() {

View File

@ -40,9 +40,7 @@ function udgEx(user, acct_id) {
var id = json.accounts[0].id; var id = json.accounts[0].id;
udg(id, acct_id); udg(id, acct_id);
} else { } else {
var url = "https://" + user.split('@')[1] + "/@" + user.split('@')[0]; postMessage(["openUrl", url], "*")
const { shell } = require('electron');
shell.openExternal(url);
} }
}); });
return true; return true;