added open themes folder button
This commit is contained in:
parent
f46826d696
commit
b4de904cd0
2 changed files with 47 additions and 21 deletions
|
@ -1,17 +1,18 @@
|
||||||
import { join } from "path";
|
import {join} from "path";
|
||||||
import { app, BrowserWindow as bw, ipcMain, ShareMenu, shell } from "electron";
|
import {app, BrowserWindow as bw, ipcMain, ShareMenu, shell} from "electron";
|
||||||
import * as windowStateKeeper from "electron-window-state";
|
import * as windowStateKeeper from "electron-window-state";
|
||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import * as getPort from "get-port";
|
import * as getPort from "get-port";
|
||||||
import { search } from "youtube-search-without-api-key";
|
import {search} from "youtube-search-without-api-key";
|
||||||
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, statSync } from "fs";
|
import {existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, statSync} from "fs";
|
||||||
import { Stream } from "stream";
|
import {Stream} from "stream";
|
||||||
import { networkInterfaces } from "os";
|
import {networkInterfaces} from "os";
|
||||||
import * as mm from 'music-metadata';
|
import * as mm from 'music-metadata';
|
||||||
import fetch from 'electron-fetch'
|
import fetch from 'electron-fetch'
|
||||||
import { wsapi } from "./wsapi";
|
import {wsapi} from "./wsapi";
|
||||||
import { AppImageUpdater, NsisUpdater } from "electron-updater";
|
import {AppImageUpdater, NsisUpdater} from "electron-updater";
|
||||||
import { utils } from './utils';
|
import {utils} from './utils';
|
||||||
|
|
||||||
const fileWatcher = require('chokidar');
|
const fileWatcher = require('chokidar');
|
||||||
const AdmZip = require("adm-zip");
|
const AdmZip = require("adm-zip");
|
||||||
|
|
||||||
|
@ -219,7 +220,7 @@ export class BrowserWindow {
|
||||||
show: false,
|
show: false,
|
||||||
// backgroundColor: "#1E1E1E",
|
// backgroundColor: "#1E1E1E",
|
||||||
titleBarStyle: 'hidden',
|
titleBarStyle: 'hidden',
|
||||||
trafficLightPosition: { x: 15, y: 20 },
|
trafficLightPosition: {x: 15, y: 20},
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
experimentalFeatures: true,
|
experimentalFeatures: true,
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
|
@ -233,6 +234,7 @@ export class BrowserWindow {
|
||||||
preload: join(utils.getPath('srcPath'), "./preload/cider-preload.js"),
|
preload: join(utils.getPath('srcPath'), "./preload/cider-preload.js"),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
StartWatcher(path: string) {
|
StartWatcher(path: string) {
|
||||||
var chokidar = require("chokidar");
|
var chokidar = require("chokidar");
|
||||||
|
|
||||||
|
@ -272,11 +274,12 @@ export class BrowserWindow {
|
||||||
// console.log('Raw event info:', event, path, details);
|
// console.log('Raw event info:', event, path, details);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the browser window
|
* Creates the browser window
|
||||||
*/
|
*/
|
||||||
async createWindow(): Promise<Electron.BrowserWindow> {
|
async createWindow(): Promise<Electron.BrowserWindow> {
|
||||||
this.clientPort = await getPort({ port: 9000 });
|
this.clientPort = await getPort({port: 9000});
|
||||||
BrowserWindow.verifyFiles();
|
BrowserWindow.verifyFiles();
|
||||||
this.StartWatcher(utils.getPath('themes'));
|
this.StartWatcher(utils.getPath('themes'));
|
||||||
|
|
||||||
|
@ -497,7 +500,7 @@ export class BrowserWindow {
|
||||||
remote.use(express.static(join(utils.getPath('srcPath'), "./web-remote/")))
|
remote.use(express.static(join(utils.getPath('srcPath'), "./web-remote/")))
|
||||||
remote.set("views", join(utils.getPath('srcPath'), "./web-remote/views"));
|
remote.set("views", join(utils.getPath('srcPath'), "./web-remote/views"));
|
||||||
remote.set("view engine", "ejs");
|
remote.set("view engine", "ejs");
|
||||||
getPort({ port: 6942 }).then((port) => {
|
getPort({port: 6942}).then((port) => {
|
||||||
this.remotePort = port;
|
this.remotePort = port;
|
||||||
// Start Remote Discovery
|
// Start Remote Discovery
|
||||||
this.broadcastRemote()
|
this.broadcastRemote()
|
||||||
|
@ -550,7 +553,7 @@ export class BrowserWindow {
|
||||||
if (itspod != null)
|
if (itspod != null)
|
||||||
details.requestHeaders["Cookie"] = `itspod=${itspod}`;
|
details.requestHeaders["Cookie"] = `itspod=${itspod}`;
|
||||||
}
|
}
|
||||||
callback({ requestHeaders: details.requestHeaders });
|
callback({requestHeaders: details.requestHeaders});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -598,7 +601,7 @@ export class BrowserWindow {
|
||||||
// extract the files from the first folder in the zip response
|
// extract the files from the first folder in the zip response
|
||||||
let zip = new AdmZip(await response.buffer());
|
let zip = new AdmZip(await response.buffer());
|
||||||
let entry = zip.getEntries()[0];
|
let entry = zip.getEntries()[0];
|
||||||
if(!existsSync(join(utils.getPath("themes"), "gh_" + apiRepo.id))) {
|
if (!existsSync(join(utils.getPath("themes"), "gh_" + apiRepo.id))) {
|
||||||
mkdirSync(join(utils.getPath("themes"), "gh_" + apiRepo.id));
|
mkdirSync(join(utils.getPath("themes"), "gh_" + apiRepo.id));
|
||||||
}
|
}
|
||||||
console.log(join(utils.getPath("themes"), "gh_" + apiRepo.id))
|
console.log(join(utils.getPath("themes"), "gh_" + apiRepo.id))
|
||||||
|
@ -678,6 +681,21 @@ export class BrowserWindow {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.handle("open-path", async (event, path) => {
|
||||||
|
switch(path) {
|
||||||
|
default:
|
||||||
|
case "plugins":
|
||||||
|
shell.openPath(utils.getPath("plugins"));
|
||||||
|
break;
|
||||||
|
case "userdata":
|
||||||
|
shell.openPath(app.getPath("userData"));
|
||||||
|
break;
|
||||||
|
case "themes":
|
||||||
|
shell.openPath(utils.getPath("themes"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ipcMain.on("get-i18n", (event, key) => {
|
ipcMain.on("get-i18n", (event, key) => {
|
||||||
event.returnValue = utils.getLocale(key);
|
event.returnValue = utils.getLocale(key);
|
||||||
});
|
});
|
||||||
|
@ -834,7 +852,7 @@ export class BrowserWindow {
|
||||||
})
|
})
|
||||||
//Fullscreen
|
//Fullscreen
|
||||||
ipcMain.on('detachDT', (_event, _) => {
|
ipcMain.on('detachDT', (_event, _) => {
|
||||||
BrowserWindow.win.webContents.openDevTools({ mode: 'detach' });
|
BrowserWindow.win.webContents.openDevTools({mode: 'detach'});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -992,8 +1010,8 @@ export class BrowserWindow {
|
||||||
console.log('sc', SoundCheckTag)
|
console.log('sc', SoundCheckTag)
|
||||||
BrowserWindow.win.webContents.send('SoundCheckTag', SoundCheckTag)
|
BrowserWindow.win.webContents.send('SoundCheckTag', SoundCheckTag)
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('check-for-update', async (_event) => {
|
ipcMain.on('check-for-update', async (_event) => {
|
||||||
|
@ -1023,7 +1041,7 @@ export class BrowserWindow {
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('get-version', (_event) => {
|
ipcMain.on('get-version', (_event) => {
|
||||||
if (app.isPackaged){
|
if (app.isPackaged) {
|
||||||
_event.returnValue = app.getVersion()
|
_event.returnValue = app.getVersion()
|
||||||
} else {
|
} else {
|
||||||
_event.returnValue = `Experimental running on Electron ${app.getVersion()}`
|
_event.returnValue = `Experimental running on Electron ${app.getVersion()}`
|
||||||
|
@ -1092,10 +1110,10 @@ export class BrowserWindow {
|
||||||
// Set window Handler
|
// Set window Handler
|
||||||
BrowserWindow.win.webContents.setWindowOpenHandler((x: any) => {
|
BrowserWindow.win.webContents.setWindowOpenHandler((x: any) => {
|
||||||
if (x.url.includes("apple") || x.url.includes("localhost")) {
|
if (x.url.includes("apple") || x.url.includes("localhost")) {
|
||||||
return { action: "allow" };
|
return {action: "allow"};
|
||||||
}
|
}
|
||||||
shell.openExternal(x.url).catch(console.error);
|
shell.openExternal(x.url).catch(console.error);
|
||||||
return { action: "deny" };
|
return {action: "deny"};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1144,7 +1162,7 @@ export class BrowserWindow {
|
||||||
"CtlN": "Cider",
|
"CtlN": "Cider",
|
||||||
"iV": "196623"
|
"iV": "196623"
|
||||||
};
|
};
|
||||||
let server2 = mdns.createAdvertisement(x, `${await getPort({ port: 3839 })}`, {
|
let server2 = mdns.createAdvertisement(x, `${await getPort({port: 3839})}`, {
|
||||||
name: encoded,
|
name: encoded,
|
||||||
txt: txt_record
|
txt: txt_record
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,6 +12,11 @@
|
||||||
<option v-for="theme in themes" :value="theme.file">{{ theme.name }}</option>
|
<option v-for="theme in themes" :value="theme.file">{{ theme.name }}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-auto flex-center">
|
||||||
|
<button class="md-btn md-btn-small md-btn-block" @click="openThemesFolder()">
|
||||||
|
Open Themes Folder
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<div class="col-auto nopadding flex-center">
|
<div class="col-auto nopadding flex-center">
|
||||||
<button class="md-btn md-btn-small md-btn-block" @click="installThemeURL()">
|
<button class="md-btn md-btn-small md-btn-block" @click="installThemeURL()">
|
||||||
{{$root.getLz('settings.option.visual.theme.github.download')}}
|
{{$root.getLz('settings.option.visual.theme.github.download')}}
|
||||||
|
@ -99,6 +104,9 @@
|
||||||
this.getInstalledThemes();
|
this.getInstalledThemes();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
openThemesFolder() {
|
||||||
|
ipcRenderer.invoke("open-path", "themes")
|
||||||
|
},
|
||||||
getInstalledThemes() {
|
getInstalledThemes() {
|
||||||
let self = this
|
let self = this
|
||||||
const themes = ipcRenderer.sendSync("get-themes")
|
const themes = ipcRenderer.sendSync("get-themes")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue