From cabc36fc7f74c3fb4c27b8f3814f441bc68f96b8 Mon Sep 17 00:00:00 2001 From: vapormusic Date: Thu, 7 Jul 2022 00:00:11 +0700 Subject: [PATCH] sometest --- src/main/plugins/discordrpc.ts | 54 ++++++++++++++++++++++++++-------- src/renderer/main/vueapp.js | 1 + src/renderer/style.css | 4 +-- 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/src/main/plugins/discordrpc.ts b/src/main/plugins/discordrpc.ts index cdd78144..37aa9f9b 100644 --- a/src/main/plugins/discordrpc.ts +++ b/src/main/plugins/discordrpc.ts @@ -52,22 +52,50 @@ export default class DiscordRPC { const self = this this.connect(); console.debug(`[Plugin][${this.name}] Ready.`); - ipcMain.on('updateRPCImage', (_event, imageurl) => { + ipcMain.on('updateRPCImage', async (_event, imageurl) => { if (!this._utils.getStoreValue("general.privateEnabled")) { - fetch('https://api.cider.sh/v1/images', { + let b64data = "" + let postbody = "" + if (imageurl.startsWith("/ciderlocalart")){ + let port = await _win.webContents.executeJavaScript( + `app.clientPort` + ); + console.log("http://localhost:"+port+imageurl) + const response = await fetch("http://localhost:"+port+imageurl) + b64data = (await response.buffer()).toString('base64'); + postbody = JSON.stringify({data: b64data}) + fetch('https://cider-api-development.up.railway.app/v1/images', { - method: 'POST', - body: JSON.stringify({url: imageurl}), - headers: { - 'Content-Type': 'application/json', - 'User-Agent': _win.webContents.getUserAgent() - }, - }) - .then(res => res.json()) - .then(function (json) { - self._attributes["artwork"]["url"] = json.url - self.setActivity(self._attributes) + method: 'POST', + body: postbody, + headers: { + 'Content-Type': 'application/json', + 'User-Agent': _win.webContents.getUserAgent() + }, }) + .then(res => res.json()) + .then(function (json) { + self._attributes["artwork"]["url"] = json.url + self.setActivity(self._attributes) + }) + } else { + postbody = JSON.stringify({url: imageurl}) + fetch('https://api.cider.sh/v1/images', { + + method: 'POST', + body: postbody, + headers: { + 'Content-Type': 'application/json', + 'User-Agent': _win.webContents.getUserAgent() + }, + }) + .then(res => res.json()) + .then(function (json) { + self._attributes["artwork"]["url"] = json.url + self.setActivity(self._attributes) + }) + } + } }) ipcMain.on("reloadRPC", () => { diff --git a/src/renderer/main/vueapp.js b/src/renderer/main/vueapp.js index 413ed6f3..19cc6570 100644 --- a/src/renderer/main/vueapp.js +++ b/src/renderer/main/vueapp.js @@ -12,6 +12,7 @@ const app = new Vue({ ipcRenderer: ipcRenderer, cfg: ipcRenderer.sendSync("getStore"), isDev: ipcRenderer.sendSync("is-dev"), + clientPort: ipcRenderer.sendSync("get-port"), drawertest: false, platform: "", mk: {}, diff --git a/src/renderer/style.css b/src/renderer/style.css index 5a563fb4..d96a3ec9 100644 --- a/src/renderer/style.css +++ b/src/renderer/style.css @@ -14045,7 +14045,7 @@ input[type=checkbox][switch]:checked:active::before { display: flex; justify-content: center; align-items: center; - padding-left: 100px; + float: right; } .artist-page .artist-header .animated { width: 100%; @@ -16444,7 +16444,7 @@ input[type="range"].web-slider.display--small::-webkit-slider-thumb { display: flex; justify-content: center; align-items: center; - padding-left: 100px; + float: right; } .about-page .teamBtn { display: flex;