浏览代码

Add Status bar
Add Delete Image Method
Fix Replace Image Url Faild
Fix Theme change invalid
Fix Highlight Theme change invalid
Modify UI

zhuzhuyule 7 年之前
父节点
当前提交
4de139c34b

+ 2 - 1
app/tool/hexo-cos.js

@@ -121,10 +121,11 @@ class COSServer {
 
     deleteObject(fileanme, cb) {
         this.cos.deleteObject({
-            Bucket: config.Bucket, // Bucket 格式:test-1250000000
+            Bucket: config.Bucket,
             Region: config.Region,
             Key: fileanme
         }, function (err, data) {
+            console.log(data)
             if (typeof cb === 'function')
                 cb(err || data);
         });

+ 39 - 14
app/tool/hexo-qiniu.js

@@ -133,6 +133,26 @@ class qiniuServer {
         });
     }
 
+    /**
+     * 删除文件
+     * @param key
+     * @param callback
+     */
+    deleteFile(key,callback){
+        var config = new this.qiniu.conf.Config();
+        var bucketManager = new this.qiniu.rs.BucketManager(this.mac, config);
+        bucketManager.delete(this.bucket, key, function(error, res, body) {
+            if (typeof callback === "function") {
+                callback({
+                    statusCode: res.statusCode,
+                    data: JSON.parse(body)
+                })
+            } else {
+                console.log(res)
+            }
+        });
+    }
+
     /**
      * 异步上传单个文件
      * @param localFile         本地文件全路径
@@ -161,22 +181,27 @@ class qiniuServer {
             function (respErr, respBody, respInfo) {
                 if (typeof  callback == 'function') {
                     let result = {type:10,id: localFile};
-                    if (respInfo.statusCode == 200 || respInfo.statusCode == 579) {
-                        result.type = 20;
-                        result.statusCode = 200;
-                        result.data = {
-                            localname: path.basename(localFile),
-                            storename: path.basename(serverFileName),
-                            path: respBody.key,
-                            url: qiniuServer.url + respBody.key
+                    try {
+                        if (respInfo.statusCode == 200 || respInfo.statusCode == 579) {
+                            result.type = 20;
+                            result.statusCode = 200;
+                            result.data = {
+                                localname: path.basename(localFile),
+                                storename: path.basename(serverFileName),
+                                path: respBody.key,
+                                url: qiniuServer.url + respBody.key
+                            }
+                            result.msg = '';
+                            result.errorlist = '';
+                        } else {
+                            result.msg = respInfo.statusCode + respBody.error;
+                            result.errorlist = 'https://developer.qiniu.com/kodo/api/3928/error-responses#2';
                         }
-                        result.msg = '';
-                        result.errorlist = '';
-                    } else {
-                        result.msg = respInfo.statusCode + respBody.error;
-                        result.errorlist = 'https://developer.qiniu.com/kodo/api/3928/error-responses#2';
+                    }catch (e){
+                        console.log(respBody)
+                    }finally {
+                        callback(result)
                     }
-                    callback(result)
                 } else {
                     console.log(respBody)
                 }

+ 41 - 2
app/tool/hexo-smms.js

@@ -16,8 +16,47 @@ class Smms {
         this.request = require('request');
     }
 
+    clear() {
+        this.request({
+            url: 'https://sm.ms/clear/',
+            method: 'GET',
+            headers: {'user-agent': userAgent}
+        })
+    }
+
     del(fileHash) {
-        this.request('https://sm.ms/delete/'+ fileHash)
+        this.request({
+            url: 'https://sm.ms/delete/' + fileHash,
+            method: 'GET',
+            headers: {'user-agent': userAgent}
+        }, (error, res, body) => {
+            var content = body;
+            if (content) {
+                content = content.match(/<div class="container"><div[^>]*>([^<]*)</)
+                if (content != null)
+                    content = fileHash + ' : ' + content[1];
+            }
+            console.log(content)
+        })
+    }
+
+    getList(callback) {
+        this.request({
+            url: "https://sm.ms/api/list",
+            method: 'GET',
+            headers: {'user-agent': userAgent}
+        }, (error, res, body) => {
+            if (typeof callback === "function") {
+                if (res.statusCode == 200)
+                    callback({
+                        statusCode: res.statusCode,
+                        data: (typeof(body) == 'string') ? JSON.parse(body) : body
+                    });
+                else {
+                    console.log(body)
+                }
+            }
+        })
     }
 
     /**
@@ -65,7 +104,7 @@ class Smms {
         }, (error, res, body) => {
             if (typeof callback === "function") {
                 let response = JSON.parse(body);
-                let result = {type:1,id: localFile};
+                let result = {type: 1, id: localFile};
                 if (res.statusCode == 200) {
                     result.statusCode = (response.code == 'success' ? 200 : -1);
                     if (result.statusCode == 200) {

+ 93 - 44
app/tool/hexo-uploadServer.js

@@ -15,11 +15,12 @@ module.exports = (function () {
     let smmsServer, qiniuServer, cosServer;
     let finishedCount, totalCount, pathIndex;
     let statusList, successList, errorList;
-    let timeout,startDate;
+    let timeout, startDate;
     let typeServer;
     let typeBack;
+    let order;
     //
-    let baseDir, uploadArray,finishedCallback;
+    let baseDir, uploadArray, finishedCallback;
 
     function getSmmsServer() {
         if (!smmsServer) {
@@ -62,11 +63,11 @@ module.exports = (function () {
         getSmmsServer().uploadFile(imgPath, '', callback);
     }
 
-    function asyncUploadToQiNiu(imgPath,serverName, callback) {
+    function asyncUploadToQiNiu(imgPath, serverName, callback) {
         getQiNiuServer().uploadFile(imgPath, serverName, callback);
     }
 
-    function asyncUploadToCOS(imgPath,serverName, callback) {
+    function asyncUploadToCOS(imgPath, serverName, callback) {
         getCOSServer().sliceUploadFile(imgPath, serverName, callback);
     }
 
@@ -77,18 +78,18 @@ module.exports = (function () {
     function asyncUploadFile(imgPath, callback) {
         switch (typeServer) {
             case 'qiniu':
-                asyncUploadToQiNiu(imgPath,relativePath(imgPath), callback)
+                asyncUploadToQiNiu(imgPath, relativePath(imgPath), callback)
                 break;
             case 'cos':
-                asyncUploadToCOS(imgPath,relativePath(imgPath), callback)
+                asyncUploadToCOS(imgPath, relativePath(imgPath), callback)
                 break;
             default: {
                 if (typeBack > 2) {
                     if (statusList[imgPath]) {
                         if (statusList[imgPath].typeServer == 'qiniu') {
-                            asyncUploadToQiNiu(imgPath,statusList[imgPath].pathname , callback)
+                            asyncUploadToQiNiu(imgPath, statusList[imgPath].pathname, callback)
                         } else {
-                            asyncUploadToCOS(imgPath,statusList[imgPath].pathname , callback)
+                            asyncUploadToCOS(imgPath, statusList[imgPath].pathname, callback)
                         }
                     } else {
                         asyncUploadToSmms(imgPath, callback);
@@ -98,12 +99,11 @@ module.exports = (function () {
         }
     }
 
-    function checktime(isBreak) {
+    function checktime() {
         clearTimeout(timeout);
-        if (!isBreak)
-            timeout = setTimeout(() => {
-                uploadEnd(true);
-            }, 30000)
+        timeout = setTimeout(() => {
+            uploadEnd(true);
+        }, 30000)
     }
 
     /**
@@ -129,11 +129,13 @@ module.exports = (function () {
 
 
     function uploaded(response) {
+        order++;
         let result = response;
         let uploadNext = true;
         let imgPath = result.id;
+        let nextType = '';
         if (typeServer == 'smms' && typeBack > 2) {  //是否需要备份
-            console.log(result.statusCode,result.data.path,result.data.url)
+            console.log(result.statusCode, result.data.path, result.data.url)
             statusList[imgPath].type += result.type;
             if (statusList[imgPath].type == 2) {  //Smsm
                 statusList[imgPath].hash = result.data.hash;
@@ -146,35 +148,51 @@ module.exports = (function () {
             } else if (statusList[imgPath].type == 22) {   //Qiniu
                 uploadNext = backUpload(result)
             }
+            nextType = statusList[imgPath].serverType;
+        }
 
-            if (!uploadNext)
-                asyncUploadFile(imgPath, uploaded);
+        let info = {
+            order: order,
+            isLoading: (finishedCount !== totalCount),
+            finishedCount: finishedCount,
+            totalCount: totalCount,
+            useTime: new Date() - startDate,
+            timeout: false,
+            serverType: typeServer,
+            response: response,
+            nextPath: imgPath,
+            nextType: nextType
         }
 
-        if (uploadNext){
+
+        if (!uploadNext) {
+            asyncUploadFile(imgPath, uploaded);
+            finishedCallback(info, successList, errorList);
+        } else {
             finishedCount++;
             console.log(finishedCount + '/' + totalCount);
-            if (typeServer == 'smms' && typeBack > 2){
+            if (typeServer == 'smms' && typeBack > 2) {
                 if (statusList[imgPath].type == typeBack) {
                     result.data.hash = statusList[imgPath].hash;
                     result.data.url = statusList[imgPath].url;
-                    successList.set(imgPath, result)
+                    successList.push(result)
                 } else {
-                    errorList.set(imgPath, result)
+                    errorList.push(result)
                 }
             } else {
                 if (result.statusCode == 200) {
-                    successList.set(imgPath, result)
+                    successList.push(result)
                 } else {
-                    errorList.set(imgPath, result)
+                    errorList.push(result)
                 }
             }
 
-            if(pathIndex < totalCount){
-                asyncUploadFile(uploadArray[pathIndex], uploaded)
+            if (pathIndex < totalCount) {
+                info.nextPath = uploadArray[pathIndex];
+                finishedCallback(info, successList, errorList);
+                asyncUploadFile(info.nextPath, uploaded)
                 pathIndex++;
-            } else if (finishedCount == totalCount){
-                checktime(true);
+            } else if (finishedCount == totalCount) {
                 uploadEnd();
                 return;
             }
@@ -216,12 +234,21 @@ module.exports = (function () {
 
     function uploadEnd(isTimeout) {
         try {
+            clearTimeout(timeout);
             if (isTimeout)
-                errorList.set('Upload time out!',{msg:'Place check your net!'});
+                errorList.set('Upload time out!', {msg: 'Place check your net!'});
         } finally {
-            console.log('upload end ! use time: ',new Date() - startDate)
-            console.log(successList.size,errorList.size)
-            finishedCallback(successList,errorList);
+            console.log('upload end ! use time: ', new Date() - startDate)
+            let info = {
+                order: order,
+                isLoading: false,
+                finishedCount: finishedCount,
+                totalCount: totalCount,
+                useTime: new Date() - startDate,
+                timeout: !!isTimeout,
+                serverType: typeServer
+            }
+            finishedCallback(info, successList, errorList);
             isUploading = false;
         }
     }
@@ -230,37 +257,59 @@ module.exports = (function () {
         constructor() {
             isUploading = false;
         }
-        isLoading(){
+
+        isLoading() {
             return isUploading;
         }
+        //SM.MS
+        del(hash){
+            getSmmsServer().del(hash)
+        }
+        clearSmmsList(){
+            getSmmsServer().clear()
+        }
+        getSmmsList(callback){
+            getSmmsServer().getList(callback);
+        }
+
         //Qiniu
         updateQiniu(acessKey, secretKey, bucket, url) {
             getQiNiuServer().update(acessKey, secretKey, bucket, url)
         }
+
         getQiniuAccessToken(url) {
             getQiNiuServer().getAccessToken(url)
         }
-        getQiniuBuckets(callback){
+
+        getQiniuBuckets(callback) {
             getQiNiuServer().getBuckets(callback)
         }
-        getQiniuBucketsUrl(buketName, callback){
+
+        getQiniuBucketsUrl(buketName, callback) {
             getQiNiuServer().getBucketsUrl(buketName, callback)
         }
 
+        deleteQiniuFile(fileanme, cb) {
+            getQiNiuServer().deleteFile(fileanme, cb)
+        }
         //Cos
-        updateCos(acessKey, secretKey, bucket, region,protocol){
-            getCOSServer().update(acessKey, secretKey, bucket, region,protocol)
+        updateCos(acessKey, secretKey, bucket, region, protocol) {
+            getCOSServer().update(acessKey, secretKey, bucket, region, protocol)
         }
-        getCosService(cb){
+
+        getCosService(cb) {
             getCOSServer().getService(cb)
         }
-        getCosFileURL(key, cb){
+
+        getCosFileURL(key, cb) {
             getCOSServer().getFileURL(key, cb)
         }
-        getCosBucketLocation(cb){
-            getCOSServer(). getBucketLocation(cb)
+
+        getCosBucketLocation(cb) {
+            getCOSServer().getBucketLocation(cb)
         }
-        deleteObject(fileanme, cb){
+
+        deleteCosFile(fileanme, cb) {
             getCOSServer().deleteObject(fileanme, cb)
         }
 
@@ -278,13 +327,12 @@ module.exports = (function () {
             totalCount = uploadArray.length;
             finishedCount = 0;
             timeout = 0;
+            order = 0;
             typeServer = moeApp.config.get('image-web-type');
             typeBack = moeApp.config.get('image-back-type');
 
-            if (!successList) successList = new Map();
-            successList.clear();
-            if (!errorList) errorList = new Map();
-            errorList.clear();
+            successList = []
+            errorList = [];
             if (!statusList) statusList = new Map();
             statusList.clear();
 
@@ -299,5 +347,6 @@ module.exports = (function () {
             }
         }
     }
+
     return UploadServer;
 })();

+ 104 - 30
views/main/hexo-image.js

@@ -2,6 +2,8 @@ window.md5 = (text) => {
     return require('crypto').createHash('md5').update(text).digest('hex');
 };
 
+let uploadList = [];
+
 class ImgManager {
     constructor() {
         this.postName = path.basename(hexoWindow.fileName, path.extname(hexoWindow.fileName)) || hexoWindow.ID || "";
@@ -187,9 +189,49 @@ class ImgManager {
         }
     }
 
+    abortUploading() {
+        var typeServer = moeApp.config.get('image-web-type');
+        var typeBack = moeApp.config.get('image-back-type');
+        switch (typeServer) {
+            case 'smms': {
+                uploadList.forEach((response) => {
+                        response.data.data.forEach((item) => {
+                            this.getUploadServer().del(item.hash);
+                            if (typeBack > 220 || typeBack == 22)
+                                this.getUploadServer().deleteQiniuFile(item.path.slice(1));
+                            if (typeBack > 200)
+                                this.getUploadServer().deleteCosFile(item.path.slice(1));
+                        })
+                    }
+                );
+                this.getUploadServer().clearSmmsList();
+                break;
+            }
+            case 'qiniu': {
+                uploadList.forEach((response) => {
+                        response.data.data.forEach((item) => {
+                            this.getUploadServer().deleteQiniuFile(item.path.slice(1));
+                        })
+                    }
+                );
+                break;
+            }
+            case 'cos': {
+                uploadList.forEach((response) => {
+                        response.data.data.forEach((item) => {
+                            this.getUploadServer().deleteCosFile(item.path.slice(1));
+                        })
+                    }
+                );
+                break;
+            }
+        }
+
+    }
+
     uploadDelAll() {
         Object.keys(this.imgPathToDelHash).forEach(k => {
-            this.getSmmsServer().del(imgManager.imgPathToDelHash[k])
+            this.getUploadServer().del(imgManager.imgPathToDelHash[k])
             delete imgManager.imgPathToDelHash[k];
         })
     }
@@ -201,47 +243,79 @@ class ImgManager {
             let filePath = decodeURI(item.src).replace(/^file:\/\/\//, '');
             if (fs.existsSync(filePath)) {
                 arr.push(filePath);
-            } else {
             }
-        })
-
-        this.getUploadServer().upload(arr,this.imgBaseDir,(success,error)=>{
-            updateSrc(success)
-            updateError(error)
+        });
+        let statuContentItem = document.querySelector('#status-content');
+        statuContentItem.innerText = '';
+        statuContentItem.style.opacity = 1;
+        let content = '';
+        let order = 0;
+        let serverType = {
+            smms: 'WebSM',
+            qiniu: 'QiNiu',
+            cos: 'WebCOS'
+        }
+        this.getUploadServer().upload(arr, this.imgBaseDir, (info, success, error) => {
+            if (info.order > order) {
+                order = info.order;
+                if (info.isLoading) {
+                    content = `[${info.finishedCount}/${info.totalCount}]`;
+                    content += `"${info.response.id}" uploaded to ${__(serverType[info.serverType])} finished!`;
+                    if (info.nextPath)
+                        content += `And uploading "${info.nextPath}"`;
+                    statuContentItem.innerText = content;
+                } else {
+                    updateSrc(success)
+                    updateError(error)
+                    content = `[${info.finishedCount}/${info.totalCount}]`;
+                    content += `Upload End! Success: ${success.length} | Failed: ${error.length}|`;
+                    statuContentItem.innerText = content;
+                    setTimeout(() => {
+                        statuContentItem.style.opacity = 0;
+                    }, 5000)
+                }
+            }
         });
 
         function updateError(errorList) {
-                let errMsg = '';
-                errorList.forEach((response) => {
+            let errMsg = '';
+            let maxIndex = errorList.length - 1;
+            if (maxIndex >= 0) {
+                errorList.forEach((response, index) => {
                     errMsg += response.id + ':' + __(response.msg) + '</br>';
+                    if (maxIndex == index) {
+                        window.popMessageShell(null, {
+                            content: errMsg,
+                            type: 'danger',
+                            autoHide: false
+                        })
+                    }
                 })
-                if (errMsg) {
-                    window.popMessageShell(null, {
-                        content: errMsg,
-                        type: 'danger',
-                        autoHide: false
-                    })
-                } else {
-                    window.popMessageShell(null, {
-                        content: __('All Files') + ' ' + __('Upload Finished'),
-                        type: 'success',
-                        btnTip: 'check',
-                        autoHide: true
-                    });
-                }
+            } else {
+                window.popMessageShell(null, {
+                    content: __('All Files') + ' ' + __('Upload Finished'),
+                    type: 'success',
+                    btnTip: 'check',
+                    autoHide: true
+                });
+            }
         }
 
         function updateSrc(successList) {
-            var content = editor.getValue();
-            successList.forEach((response) => {
+            let content = editor.getValue();
+            let maxIndex = successList.length - 1;
+            successList.forEach((response, index) => {
+                uploadList.push(response);
                 content = content.replace(new RegExp(imgManager.imgPathToMarkURL[response.id], 'g'), response.data.url);
                 imgManager.imgPathToUrlPath[response.id] = response.data.path;
                 imgManager.imgPathToMarkURL[response.id] = response.data.url;
-                imgManager.imgPathToDelHash[response.id] = response.data.hash||'';
-            })
-            editor.setValue(content);
-            hexoWindow.content = content;
-            hexoWindow.changed = true;
+                imgManager.imgPathToDelHash[response.id] = (response.data.hash || '');
+                if (maxIndex == index) {
+                    editor.setValue(content);
+                    hexoWindow.content = content;
+                    hexoWindow.changed = true;
+                }
+            });
         }
     }
 }

+ 26 - 20
views/main/index.html

@@ -121,30 +121,36 @@
             <div id="cover-bottom">
                 <div id="cover-bottom-background-left"></div>
                 <div id="cover-bottom-background-right"></div>
-                <div id="cover-bottom-left">
-                    <div class="button-bottom l10n-title" id="button-bottom-menu" title="Menu">
-                        <i class="fa fa-bars" aria-hidden="true"></i>
-                    </div>
-                    <!--<div class="button-bottom l10n-title"  title="Refresh" onclick="location.reload(true)">-->
+                <div id="cover-bottom-tools">
+                    <div id="cover-bottom-left">
+                        <div class="button-bottom l10n-title" id="button-bottom-menu" title="Menu">
+                            <i class="fa fa-bars" aria-hidden="true"></i>
+                        </div>
+                        <!--<div class="button-bottom l10n-title"  title="Refresh" onclick="location.reload(true)">-->
                         <!--<i class="fa fa-refresh" aria-hidden="true"></i>-->
-                    <!--</div>-->
-                    <!--<div class="button-bottom l10n-title" id="button-bottom-file-tree" title="Directory">-->
+                        <!--</div>-->
+                        <!--<div class="button-bottom l10n-title" id="button-bottom-file-tree" title="Directory">-->
                         <!--<i class="fa fa-folder-o" aria-hidden="true"></i>-->
-                    <!--</div>-->
-                </div>
-                <div id="cover-bottom-right">
-                    <div class="button-bottom l10n-title" id="button-bottom-focus" title="Toggle focus mode">
-                        <i class="fa fa-dot-circle-o" aria-hidden="true"></i>
+                        <!--</div>-->
                     </div>
-
-                    <div class="button-bottom l10n-title"  title="Write Mode" exdata="(Ctrl+W)" mode-button="write">
-                        <i class="fa fa-pencil" aria-hidden="true"></i>
+                    <div id="cover-bottom-status">
+                        <div class="status-button"></div>
+                        <div id="status-content" class="transition"></div>
                     </div>
-                    <div class="button-bottom l10n-title"  title="Preview Mode" exdata="(Ctrl+P)" mode-button="preview">
-                        <i class="fa fa-pencil-square-o" aria-hidden="true"></i>
-                    </div>
-                    <div class="button-bottom l10n-title"  title="Read Mode" exdata="(Ctrl+R)" mode-button="read">
-                        <i class="fa fa-eye" aria-hidden="true"></i>
+                    <div id="cover-bottom-right">
+                        <div class="button-bottom l10n-title" id="button-bottom-focus" title="Toggle focus mode">
+                            <i class="fa fa-dot-circle-o" aria-hidden="true"></i>
+                        </div>
+
+                        <div class="button-bottom l10n-title"  title="Write Mode" exdata="(Ctrl+W)" mode-button="write">
+                            <i class="fa fa-pencil" aria-hidden="true"></i>
+                        </div>
+                        <div class="button-bottom l10n-title"  title="Preview Mode" exdata="(Ctrl+P)" mode-button="preview">
+                            <i class="fa fa-pencil-square-o" aria-hidden="true"></i>
+                        </div>
+                        <div class="button-bottom l10n-title"  title="Read Mode" exdata="(Ctrl+R)" mode-button="read">
+                            <i class="fa fa-eye" aria-hidden="true"></i>
+                        </div>
                     </div>
                 </div>
             </div>

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

@@ -65,6 +65,7 @@ document.addEventListener('DOMContentLoaded', () => {
     }
     ipcRenderer.on('pop-message-shell',popMessageShell)  ;
 
+
     ipcRenderer.on('refresh-editor', function () {
         let hexoWindow  = window.hexoWindow;
         if (hexoWindow.fileName !== '') {

+ 8 - 3
views/main/moe-settings.js

@@ -111,7 +111,7 @@ function setHighlightTheme(val) {
         link.id = 'highlight-theme';
     }
     let file = path.join(themedir, `${val}.css`);
-    link.href = fs.existsSync(file) ? file : '';
+    link.href = (fs.existsSync(file) ? file : '');
 
     link = document.getElementById('highlight-theme-index');
     if (!link) {
@@ -120,8 +120,12 @@ function setHighlightTheme(val) {
         link.rel = 'stylesheet';
         link.id = 'highlight-theme-index';
     }
-    file = path.join(themedir, 'index.css');
-    link.href = fs.existsSync(file) ? file : '';
+    if ( val == 'none'){
+        link.href = '';
+    } else{
+        file = path.join(themedir, 'index.css');
+        link.href = (fs.existsSync(file) ? file : '');
+    }
 }
 
 function setRenderTheme(val) {
@@ -158,6 +162,7 @@ function setHexoConfigEnable(val) {
 };
 
 function setHexoConfig(val) {
+    imgManager.updateBase();
     hexo.changeConfig();
     window.updatePreview(true);
 };

+ 59 - 34
views/main/moe-style.css

@@ -23,7 +23,7 @@
     --spaceY: 30px;
 }
 
-.notransition, .notransition *:not(.CodeMirror-cursors):not(.CodeMirror-lines):not(.CodeMirror-sizer):not(.CodeMirror-vscrollbar) {
+.notransition, .notransition *:not(.transition):not(.CodeMirror-cursors):not(.CodeMirror-lines):not(.CodeMirror-sizer):not(.CodeMirror-vscrollbar) {
     transition: none !important;
 }
 
@@ -43,6 +43,17 @@ html, body {
     -webkit-user-select: none;
 }
 
+body{
+    background: #fff !important;
+    overflow-x: hidden !important;
+    margin: 0 !important;
+    -webkit-user-select: none !important;
+    cursor: default !important;
+    width: calc(100% - 2px) !important;
+    height: calc(100% - 2px) !important;
+    border: 1px solid #d2d2d2 !important;
+}
+
 #side-menu {
     width: 300px;
     margin-left: -300px;
@@ -114,12 +125,11 @@ html, body {
 
 #main {
     transition: all 500ms ease-in-out;
-    position: fixed;
-    left: 0;
-    top: 0;
-    width: calc(100% - 2px);
-    height: calc(100% - 2px);
-    border: 1px solid rgba(128, 128, 128, 0.3);
+    position: fixed !important;
+    left: 1px !important;
+    top: 1px !important;
+    width: calc(100% - 2px) !important;
+    height: calc(100% - 2px) !important;
 }
 
 #main-container {
@@ -294,31 +304,6 @@ html, body {
     line-height: 2;
 }
 
-#cover-bottom-left {
-    position: absolute;
-    left: 0;
-    width: calc(50% - 10px);
-    height: 100%;
-    padding-left: 10px;
-}
-
-#cover-bottom-right {
-    position: absolute;
-    right: 0;
-    width: calc(50% - 10px);
-    height: 100%;
-    padding-right: 10px;
-    text-align: right;
-}
-
-#cover-bottom .button-bottom.hover {
-    color: #cecece;
-}
-
-#cover-bottom .button-bottom:active {
-    color: #dcdcdc;
-}
-
 /*#editor * {
     transition: all 500ms ease-in-out;
 }*/
@@ -358,7 +343,7 @@ body[settings-editor-font="sans"] #editor  * {
 @media screen and (min-width: 875px){
     .read #container {
         max-width: 1200px !important;
-        width: 70% !important;
+        width: calc(100% - 45px * 2) !important;
     }
 }
 
@@ -580,8 +565,48 @@ div#cover-bottom {
 }
 
 
+
 #editor.ctrl span.cm-string.cm-url:hover {
     text-decoration: underline;
     color: blue;
     cursor: pointer;
-}
+}
+
+#cover-bottom-tools{
+    display: flex;
+    width: 100%;
+    height: 100%;
+}
+
+
+#cover-bottom-left {
+    padding-left: 10px;
+    z-index: 1;
+}
+#cover-bottom-status{
+    flex: 1;
+    z-index: 1;
+    line-height: 25px;
+    padding-left: 10px;
+}
+#cover-bottom-status #status-content{
+    flex: 1;
+    font-size: 13px;
+    line-height: 25px;
+    color: #808080;
+    opacity: 1;
+    transition: opacity 1s;
+}
+
+#cover-bottom-right {
+    padding-right: 10px;
+    z-index: 1;
+}
+
+#cover-bottom .button-bottom.hover {
+    color: #cecece;
+}
+
+#cover-bottom .button-bottom:active {
+    color: #dcdcdc;
+}

+ 3 - 2
views/settings/moe-settings.css

@@ -28,8 +28,9 @@ body {
     margin: 0;
     -webkit-user-select: none;
     cursor: default;
-    width: 100%;
-    height: 100%;
+    width: calc(100% - 2px);
+    height: calc(100% - 2px);
+    border: 1px solid #d2d2d2;
 }
 
 #main {

+ 36 - 26
views/settings/moe-settings.js

@@ -213,6 +213,11 @@ document.addEventListener('DOMContentLoaded', () => {
     let hexoConfigEnableButton = document.querySelector('input[data-key="hexo-config-enable"]');
     let hexoConfigLoadButton = document.querySelector('#hexo-config-btn');
     let hexoConfigInput = document.querySelector('input[data-key="hexo-config"]');
+
+    hexoConfigEnableButton.addEventListener('click',()=>{
+        moeApp.config.set('hexo-config-enable', hexoConfigEnableButton.checked);
+        ipcRenderer.send('setting-changed', {key: 'hexo-config-enable', val: hexoConfigEnableButton.checked});
+    })
     hexoConfigLoadButton.addEventListener('click', () => {
         dialog.showOpenDialog(window.hexoWindow, {
             properties: ['openFile'],
@@ -421,37 +426,42 @@ document.addEventListener('DOMContentLoaded', () => {
             isFindStyle = newCustomeTheme(themes[hexoTheme])
         }
         //未配置主题,自动配置
-        let classDir = path.join(hexoConfig.__basedir, hexoConfig.public_dir, 'css');
-        if (!isFindStyle) {
-            if (fs.existsSync(classDir) && fs.lstatSync(classDir).isDirectory()) {
-                isFindStyle = newCustomeTheme(classDir);
+        let classDir = '';
+        if (hexoConfig.__basedir && fs.existsSync(hexoConfig.__basedir)){
+            if(hexoConfig.public_dir){
+                classDir = path.join(hexoConfig.__basedir, hexoConfig.public_dir, 'css');
             }
-        }
-        if (isFindStyle) {
-            for (let item in themes) {
-                if (themes.hasOwnProperty(item) && themes[item] == classDir) {
-                    delete themes[item];
+            if (!isFindStyle) {
+                if (fs.existsSync(classDir) && fs.lstatSync(classDir).isDirectory()) {
+                    isFindStyle = newCustomeTheme(classDir);
                 }
             }
+            if (isFindStyle) {
+                for (let item in themes) {
+                    if (themes.hasOwnProperty(item) && themes[item] == classDir) {
+                        delete themes[item];
+                    }
+                }
 
-            themes[hexoTheme] = classDir;
-            moeApp.config.set('custom-render-themes', themes);
-            moeApp.config.set("render-theme", hexoTheme);
+                themes[hexoTheme] = classDir;
+                moeApp.config.set('custom-render-themes', themes);
+                moeApp.config.set("render-theme", hexoTheme);
 
-            reloadRenderThemeSelect(hexoTheme);
-            reloadHighlightSelect(hexoTheme);
-        } else {
-            dialog.showMessageBox(
-                window.hexoWindow,
-                {
-                    type: 'warning',
-                    title: __('Waring'),
-                    message: __("WaringNoFile"),
-                    detail: __("WaringNoFileDetail1") + classDir + __("WaringNoFileDetail2")
-                },
-                function (res) {
-                }
-            )
+                reloadRenderThemeSelect(hexoTheme);
+                reloadHighlightSelect(hexoTheme);
+            } else {
+                dialog.showMessageBox(
+                    window.hexoWindow,
+                    {
+                        type: 'warning',
+                        title: __('Waring'),
+                        message: __("WaringNoFile"),
+                        detail: __("WaringNoFileDetail1") + classDir + __("WaringNoFileDetail2")
+                    },
+                    function (res) {
+                    }
+                )
+            }
         }
     })
 

+ 0 - 7
views/settings/settings.html

@@ -186,13 +186,6 @@
                                     <div style="display: inline-block; margin-left: -1px; position: absolute; " id="hexo-config-btn">
                                         <button class="button-add-remove button-add" ><i class="fa fa-folder-o" aria-hidden="true"></i></button>
                                     </div>
-                                    <script>
-                                        const enable = moeApp.config.get('hexo-config-enable');
-                                        if (!enable){
-                                            $('input[data-key="hexo-config"]').hide();
-                                            $('#hexo-config-btn').hide();
-                                        }
-                                    </script>
                                 </td>
                             </tr>
                             <tr style="height: 60px; ">