chore: refactor
This commit is contained in:
parent
1a3c53c576
commit
efc6db9e1a
@ -39,7 +39,7 @@ const createMainWindow = () => {
|
|||||||
|
|
||||||
ipcMain.handle(
|
ipcMain.handle(
|
||||||
"invokePluginFunc",
|
"invokePluginFunc",
|
||||||
async (event, modulePath, method, ...args) => {
|
async (_event, modulePath, method, ...args) => {
|
||||||
const module = join(app.getPath("userData"), "plugins", modulePath);
|
const module = join(app.getPath("userData"), "plugins", modulePath);
|
||||||
return await import(/* webpackIgnore: true */ module)
|
return await import(/* webpackIgnore: true */ module)
|
||||||
.then((plugin) => {
|
.then((plugin) => {
|
||||||
@ -70,24 +70,6 @@ const createMainWindow = () => {
|
|||||||
|
|
||||||
if (isDev) mainWindow.webContents.openDevTools();
|
if (isDev) mainWindow.webContents.openDevTools();
|
||||||
};
|
};
|
||||||
const migratePlugins = () => {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
if (store.get("migrated_version") !== app.getVersion()) {
|
|
||||||
console.log("start migration:", store.get("migrated_version"));
|
|
||||||
const userDataPath = app.getPath("userData");
|
|
||||||
const fullPath = join(userDataPath, "plugins");
|
|
||||||
|
|
||||||
rmdir(fullPath, { recursive: true }, function (err) {
|
|
||||||
if (err) console.log(err);
|
|
||||||
store.set("migrated_version", app.getVersion());
|
|
||||||
console.log("migrate plugins done");
|
|
||||||
resolve(undefined);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
resolve(undefined);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
app
|
app
|
||||||
.whenReady()
|
.whenReady()
|
||||||
@ -218,6 +200,25 @@ app.on("window-all-closed", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function migratePlugins() {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
if (store.get("migrated_version") !== app.getVersion()) {
|
||||||
|
console.log("start migration:", store.get("migrated_version"));
|
||||||
|
const userDataPath = app.getPath("userData");
|
||||||
|
const fullPath = join(userDataPath, "plugins");
|
||||||
|
|
||||||
|
rmdir(fullPath, { recursive: true }, function (err) {
|
||||||
|
if (err) console.log(err);
|
||||||
|
store.set("migrated_version", app.getVersion());
|
||||||
|
console.log("migrate plugins done");
|
||||||
|
resolve(undefined);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
resolve(undefined);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
function setupPlugins() {
|
function setupPlugins() {
|
||||||
init({
|
init({
|
||||||
// Function to check from the main process that user wants to install a plugin
|
// Function to check from the main process that user wants to install a plugin
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user