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 { app, BrowserWindow as bw, ipcMain, ShareMenu, shell } from "electron";
|
||||
import {join} from "path";
|
||||
import {app, BrowserWindow as bw, ipcMain, ShareMenu, shell} from "electron";
|
||||
import * as windowStateKeeper from "electron-window-state";
|
||||
import * as express from "express";
|
||||
import * as getPort from "get-port";
|
||||
import { search } from "youtube-search-without-api-key";
|
||||
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, statSync } from "fs";
|
||||
import { Stream } from "stream";
|
||||
import { networkInterfaces } from "os";
|
||||
import {search} from "youtube-search-without-api-key";
|
||||
import {existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, statSync} from "fs";
|
||||
import {Stream} from "stream";
|
||||
import {networkInterfaces} from "os";
|
||||
import * as mm from 'music-metadata';
|
||||
import fetch from 'electron-fetch'
|
||||
import { wsapi } from "./wsapi";
|
||||
import { AppImageUpdater, NsisUpdater } from "electron-updater";
|
||||
import { utils } from './utils';
|
||||
import {wsapi} from "./wsapi";
|
||||
import {AppImageUpdater, NsisUpdater} from "electron-updater";
|
||||
import {utils} from './utils';
|
||||
|
||||
const fileWatcher = require('chokidar');
|
||||
const AdmZip = require("adm-zip");
|
||||
|
||||
|
@ -219,7 +220,7 @@ export class BrowserWindow {
|
|||
show: false,
|
||||
// backgroundColor: "#1E1E1E",
|
||||
titleBarStyle: 'hidden',
|
||||
trafficLightPosition: { x: 15, y: 20 },
|
||||
trafficLightPosition: {x: 15, y: 20},
|
||||
webPreferences: {
|
||||
experimentalFeatures: true,
|
||||
nodeIntegration: true,
|
||||
|
@ -233,6 +234,7 @@ export class BrowserWindow {
|
|||
preload: join(utils.getPath('srcPath'), "./preload/cider-preload.js"),
|
||||
},
|
||||
};
|
||||
|
||||
StartWatcher(path: string) {
|
||||
var chokidar = require("chokidar");
|
||||
|
||||
|
@ -272,11 +274,12 @@ export class BrowserWindow {
|
|||
// console.log('Raw event info:', event, path, details);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the browser window
|
||||
*/
|
||||
async createWindow(): Promise<Electron.BrowserWindow> {
|
||||
this.clientPort = await getPort({ port: 9000 });
|
||||
this.clientPort = await getPort({port: 9000});
|
||||
BrowserWindow.verifyFiles();
|
||||
this.StartWatcher(utils.getPath('themes'));
|
||||
|
||||
|
@ -497,7 +500,7 @@ export class BrowserWindow {
|
|||
remote.use(express.static(join(utils.getPath('srcPath'), "./web-remote/")))
|
||||
remote.set("views", join(utils.getPath('srcPath'), "./web-remote/views"));
|
||||
remote.set("view engine", "ejs");
|
||||
getPort({ port: 6942 }).then((port) => {
|
||||
getPort({port: 6942}).then((port) => {
|
||||
this.remotePort = port;
|
||||
// Start Remote Discovery
|
||||
this.broadcastRemote()
|
||||
|
@ -550,7 +553,7 @@ export class BrowserWindow {
|
|||
if (itspod != null)
|
||||
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
|
||||
let zip = new AdmZip(await response.buffer());
|
||||
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));
|
||||
}
|
||||
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) => {
|
||||
event.returnValue = utils.getLocale(key);
|
||||
});
|
||||
|
@ -834,7 +852,7 @@ export class BrowserWindow {
|
|||
})
|
||||
//Fullscreen
|
||||
ipcMain.on('detachDT', (_event, _) => {
|
||||
BrowserWindow.win.webContents.openDevTools({ mode: 'detach' });
|
||||
BrowserWindow.win.webContents.openDevTools({mode: 'detach'});
|
||||
})
|
||||
|
||||
|
||||
|
@ -1023,7 +1041,7 @@ export class BrowserWindow {
|
|||
})
|
||||
|
||||
ipcMain.on('get-version', (_event) => {
|
||||
if (app.isPackaged){
|
||||
if (app.isPackaged) {
|
||||
_event.returnValue = app.getVersion()
|
||||
} else {
|
||||
_event.returnValue = `Experimental running on Electron ${app.getVersion()}`
|
||||
|
@ -1092,10 +1110,10 @@ export class BrowserWindow {
|
|||
// Set window Handler
|
||||
BrowserWindow.win.webContents.setWindowOpenHandler((x: any) => {
|
||||
if (x.url.includes("apple") || x.url.includes("localhost")) {
|
||||
return { action: "allow" };
|
||||
return {action: "allow"};
|
||||
}
|
||||
shell.openExternal(x.url).catch(console.error);
|
||||
return { action: "deny" };
|
||||
return {action: "deny"};
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1144,7 +1162,7 @@ export class BrowserWindow {
|
|||
"CtlN": "Cider",
|
||||
"iV": "196623"
|
||||
};
|
||||
let server2 = mdns.createAdvertisement(x, `${await getPort({ port: 3839 })}`, {
|
||||
let server2 = mdns.createAdvertisement(x, `${await getPort({port: 3839})}`, {
|
||||
name: encoded,
|
||||
txt: txt_record
|
||||
});
|
||||
|
|
|
@ -12,6 +12,11 @@
|
|||
<option v-for="theme in themes" :value="theme.file">{{ theme.name }}</option>
|
||||
</select>
|
||||
</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">
|
||||
<button class="md-btn md-btn-small md-btn-block" @click="installThemeURL()">
|
||||
{{$root.getLz('settings.option.visual.theme.github.download')}}
|
||||
|
@ -99,6 +104,9 @@
|
|||
this.getInstalledThemes();
|
||||
},
|
||||
methods: {
|
||||
openThemesFolder() {
|
||||
ipcRenderer.invoke("open-path", "themes")
|
||||
},
|
||||
getInstalledThemes() {
|
||||
let self = this
|
||||
const themes = ipcRenderer.sendSync("get-themes")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue