From 22ee98569c1a88f6083853981970d5f01ca7b696 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 24 Nov 2017 11:29:40 +0800 Subject: [PATCH] =?UTF-8?q?1=20=E4=B8=AA=E4=BF=AE=E5=A4=8D,=201=20?= =?UTF-8?q?=E4=B8=AA=E6=96=B0=E5=A2=9E=EF=BC=8C2=20=E4=B8=AA=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20=E4=BF=AE=E5=A4=8D=EF=BC=9A=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E7=89=88=20npm=20=E6=A8=A1=E5=9D=97=E7=9A=84=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E6=9C=89=E8=AF=AF=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=EF=BC=9A=E5=8F=B3=E9=94=AE=E8=8F=9C=E5=8D=95-=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E5=BA=94=E7=94=A8=20=E4=BC=98=E5=8C=96=EF=BC=9A?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=8D=87=E7=BA=A7=E5=90=8E=E7=9A=84=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E5=8A=9F=E8=83=BD=20=E4=BC=98=E5=8C=96=EF=BC=9A?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E6=A1=86=E8=BE=93=E5=87=BA=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=9A=84=E6=98=BE=E7=A4=BA=E2=80=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + package.json | 24 +++++++++++++++++++----- src/css/style.css | 15 +++++++++++++-- src/js/updater.js | 43 +++++++++++++++++++++++++++++-------------- 4 files changed, 62 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index f779a98..027bb2c 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ GUI workflow for Front-End developers based on Electron - 刷新:刷新页面 - 开发者工具:开启或关闭开发者工具 - 检查更新:检查是否有新版本 + - 重启应用:刷新解决不了的问题就重启吧 - 在线更新: - 打开应用后默认检查更新,右键菜单也可以点击检查更新 - 当 github 上存在更新的版本时,显示 **一键升级** 按钮 diff --git a/package.json b/package.json index e1fc5ad..326a712 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,25 @@ { "name": "splice", - "version": "1.1.1", + "version": "1.1.2", "manifest": [{ + "version": "1.1.2", + "files": ["src/js/updater.js", "README.md", "src/css/style.css"], + "packages": [], + "logs": ["修复:发布版 npm 模块的下载位置有误", "新增:右键菜单-重启应用", "优化:应用升级后的重启功能", "优化:对话框输出信息的显示"] + }, { "version": "1.1.1", - "files": ["src/js/index.js", "src/js/modules.js", "src/js/workflow.js", "src/main.js"], - "packages": ["gulp-base64"], - "logs": ["css 新增功能:图片转 base64"] + "files": [ + "src/js/index.js", + "src/js/modules.js", + "src/js/workflow.js", + "src/main.js" + ], + "packages": [ + "gulp-base64" + ], + "logs": [ + "css 新增功能:图片转 base64" + ] }], "description": "GUI workflow for Front-End developers based on Electron", "main": "src/main.js", @@ -92,4 +106,4 @@ "last 10 versions", "not ie <= 8" ] -} +} \ No newline at end of file diff --git a/src/css/style.css b/src/css/style.css index f5adaa3..f2a57ff 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -364,7 +364,8 @@ position: fixed; right: 16px; background-color: #fff; - box-shadow: 0 2px 4px rgba(0,0,0,.12),0 0 6px rgba(0,0,0,.04); + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.32),0 0 6px rgba(0,0,0,.04); + border: 1px solid rgba(0, 0, 0, 0.12); transition: opacity .3s,transform .3s,right .3s,top .4s; overflow: hidden; opacity: 0; @@ -608,11 +609,17 @@ margin: 0 auto; } .notification__dialog .notification__content { - height: 230px; + min-height: 150px; + max-height: 400px; overflow-y: scroll; margin: 16px -20px 0; padding: 0 20px; } +.notification__content pre { + /*换行*/ + word-break: break-word; + white-space: pre-line; +} .notification__footer { text-align: center; } @@ -623,3 +630,7 @@ opacity: 1; transition: all 250ms ease-out; } +#dialogBtn { + margin-left: 50%; + transform: translateX(-50%); +} \ No newline at end of file diff --git a/src/js/updater.js b/src/js/updater.js index e08ff82..9f23579 100644 --- a/src/js/updater.js +++ b/src/js/updater.js @@ -1,4 +1,10 @@ var updater = { + // 重启应用 + relaunch: function() { + remote.app.relaunch(); + remote.app.exit(0); + }, + // 右键菜单 contextmenu: function () { var self = this; var menu = new Menu(); @@ -23,6 +29,10 @@ var updater = { self.updateDetect(self.app); } })); + menu.append(new MenuItem({ + label: '重启应用', + click: self.relaunch + })); window.addEventListener('contextmenu', function (event) { event.preventDefault(); @@ -232,7 +242,7 @@ var updater = { } } document.getElementById('dialogBtn').addEventListener('click', function(e) { - location.reload(); + self.relaunch(); }); var done = function(progress, autoload, content) { console.log('progress is', progress); @@ -245,7 +255,7 @@ var updater = { // 升级成功,重载中... // 提示信息 btnTxt('升级成功,重载中...') - location.reload(); + self.relaunch(); }, 3000); } else { if (content) {app.dialogTitle = '模块安装提示'; @@ -253,9 +263,8 @@ var updater = { app.showDialogBtn = true; app.dialogBtn = '重启应用'; app.showDialog = true; - } else { - location.reload(); + self.relaunch(); } } } @@ -472,7 +481,7 @@ var updater = { // 安装新增模块 if (packages.length > 0) { - console.log('需要安装新模块'); + console.log('需要安装新模块:' + packages.join(',')); self.install(packages, function(stdout, stderr) { console.log('stdout, stderr', stdout, stderr); // showMsg(`执行 npm install 安装新增模块时输出如下: @@ -480,13 +489,14 @@ var updater = { // ${stderr} // 如有问题,请自行在应用根目录安装如下模块: // ${packages.join(', ')}`); - let content = `如有问题,请自行在应用根目录安装新增的 npm 模块: - ${packages.join(', ')} + let content = `如重启后使用有问题,请自行在应用根目录(.../resources/app/)安装新增的 npm 模块: + ${packages.join(', ')} +

执行 npm install 安装新增模块时输出如下
- ${stdout} - ${stderr} +
${stdout}
+                                                    ${stderr}
`; // 确认信息后点击重启应用 done(progress, false, content); @@ -496,12 +506,13 @@ var updater = { // ${error} // 请自行在应用根目录安装如下模块: // ${packages.join(', ')}`); - let content = `请自行在应用根目录安装新增的 npm 模块: - ${packages.join(', ')} + let content = `请自行在应用根目录(.../resources/app/)安装新增的 npm 模块: + ${packages.join(', ')} +

执行 npm install 安装新增模块时出错
- ${error} +
${error}
`; // 确认信息后点击重启应用 done(progress, false, content); @@ -531,8 +542,12 @@ var updater = { success = success || function() {}; fail = fail || function() {}; - let cmd = `npm i -S ${packages.join(' ')}`; - exec(cmd, function(error, stdout, stderr) { + // __dirname 是项目运行时入口文件所在的文件夹 + let folder = path.join(__dirname, '../'); + let cmd = `npm i -S ${packages.join(' ')} --prefix ./`; + exec(cmd, { + cwd: folder + }, function(error, stdout, stderr) { if (error) { console.error(`exec error: ${error}`); fail(error);