Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
antSword
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HuangJunbo
antSword
Commits
ea00b9d2
Commit
ea00b9d2
authored
Jun 20, 2016
by
antoor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Program upgrades
程序升级功能
parent
0ba1db98
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
2 deletions
+43
-2
update.js
modules/update.js
+24
-2
app.entry.js
source/app.entry.js
+19
-0
No files found.
modules/update.js
View file @
ea00b9d2
...
...
@@ -6,11 +6,12 @@
*/
const
config
=
require
(
'./config'
);
const
superagent
=
require
(
'superagent'
);
class
Update
{
constructor
(
electron
)
{
this
.
logger
=
new
electron
.
Logger
(
'Update'
);
setTimeout
(
this
.
checkUpdate
.
bind
(
this
),
1000
*
60
);
electron
.
ipcMain
.
on
(
'check-update'
,
this
.
checkUpdate
.
bind
(
this
)
);
}
/**
...
...
@@ -18,8 +19,29 @@ class Update {
* 如果有更新,则以通知的方式提示用户手动更新,用户点击跳转到更新页面
* @return {[type]} [description]
*/
checkUpdate
()
{
checkUpdate
(
event
)
{
this
.
logger
.
debug
(
'checkUpdate..'
);
superagent
.
get
(
'https://api.github.com/repos/antoor/antSword/releases/latest'
)
.
end
((
err
,
ret
)
=>
{
try
{
let
lastInfo
=
JSON
.
parse
(
ret
.
text
);
let
newVersion
=
lastInfo
[
'tag_name'
];
let
curVersion
=
config
[
'package'
].
version
;
// 比对版本
if
(
curVersion
!==
newVersion
)
{
this
.
logger
.
info
(
'Found a new version'
,
newVersion
);
event
.
sender
.
send
(
'notification-update'
,
{
ver
:
newVersion
,
url
:
lastInfo
[
'html_url'
]
});
}
else
{
this
.
logger
.
warn
(
'No new version.'
);
}
}
catch
(
e
)
{
this
.
logger
.
fatal
(
'ERR'
,
e
);
}
});
}
}
...
...
source/app.entry.js
View file @
ea00b9d2
...
...
@@ -196,6 +196,20 @@ ipcRenderer
antSword
.
modules
.
shellmanager
.
category
.
cell
.
setWidth
(
222
);
},
555
);
})
/**
* 通知提示更新
* @param {[type]} 'notification-update' [description]
* @param {[type]} (e, opt [description]
* @return {[type]} [description]
*/
.
on
(
'notification-update'
,
(
e
,
opt
)
=>
{
let
n
=
new
Notification
(
'发现更新'
,
{
body
:
'新版本:'
+
opt
[
'ver'
]
});
n
.
addEventListener
(
'click'
,
()
=>
{
antSword
.
shell
.
openExternal
(
opt
[
'url'
]);
});
})
/**
* 重新加载本地插件
* @param {[type]} 'reloadPlug' [description]
...
...
@@ -222,3 +236,8 @@ ipcRenderer
});
antSword
.
reloadPlug
();
// 检查更新
setTimeout
(
antSword
.
ipcRenderer
.
send
.
bind
(
antSword
.
ipcRenderer
,
'check-update'
),
1000
*
60
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment