Skip to content

Commit da9d7a4

Browse files
committed
auto update確認
1 parent 46c6555 commit da9d7a4

3 files changed

Lines changed: 27 additions & 10 deletions

File tree

atom-lib/updater.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,38 @@ var path = require('path')
55

66
var version = app.getVersion()
77
var versionText = (version == null || version.length === 0) ? 'DEV version' : 'v' + version
8-
8+
var versionNotified = false
99
autoUpdater
1010
.on('error', function (err, message) {
1111
console.error(err)
1212
console.error(message)
13+
console.log(path.resolve(__dirname, '../resources/favicon-230x230.png'))
1314
nn.notify({
1415
title: 'Error! ' + versionText,
15-
icon: path.join(__dirname, 'browser/main/resources/favicon-230x230.png'),
16+
icon: path.resolve(__dirname, '../resources/favicon-230x230.png'),
1617
message: message
1718
})
1819
})
1920
// .on('checking-for-update', function () {
2021
// // Connecting
22+
// console.log('checking...')
2123
// })
2224
.on('update-available', function () {
2325
nn.notify({
2426
title: 'Update is available!! ' + versionText,
25-
icon: path.join(__dirname, 'browser/main/resources/favicon-230x230.png'),
27+
icon: path.resolve(__dirname, '../resources/favicon-230x230.png'),
2628
message: 'Download started.. wait for the update ready.'
2729
})
2830
})
2931
.on('update-not-available', function () {
30-
nn.notify({
31-
title: 'Latest Build!! ' + versionText,
32-
icon: path.join(__dirname, 'browser/main/resources/favicon-230x230.png'),
33-
message: 'Hope you to enjoy our app :D'
34-
})
32+
if (!versionNotified) {
33+
nn.notify({
34+
title: 'Latest Build!! ' + versionText,
35+
icon: path.resolve(__dirname, '../resources/favicon-230x230.png'),
36+
message: 'Hope you to enjoy our app :D'
37+
})
38+
versionNotified = true
39+
}
3540
})
3641

3742
module.exports = autoUpdater

browser/main/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ require('../styles/main/index.styl')
1111
import { openModal } from 'boost/modal'
1212
import Tutorial from 'boost/components/modal/Tutorial'
1313
import activityRecord from 'boost/activityRecord'
14+
import ipc from 'ipc'
1415

1516
activityRecord.init()
17+
window.addEventListener('online', function () {
18+
ipc.send('check-update', 'check-update')
19+
})
1620

1721
let routes = (
1822
<Route path='/' component={MainPage}>

main.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ updater
3030
.on('update-downloaded', function (event, releaseNotes, releaseName, releaseDate, updateUrl, quitAndUpdate) {
3131
nn.notify({
3232
title: 'Ready to Update!! ' + versionText,
33-
icon: path.join(__dirname, 'browser/main/resources/favicon-230x230.png'),
34-
message: 'Click tray icon to update app: ' + releaseName
33+
icon: path.join(__dirname, '/resources/favicon-230x230.png'),
34+
message: 'Click update button on Main window: ' + releaseName
3535
})
3636
update = quitAndUpdate
3737

@@ -50,6 +50,14 @@ app.on('ready', function () {
5050
// menu start
5151
var template = require('./atom-lib/menu-template')
5252

53+
setInterval(function () {
54+
updater.checkForUpdates()
55+
}, 1000 * 60 * 60 * 24)
56+
57+
ipc.on('check-update', function (event, msg) {
58+
updater.checkForUpdates()
59+
})
60+
5361
ipc.on('update-app', function (event, msg) {
5462
if (update != null) {
5563
appQuit = true

0 commit comments

Comments
 (0)