From 451fb433eb3b17ee21d9ba2c29720d81f695dacb Mon Sep 17 00:00:00 2001 From: booploops <49113086+booploops@users.noreply.github.com> Date: Thu, 2 Dec 2021 21:41:03 -0800 Subject: [PATCH] can play music and authenticate --- resources/cider-ui-tests/index.js | 2 +- resources/functions/cider-win.js | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/resources/cider-ui-tests/index.js b/resources/cider-ui-tests/index.js index 4b2870f2..c61563a7 100644 --- a/resources/cider-ui-tests/index.js +++ b/resources/cider-ui-tests/index.js @@ -41,7 +41,7 @@ var app = new Vue({ document.addEventListener('musickitloaded', function() { // MusicKit global is now defined MusicKit.configure({ - developerToken: '', + developerToken: 'put key here pls', app: { name: 'My Cool Web App', build: '1978.4.1' diff --git a/resources/functions/cider-win.js b/resources/functions/cider-win.js index 3d0281be..a2143be2 100644 --- a/resources/functions/cider-win.js +++ b/resources/functions/cider-win.js @@ -1,5 +1,8 @@ const {app, BrowserWindow, ipcMain} = require("electron") const {join, resolve} = require("path") +const getPort = require("get-port"); +const express = require("express"); +const path = require("path"); const CiderWin = { CreateBrowserWindow() { @@ -16,26 +19,38 @@ const CiderWin = { plugins: true, nodeIntegration: true, nodeIntegrationInWorker: false, - webSecurity: true, + webSecurity: false, allowRunningInsecureContent: true, enableRemoteModule: true, sandbox: true, nativeWindowOpen: true } } + CiderWin.InitWebServer() if (process.platform === "darwin" || process.platform === "linux") { win = new BrowserWindow(options) } else { const {BrowserWindow} = require("electron-acrylic-window"); win = new BrowserWindow(options) } - let location = join(__dirname, "../cider-ui-tests/index.html") - win.loadFile(location) + + let location = "http://localhost:9000/" + win.loadURL(location) win.on("closed", () => { win = null }) }, - SetupHandlers() { + async InitWebServer() { + const webRemotePort = await getPort({port : 9000}); + const webapp = express(); + const webRemotePath = path.join(__dirname, '../cider-ui-tests/'); + webapp.use(express.static(webRemotePath)); + webapp.get('/', function (req, res) { + res.sendFile(path.join(webRemotePath, 'index.html')); + }); + webapp.listen(webRemotePort, function () { + console.log(`Web Remote listening on port ${webRemotePort}`); + }); } }