From 86387bfd826511951ba7cb79cdd9ca729f1a5cc9 Mon Sep 17 00:00:00 2001 From: Handle Date: Thu, 24 Jan 2019 00:03:29 +0800 Subject: [PATCH] fixMoreBugs --- configs.js | 23 ++++++++++++++--------- manager/manager.js | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/configs.js b/configs.js index 72630c8..1a72418 100644 --- a/configs.js +++ b/configs.js @@ -1,8 +1,13 @@ const os = require('os') const fs = require('fs') -const { app } = require('electron') +const electron = require('electron') const path = require('path') +let app = electron.app +if (!app) { + app = electron.remote.app +} + const getIcon = () => { switch (os.platform()) { case 'win32': @@ -24,12 +29,12 @@ const CONFIGS = { MODS_DIR: '/mod', MODS_CONFIG_PATH: path.join(app.getPath('userData'), 'modsEnabled.json'), PLUGINS_DIR: '/plugin', - PLUGINS_CONFIG_PATH: path.join( - app.getPath('userData'), - 'pluginsEnabled.json' - ), TOOLS_DIR: '/tool', EXECUTES_DIR: '/execute', + EXECUTES_CONFIG_PATH: path.join( + app.getPath('userData'), + 'executesEnabled.json' + ), USER_CONFIG_PATH: path.join(app.getPath('userData'), 'configs-user.json'), GAME_WINDOW_CONFIG: { width: 1280, @@ -83,18 +88,18 @@ const CONFIGS = { } } try { - fs.statSync(CONFIGS.PLUGINS_CONFIG_PATH) + fs.statSync(CONFIGS.EXECUTES_CONFIG_PATH) } catch (error) { fs.copyFileSync( - path.join(__dirname, CONFIGS.PLUGINS_DIR, 'active.json'), - CONFIGS.PLUGINS_CONFIG_PATH + path.join(__dirname, CONFIGS.EXECUTES_DIR, 'active.json'), + CONFIGS.EXECUTES_CONFIG_PATH ) } try { fs.statSync(CONFIGS.MODS_CONFIG_PATH) } catch (error) { fs.copyFileSync( - path.join(__dirname, CONFIGS.MODS_CONFIG_PATH, 'active.json'), + path.join(__dirname, CONFIGS.MODS_DIR, 'active.json'), CONFIGS.MODS_CONFIG_PATH ) } diff --git a/manager/manager.js b/manager/manager.js index 9dc4509..f5f44aa 100644 --- a/manager/manager.js +++ b/manager/manager.js @@ -11,7 +11,7 @@ const app = electronRemote.app // 注入脚本根文件根目录 const executeRootDir = path.join(__dirname, '../', configs.EXECUTES_DIR) // const executeSettingsFile = path.join(executeRootDir, './active.json') -const executeSettingsFile = configs.PLUGINS_CONFIG_PATH +const executeSettingsFile = configs.EXECUTES_CONFIG_PATH // Mod文件根目录 const modRootDir = path.join(__dirname, '../', configs.MODS_DIR)