Skip to content

Commit b10a74a

Browse files
committed
windows 添加菜单
1 parent bde8988 commit b10a74a

File tree

4 files changed

+35
-27
lines changed

4 files changed

+35
-27
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "WeFlow",
33
"version": "1.2.0",
4+
"release": "1.1.0",
45
"description": "A minimal Electron application",
56
"main": "main.js",
67
"scripts": {

src/app.js

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -124,27 +124,25 @@ function checkLocalProjects() {
124124

125125
//检查更新
126126
function checkForUpdate(action) {
127-
if (action) {
128-
checkHandler = $.ajax({
129-
method: 'GET',
130-
url: Common.CHECKURL,
131-
dataType: 'json',
132-
cache: false,
133-
success: function (data) {
134-
if (data[0].tag_name > packageJson.version) {
135-
ipc.send('checkForUpdate', 1)
136-
}else{
137-
ipc.send('checkForUpdate', 0);
138-
}
127+
checkHandler = $.ajax({
128+
method: 'GET',
129+
url: Common.CHECKURL,
130+
dataType: 'json',
131+
cache: false,
132+
success: function (data) {
133+
if (data && data.release && data.release > packageJson.version) {
134+
ipc.send('checkForUpdate', 1)
135+
}else{
136+
action && ipc.send('checkForUpdate', 0);
139137
}
140-
});
141-
}
138+
}
139+
});
142140
}
143141

144142
ipc.on('checkForUpdateReply', function (event, index, status) {
145143
if(status){
146144
if(index === 1){
147-
alert('哈哈哈, 你真的以为我等下会提醒你吗?');
145+
alert('哈哈哈, 你真的以为我等下会提醒你吗?赶紧去下载最新版本吧!');
148146
}else{
149147
shell.openExternal(Common.DOWNLOADURL);
150148
}
@@ -693,16 +691,8 @@ $setting.on('change', 'input', function () {
693691

694692
async.series([
695693
function (next) {
696-
if (Common.PLATFORM === 'win32') {
697-
//windows 删除目录有bug
698-
next();
699-
} else {
700-
shell.moveItemToTrash(originWorkspace);
701-
next();
702-
// del([originWorkspace], {force: true}).then(function () {
703-
// next();
704-
// })
705-
}
694+
shell.moveItemToTrash(originWorkspace);
695+
next();
706696
},
707697
function (next) {
708698
//更新 localstorage

src/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Common.DEFAULT_PATH = Common.PLATFORM === 'win32' ? 'desktop' : 'home';
1616
Common.TEMPLAGE_PROJECT = path.resolve(path.join(__dirname, '../templates/project.zip'));
1717
Common.TEMPLAGE_EXAMPLE = path.resolve(path.join(__dirname, '../templates/example.zip'));
1818
Common.EXAMPLE_NAME = 'WeFlow-example';
19-
Common.CHECKURL = 'https://api.github.com/repos/weixin/WeFlow/releases';
19+
Common.CHECKURL = 'https://raw.githubusercontent.com/weixin/WeFlow/master/package.json';
2020
Common.DOWNLOADURL = 'https://github.com/weixin/WeFlow/releases';
2121

2222
Common.requireUncached = function (module) {

src/menu.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ var template = [
159159
}
160160
];
161161

162-
if (process.platform == 'darwin') {
162+
if (process.platform === 'darwin') {
163163
var name = remote.app.getName();
164164
template.unshift({
165165
label: name,
@@ -225,6 +225,23 @@ if (process.platform == 'darwin') {
225225
}
226226
]
227227
});
228+
}else if(process.platform === 'win32'){
229+
let helpItem = template[template.length-1];
230+
231+
helpItem.submenu.unshift({
232+
label: '检查更新…',
233+
accelerator: '',
234+
click: function () {
235+
checkForUpdate(true);
236+
}
237+
});
238+
239+
helpItem.submenu.unshift({
240+
label: '关于',
241+
click: function (item, focusedWindow) {
242+
showAbout();
243+
}
244+
});
228245
}
229246

230247
var menu = Menu.buildFromTemplate(template);

0 commit comments

Comments
 (0)