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(', ')} +
${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);