mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-11 07:33:05 -04:00
Make Settings & Settings Page
This commit is contained in:
parent
cb288e204d
commit
98cb301df5
18 changed files with 330 additions and 43 deletions
|
@ -1,12 +1,33 @@
|
|||
import { IPC_QUICK_CSS_UPDATE, IPC_GET_QUICK_CSS } from './utils/ipcEvents';
|
||||
import { ipcRenderer } from 'electron';
|
||||
import IPC_EVENTS from './utils/IpcEvents';
|
||||
import { IpcRenderer, ipcRenderer } from 'electron';
|
||||
|
||||
export default {
|
||||
handleQuickCssUpdate(cb: (s: string) => void) {
|
||||
ipcRenderer.on(IPC_QUICK_CSS_UPDATE, (_, css) => {
|
||||
cb(css);
|
||||
});
|
||||
getVersions: () => process.versions,
|
||||
ipc: {
|
||||
send(event: string, ...args: any[]) {
|
||||
if (event in IPC_EVENTS) ipcRenderer.send(event, ...args);
|
||||
else throw new Error(`Event ${event} not allowed.`);
|
||||
},
|
||||
sendSync(event: string, ...args: any[]) {
|
||||
if (event in IPC_EVENTS) return ipcRenderer.sendSync(event, ...args);
|
||||
else throw new Error(`Event ${event} not allowed.`);
|
||||
},
|
||||
on(event: string, listener: Parameters<IpcRenderer["on"]>[1]) {
|
||||
if (event in IPC_EVENTS) ipcRenderer.on(event, listener);
|
||||
else throw new Error(`Event ${event} not allowed.`);
|
||||
},
|
||||
invoke(event: string, ...args: any[]) {
|
||||
if (event in IPC_EVENTS) return ipcRenderer.invoke(event, ...args);
|
||||
else throw new Error(`Event ${event} not allowed.`);
|
||||
}
|
||||
},
|
||||
getQuickCss: () => ipcRenderer.invoke(IPC_GET_QUICK_CSS) as Promise<string>,
|
||||
getVersions: () => process.versions
|
||||
require(mod: string) {
|
||||
const settings = ipcRenderer.sendSync(IPC_EVENTS.GET_SETTINGS);
|
||||
try {
|
||||
if (!JSON.parse(settings).unsafeRequire) throw "no";
|
||||
} catch {
|
||||
throw new Error("Unsafe require is not allowed. Enable it in settings and try again.");
|
||||
}
|
||||
return require(mod);
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue