Просмотр исходного кода

Add HEXO Comand
- hexo s
- hexo g
- hexo d
- hexo clean
Add Shell command file
Add Open file in explorer
Fix Auto Save tip error.

zhuzhuyule 8 лет назад
Родитель
Сommit
c29a84c063

+ 1 - 1
app/moe-action.js

@@ -34,7 +34,7 @@ class MoeditorAction {
         let w, i;
         for (i = windows.length - 1; i > -1; i--) {
             w = windows[i];
-            if (w.moeditorWindow && !w.moeditorWindow.changed) {
+            if (w.moeditorWindow && w.moeditorWindow.content.length < 1 &&!w.moeditorWindow.changed) {
                 w.focus();
                 break;
             }

+ 3 - 1
app/moe-app.js

@@ -26,6 +26,7 @@ const MoeditorWindow = require('./moe-window'),
       MoeditorFile = require('./moe-file'),
       shortcut = require('electron-localshortcut'),
       MoeditorLocale = require('./moe-l10n'),
+      MoeditorShell = require('./moe-shell'),
       MoeditorAbout = require('./moe-about'),
       MoeditorSettings = require('./moe-settings'),
       fs = require('fs'),
@@ -55,6 +56,7 @@ class MoeditorApplication {
         this.Const = Const;
 
         this.locale = new MoeditorLocale();
+        this.shellServer = new MoeditorShell();
         global.__ = str => this.locale.get(str);
 
         this.flag = new Object();
@@ -107,7 +109,7 @@ class MoeditorApplication {
                     MoeditorAction.openNew();
                 },
                 fileNewHexo: (w) => {
-                    MoeditorAction.openNew();
+                    MoeditorAction.openNewHexo();
                 },
                 fileOpen: (w) => {
                     MoeditorAction.open();

+ 1 - 1
app/moe-config-default.js

@@ -35,7 +35,7 @@ module.exports = {
     'math': true,
     'uml-diagrams': true,
     'auto-reload': 'auto',
-    'auto-save': 'disabled',
+    'auto-save': 'prompt',
     'highlight-theme': 'github',
     'render-theme': '*GitHub',
     'custom-render-themes': {},

+ 39 - 4
app/moe-l10n.js

@@ -176,6 +176,25 @@ const strings = {
         "Hexo Config": "Hexo Config",
         "Hexo tags": "Tag Templates",
 
+        "HEXOOpenPath": "Open Work Path",
+        "HEXOQuickPublish": "Quick Deploy",
+        "HEXOServer": "Start Server",
+        "HEXOClean": "Clean Cache",
+        "HEXOGenerate": "Generate file",
+        "HEXODeploy": "Deploy web",
+        "HEXOKillPort": "Kill",
+
+        "ban": "Cancle",
+        "stop": "Stop",
+        "close": "Close",
+        "check": "Confirm",
+        "ServerStart": "Service Started And Continue... ",
+        "Executing": "Operation Executing...",
+        "Operation Execution Timeout": "Operation Execution Timeout !",
+        "Operation Finished": "Operation Finished !",
+        "Operation Canceled": "Operation Canceled !",
+        "PortOccupied": "[ %s:%s ] Port is occupied, please change other IP or Port.",
+
         "Waring": "Waring",
         "WaringNoFile": "No CSS files found !",
         "WaringNoFileDetail1": 'Please check the directory: \n"',
@@ -188,8 +207,6 @@ const strings = {
 
         "Auto save": "Auto save",
         "Auto": "Auto",
-        "On Blur": "On Blur",
-        "Disabled": "Disabled",
         "Prompt": "Prompt",
         "Never": "Never",
 
@@ -294,6 +311,25 @@ const strings = {
         "Hexo Config": "Hexo配置文件",
         "Hexo tags": "Tag模板目录",
 
+        "HEXOOpenPath": "打开项目",
+        "HEXOQuickPublish": "一键部署",
+        "HEXOServer": "启动服务器",
+        "HEXOClean": "清除缓存文件",
+        "HEXOGenerate": "生成静态文件",
+        "HEXODeploy": "部署网站",
+        "HEXOKillPort": "结束占用进程",
+
+        "ban": "取消",
+        "stop": "停止",
+        "close": "关闭",
+        "check": "确认",
+        "ServerStart": "服务已启动...",
+        "Executing": "操作执行中...",
+        "Operation Execution Timeout": "操作执行超时!",
+        "Operation Finished": "操作完成!",
+        "Operation Canceled": "取消操作!",
+        "PortOccupied": "[ %s:%s ] 端口占用, 请更换IP地址或端口。",
+
         "Waring": "警告",
         "WaringNoFile": "没有发现CSS文件!",
         "WaringNoFileDetail1": '请检查如下路径: \n"',
@@ -307,11 +343,10 @@ const strings = {
 
         "Auto save": "自动保存",
         "Auto": "自动",
-        "On Blur": "询问",
-        "Disabled": "从不",
         "Prompt": "询问",
         "Never": "从不",
 
+
         "Undo": "撤销",
         "Redo": "重做",
         "Cut": "剪切",

+ 242 - 0
app/moe-shell.js

@@ -0,0 +1,242 @@
+/*
+*  This file is part of Moeditor.
+*
+*  Copyright (c) 2016 Menci <huanghaorui301@gmail.com>
+*  Copyright (c) 2016 lucaschimweg
+*  Copyright (c) 2016 douglaseccker
+*  Copyright (c) 2016 PifyZ
+*  Copyright (c) 2016 Hyuchia
+*  Copyright (c) 2016 welksonramos
+*  Copyright (c) 2016 caiocdasilva
+*  Copyright (c) 2016 lawgsy <lawgsy@gmail.com>
+*
+*  Moeditor is free software: you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation, either version 3 of the License, or
+*  (at your option) any later version.
+*
+*  Moeditor is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  You should have received a copy of the GNU General Public License
+*  along with Moeditor. If not, see <http://www.gnu.org/licenses/>.
+*
+*  The translation providers:
+*   - en: Menci
+*   - zh_CN: Menci
+*   - de: lucaschimweg
+*   - pt: douglaseccker & welksonramos & caiocdasilva
+*   - fr: PifyZ
+*   - es: Hyuchia
+*   - nl: lawgsy
+*   - it: iamsisar
+*
+*  If you want to help translate this app, please copy the `en` items of the
+*  `strings` constant as the template, and fill each item with the translated
+*  string. The `_name` item in a language is the language's name.
+*
+*  You can translate for a language (e.g. en) or a language with specified
+*  region (e.g. zh_CN). The app will choose the language with specified region
+*  first, fallback to only language when the former is unavailable, and fallback
+*  to English when they are all unavailable.
+*
+*  Send a PR to us after translating.
+*
+*/
+
+'use strict'
+
+
+const Promise = require('bluebird');
+const {ipcMain} = require('electron');
+const thread_kill = require('./tool/thread_kill');
+const exec = require('child_process').exec;
+const util = require('util');
+
+class ShellServer {
+    constructor() {
+        this.shellProcess = null;
+        this.isForce = false;
+        this.oldbiu = null;
+        this.drags = null;
+    }
+
+    processRunning() {
+        return (this.shellProcess && this.shellProcess != null)
+    }
+
+    sendConsole(content, type, btnTip) {
+        if (moeApp.shellServer.closeMsg) return;
+        try {
+            moeApp.shellServer.lastWindow.moeditorWindow.window.webContents.send('pop-message-shell', {
+                subProcess: this.shellProcess,
+                content: content,
+                type: type,
+                btnTip: btnTip,
+            });
+        } catch (e) {
+            content.error(e)
+        }
+    }
+
+    execCmd(command) {
+        console.log('execute', command);
+        let flagOK = false;
+        clearTimeout(moeApp.shellServer.timeID);
+        moeApp.shellServer.closeMsg = false;
+        moeApp.shellServer.lastWindow = require('electron').BrowserWindow.getFocusedWindow();
+        moeApp.shellServer.isForce = false;
+        moeApp.shellServer.shellProcess = exec(command, {cwd: moeApp.hexo.config.__basedir});
+        moeApp.shellServer.sendConsole('<i class="fa fa-spinner fa-pulse fa-fw margin-bottom"></i>'+__("Executing"), 'info', 'ban');
+        moeApp.shellServer.shellProcess.stderr.on('data', (data) => {
+            console.log(data);
+        });
+        moeApp.shellServer.shellProcess.stdout.on('data', (data) => {
+            clearTimeout(moeApp.shellServer.timeID);
+            if (flagOK || (/INFO  Hexo is running at https?:\/+/.test(data)) ) {
+                flagOK = true;
+                moeApp.shellServer.sendConsole('<i class="fa fa-spinner fa-pulse fa-fw margin-bottom"></i>'+__('ServerStart'), 'info', 'stop');
+
+
+
+                require('electron').shell.openExternal(data.match(/INFO  Hexo is running at (https?:\/+[^\/]+\/). Press Ctrl.C to stop./i)[1])
+            } else {
+                moeApp.shellServer.timeID = setTimeout(() => {
+                    if (!flagOK) {
+                        moeApp.shellServer.kill(moeApp.shellServer.shellProcess)
+                        flagOK = -1;
+                    }
+                }, 10000)
+            }
+            console.log(data);
+        });
+        moeApp.shellServer.shellProcess.on('close', (code, signal) => {
+            if (flagOK === -1)
+                moeApp.shellServer.sendConsole(__('Operation Execution Timeout'), 'danger', 'close');
+            else if (moeApp.shellServer.isForce)
+                moeApp.shellServer.sendConsole(__('Operation Canceled'), 'success', 'check');
+            else if (code == 0)
+                moeApp.shellServer.sendConsole(__('Operation Finished'), 'success', 'check');
+            moeApp.shellServer.shellProcess = null;
+        });
+        moeApp.shellServer.shellProcess.on('error', err => {
+            if (moeApp.shellServer.shellProcess)
+                moeApp.shellServer.sendConsole(err, 'danger', 'close')
+            console.error(err);
+        })
+    }
+
+    kill(subProcess) {
+        moeApp.shellServer.isForce = true;
+        moeApp.shellServer.closeMsg = (typeof subProcess === "boolean");
+        if (!subProcess)
+            subProcess = moeApp.shellServer.shellProcess
+        if (subProcess)
+            thread_kill(subProcess.pid, function (err) {
+                console.error(err);
+            });
+    }
+
+    checkPort(ip, port) {
+        moeApp.shellServer.isForce = false;
+        moeApp.shellServer.closeMsg = false;
+        return new Promise(function (resolve, reject) {
+            if (port > 65535 || port < 1) {
+                return reject(new Error('Port number ' + port + ' is invalid. Try a number between 1 and 65535.'));
+            }
+            var server = require('net').createServer();
+            server.once('error', reject);
+            server.once('listening', function () {
+                server.close();
+                resolve(`${ip}:${port}`);
+            });
+
+            server.listen(port, ip);
+        });
+    }
+
+    serverFail(err) {
+        if (err.code === 'EADDRINUSE') { // 端口Ip地址占用
+            moeApp.shellServer.sendConsole(util.format(__('PortOccupied'),err.address,err.port), 'danger', 'close');
+        }
+    }
+
+    server() {
+        this.checkPort(moeApp.hexo.config.server.ip, moeApp.hexo.config.server.port)
+            .then(this.execCmd('hexo s'), this.serverFail);
+    }
+
+    clean() {
+        Promise.resolve()
+            .then(this.execCmd('hexo clean'));
+    }
+
+    general() {
+        Promise.resolve()
+            .then(this.execCmd('hexo g'));
+    }
+
+    deploy() {
+        Promise.resolve()
+            .then(this.execCmd('hexo d'));
+    }
+
+    generalAndDeploy() {
+        Promise.resolve()
+            .then(this.execCmd('hexo g -d'));
+    }
+
+    stopServerForce() {
+        const port = moeApp.hexo.config.server.port;
+        const ip = moeApp.hexo.config.server.ip;
+        let command = '';
+        switch (process.platform) {
+            case 'win32':
+                command = 'netstat -nao | findstr ';
+                break;
+            case 'darwin':
+                command = 'netstat -anp|grep ';
+                break;
+            default:
+                command = 'netstat -anp|grep ';
+                break;
+        }
+        this.execCmd(command + port);
+        let portList = [];
+
+        this.shellProcess.stdout.on('data', (data) => {
+            let reg;
+            switch (process.platform) {
+                case 'win32':
+                    reg =  new RegExp(util.format('TCP\\s+%s:%s\\s+\\d+.\\d+.\\d+.\\d+:\\d+\\s+LISTENING\\s+(\\d+)', ip, port),'i');
+                    break;
+                case 'darwin':
+                    reg =  new RegExp(util.format('tcp\\s+\\d+\\s+\\d*\\s+%s:%s\\s+\\d+.\\d+.\\d+.\\d+:[*\\d]+\\s+LISTEN\\s+(\\d+)', ip, port),'i');
+                    break;
+                default:
+                    reg =  new RegExp(util.format('tcp\\s+\\d+\\s+\\d*\\s+%s:%s\\s+\\d+.\\d+.\\d+.\\d+:[*\\d]+\\s+LISTEN\\s+(\\d+)', ip, port),'i');
+                    break;
+            }
+
+            if (reg.test(data)) {
+                let pid = data.match(reg)[1]
+                if (pid)
+                    portList.push(pid)
+            }
+        });
+
+        this.shellProcess.on('close', (code, signal) => {
+            if (portList.length > 0) {
+                for (let i = 0, len = portList.length; i < len; i++) {
+                    thread_kill(portList[i])
+                }
+            }
+            this.sendConsole(__('Operation Finished'), 'success', 'check');
+            this.shellProcess = null;
+        });
+    }
+}
+
+module.exports = ShellServer;

+ 7 - 1
app/moe-window.js

@@ -70,6 +70,7 @@ class MoeditorWindow {
 
     registerEvents() {
         this.window.on('close', (e) => {
+            console.log(moeApp.windows.length,this.changed)
             if (moeApp.windows.length && this.changed) {
                 const choice = dialog.showMessageBox(
                     this.window,
@@ -96,11 +97,16 @@ class MoeditorWindow {
                 }
             }
 
+            console.log(this.window == moeApp.shellServer.lastWindow)
+            if (this.window == moeApp.shellServer.lastWindow)
+                process.nextTick(moeApp.shellServer.kill,false);
+
             const index = moeApp.windows.indexOf(this);
             if (index !== -1) moeApp.windows.splice(index, 1);
 
             if ( !moeApp.windows.length) {
-                app.quit()
+                process.nextTick(moeApp.shellServer.kill,false);
+                setTimeout(app.quit,200)
             }
         });
     }

+ 48 - 0
app/tool/spawn.js

@@ -0,0 +1,48 @@
+/**
+ * Created by nuintun on 2016/1/14.
+ */
+
+'use strict';
+
+var spawn = require('child_process').spawn;
+
+/**
+ * normalize exec args
+ * @param command
+ * @param options
+ * @returns {{cmd: *, shell: *, args: *, options: *}}
+ */
+function normalizeExecArgs(command, options){
+    var shell, args;
+
+    // Make a shallow copy before patching so we don't clobber the user's
+    // options object.
+    options = options || {};
+
+    if (process.platform === 'win32') {
+        shell = process.env.comspec || 'cmd.exe';
+        args = ['/s', '/c', '"' + command + '"'];
+        options.windowsVerbatimArguments = true;
+    } else {
+        shell = '/bin/sh';
+        args = ['-c', command];
+    }
+
+    if (options.shell) {
+        shell = options.shell;
+    }
+
+    return {
+        shell: shell,
+        args: args,
+        options: options
+    };
+}
+
+/**
+ * exec thread
+ */
+module.exports = function (){
+    var parsed = normalizeExecArgs.apply(null, arguments);
+    return spawn(parsed.shell, parsed.args, parsed.options);
+};

+ 128 - 0
app/tool/thread_kill.js

@@ -0,0 +1,128 @@
+/*!
+ * thread-kill
+ * Date: 2016/1/14
+ * https://github.com/nuintun/command-manager
+ *
+ * Referer: https://github.com/pkrumins/node-tree-kill
+ */
+
+'use strict';
+
+var spawn = require('./spawn');
+var exec = require('child_process').exec;
+
+/**
+ *
+ * @param pid
+ * @param signal
+ * @param callback
+ */
+module.exports = function (pid, signal, callback){
+    var tree = {};
+    var pidsToProcess = {};
+
+    tree[pid] = [];
+    pidsToProcess[pid] = 1;
+
+    if (typeof signal === 'function') {
+        signal = 'SIGKILL';
+        callback = signal;
+    }
+
+    switch (process.platform) {
+        // win32
+        case 'win32':
+            exec('taskkill /pid ' + pid + ' /T /F', callback);
+            break;
+        // darwin
+        case 'darwin':
+            buildProcessTree(pid, tree, pidsToProcess, function (parentPid){
+                return spawn('pgrep', ['-P', parentPid]);
+            }, function (){
+                killAll(tree, signal, callback);
+            });
+            break;
+        // linux
+        default:
+            buildProcessTree(pid, tree, pidsToProcess, function (parentPid){
+                return spawn('ps', ['-o', 'pid', '--no-headers', '--ppid', parentPid]);
+            }, function (){
+                killAll(tree, signal, callback);
+            });
+            break;
+    }
+};
+
+function killAll(tree, signal, callback){
+    var killed = {};
+
+    try {
+        Object.keys(tree).forEach(function (pid){
+            tree[pid].forEach(function (pidpid){
+                if (!killed[pidpid]) {
+                    killPid(pidpid, signal);
+
+                    killed[pidpid] = 1;
+                }
+            });
+
+            if (!killed[pid]) {
+                killPid(pid, signal);
+
+                killed[pid] = 1;
+            }
+        });
+    } catch (error) {
+        if (callback) {
+            return callback(error);
+        } else {
+            throw error;
+        }
+    }
+
+    if (callback) {
+        return callback();
+    }
+}
+
+function killPid(pid, signal){
+    try {
+        process.kill(parseInt(pid, 10), signal);
+    } catch (error) {
+        if (error.code !== 'ESRCH') throw error;
+    }
+}
+
+function buildProcessTree(parentPid, tree, pidsToProcess, spawnChildProcessesList, callback){
+    var allData = '';
+    var ps = spawnChildProcessesList(parentPid);
+
+    ps.stdout.on('data', function (data){
+        allData += data.toString('ascii');
+    });
+
+    var onClose = function (code){
+        delete pidsToProcess[parentPid];
+
+        if (code !== 0) {
+            // no more parent processes
+            if (Object.keys(pidsToProcess).length === 0) {
+                callback();
+            }
+            return;
+        }
+
+        allData.match(/\d+/g).forEach(function (pid){
+            pid = parseInt(pid, 10);
+
+            tree[parentPid].push(pid);
+
+            tree[pid] = [];
+            pidsToProcess[pid] = 1;
+
+            buildProcessTree(pid, tree, pidsToProcess, spawnChildProcessesList, callback);
+        });
+    };
+
+    ps.on('close', onClose);
+}

+ 7 - 0
views/main/hexo/default_config.js

@@ -39,6 +39,13 @@ module.exports = {
         line_number: true,
         tab_replace: ''
     },
+    server: {
+        port: 4000,
+        log: false,
+        ip: '0.0.0.0',
+        compress: false,
+        header: true
+    },
     // Category & Tag
     default_category: 'uncategorized',
     category_map: {},

+ 70 - 8
views/main/moe-contextmenu.js

@@ -19,6 +19,8 @@
 
 'use strict'
 
+let shellServer = moeApp.shellServer;
+
 document.addEventListener('DOMContentLoaded', () => {
     const remote = require('electron').remote;
     const {Menu, MenuItem} = remote;
@@ -83,20 +85,13 @@ document.addEventListener('DOMContentLoaded', () => {
                 {
                     type: 'separator'
                 },
-                {
-                    label: __('File Rename'),
-                    visible: !moeApp.defTheme,
-                    click(item, w) {
-                        window.changeFileName(true);
-                    }
-                },
                 {
                     label: __('Show Number'),
                     type: 'checkbox',
                     checked: window.editor.getOption('lineNumbers'),
                     click(item, w) {
                         let editor = document.querySelector('#editor');
-                        if (item.checked){
+                        if (item.checked) {
                             editor.classList.add('gutter');
                         } else {
                             editor.classList.remove('gutter')
@@ -112,6 +107,73 @@ document.addEventListener('DOMContentLoaded', () => {
                     click(item, w) {
                         window.scrollTogether = !window.scrollTogether;
                     }
+                },
+                {
+                    type: 'separator',
+                    visible: !moeApp.defTheme,
+                },
+                {
+                    label: "HEXO",
+                    visible: !moeApp.defTheme,
+                    enabled: !shellServer.processRunning(),
+                    click(item, w) {
+                        const shell = require('electron').shell
+                        shell.showItemInFolder(path.join(hexo.config.__basedir, '*'))
+                    },
+                    submenu: [
+                        {
+                            label: __('File Rename'),
+                            click(item, w) {
+                                window.changeFileName(true);
+                            }
+                        },
+                        {
+                            label: __('HEXOOpenPath'),
+                            click(item, w) {
+                                const shell = require('electron').shell
+                                shell.showItemInFolder(path.join(hexo.config.__basedir, '*'))
+                            }
+                        },
+                        {
+                            label: __('HEXOQuickPublish'),
+                            click(item, w) {
+                                shellServer.generalAndDeploy();
+                            }
+                        },
+                        {
+                            type: 'separator'
+                        },
+                        {
+                            label: __('HEXOServer'),
+                            click(item, w) {
+                                shellServer.server();
+                            }
+                        },
+                        {
+                            label: __('HEXOClean'),
+                            click(item, w) {
+                                shellServer.clean();
+                            }
+                        },
+                        {
+                            label: __('HEXOGenerate'),
+                            click(item, w) {
+                                shellServer.general();
+                            }
+                        },
+                        {
+                            label: __('HEXODeploy'),
+                            click(item, w) {
+                                shellServer.deploy();
+                            }
+                        },
+                        {
+                            label: __('HEXOKillPort'),
+                            click(item, w) {
+                                shellServer.stopServerForce();
+                            }
+                        }
+                    ]
                 }
             ];
             Menu.buildFromTemplate(template).popup(remote.getCurrentWindow());

+ 12 - 14
views/main/moe-document.js

@@ -32,7 +32,6 @@ $(() => {
     const dialog = require('electron').remote.dialog;
     const YMAL = require('yamljs');
 
-
     const MoeditorPreview = require('./moe-preview');
 
     if (w.fileName !== '') {
@@ -127,19 +126,18 @@ $(() => {
 
     window.autoSave = ()=> {
         const option = moeApp.config.get('auto-save');
-        if (option === 'disabled') return;
-        if (w.content === gSavedContent) return;
-
-        fs.writeFile(w.fileName, w.content, (err) => {
-            if (err) {
-                w.changed = true;
-                w.window.setDocumentEdited(true);
-                return;
-            }
-            w.isSaved = true;
-            w.changed = false;
-            w.window.setDocumentEdited(false);
-        });
+        if (option === 'auto' && w.content !== gSavedContent) {
+            fs.writeFile(w.fileName, w.content, (err) => {
+                if (err) {
+                    w.changed = true;
+                    w.window.setDocumentEdited(true);
+                    return;
+                }
+                w.isSaved = true;
+                w.changed = false;
+                w.window.setDocumentEdited(false);
+            });
+        }
     }
 
     editor.on('change', (editor, obj) => {

+ 26 - 0
views/main/moe-popmessage.js

@@ -38,6 +38,32 @@ document.addEventListener('DOMContentLoaded', () => {
         }
     });
 
+    let oldbiu = null;
+    ipcRenderer.on('pop-message-shell',(e,arg)=>{
+        if (oldbiu && oldbiu != null) oldbiu.hide();
+        oldbiu = biu(arg.content, {
+            type: 'webConsole biu-' + arg.type,
+            autoHide: !!arg.autoHide,
+            pop: true,
+            align: arg.align || 'left',
+            closeButton: '<i class="fa fa-' + (arg.btnTip||"close") + '" aria-hidden="true" title=' + __(arg.btnTip||"Close") + '></i>'
+        });
+        oldbiu.closeButton.addEventListener('click', function () {
+            process.nextTick(moeApp.shellServer.kill);
+        });
+
+        if (!drags)
+            drags = document.getElementsByClassName('drag');
+        // workaround for #electron/electron/6970
+        for (let drag of drags) {
+            drag.style.width = '0';
+            drag.offsetHeight;
+            setTimeout(() => {
+                drag.style.width = ''
+            }, 1000);
+        }
+    })  ;
+
     ipcRenderer.on('refresh-editor', function () {
         let w  = window.w;
         if (w.fileName !== '') {

+ 0 - 12
views/main/moe-settings.js

@@ -204,18 +204,6 @@ tryRun(setHexoAutoSetting, moeApp.config.get('hexo-auto-setting'));
 tryRun(setHexoConfigEnable, moeApp.config.get('hexo-config-enable'));
 tryRun(setHexoConfig, moeApp.config.get('hexo-config'));
 tryRun(setHexoTagPaths, moeApp.config.get('hexo-tag-paths'));
-// setEditorFont(moeApp.config.get('editor-font'));
-// setShowLineNumber(!!moeApp.config.get('editor-ShowLineNumber'));
-// setEditorTheme(moeApp.config.get('editor-theme'));
-// setEditorFontSize(moeApp.config.get('editor-font-size'));
-// setEditorLineHeight(moeApp.config.get('editor-line-height'));
-// setRenderTheme(moeApp.config.get('render-theme'));
-// setHighlightTheme(moeApp.config.get('highlight-theme'));
-// setCustomCSSs(moeApp.config.get('custom-csss'));
-// setHexoAutoSetting(moeApp.config.get('hexo-auto-setting'));
-// setHexoConfigEnable(moeApp.config.get('hexo-config-enable'));
-// setHexoConfig(moeApp.config.get('hexo-config'));
-// setHexoTagPaths(moeApp.config.get('hexo-tag-paths'));
 
 const ipcRenderer = require('electron').ipcRenderer;
 ipcRenderer.on('setting-changed', (e, arg) => {

+ 12 - 0
views/main/moe-style.css

@@ -493,11 +493,23 @@ body[settings-mode=read] #drag-right, body[settings-mode=write] #drag-right {
 }
 
 .biu-instance {
+    line-height: 2;
     -webkit-app-region: no-drag;
     font-size: 14px;
     font-family: Roboto, Helvetica, 'Segoe UI', Arial, sans-serif;
 }
 
+.biu-instance.biu-webConsole{
+    -webkit-app-region: drag;
+    padding: 0;
+    top: 1px;
+    box-shadow: none;
+}
+
+.biu-close{
+    -webkit-app-region: no-drag;
+}
+
 .invalidFile{
     background: red;
 }

+ 3 - 2
views/settings/settings.html

@@ -95,8 +95,9 @@
                                 <td width="40%" class="l10n">Auto save</td>
                                 <td width="60%">
                                     <select class="settings-item" data-key="auto-save">
-                                        <option value="disabled" class="l10n">Disabled</option>
-                                        <option value="on-blur" class="l10n">On Blur</option>
+                                        <option value="auto" class="l10n">Auto</option>
+                                        <option value="prompt" class="l10n">Prompt</option>
+                                        <!--<option value="never" class="l10n">Never</option>-->
                                     </select>
                                 </td>
                             </tr>