diff --git a/core/update.js b/core/update.js new file mode 100644 index 0000000..7c75484 --- /dev/null +++ b/core/update.js @@ -0,0 +1,59 @@ +const { autoUpdater } = require('electron-updater') +const { app } = require('electron') + +const Window = require('./window') +const ipc = require('./ipc') + +const temp = [] +const wName = 'update' + +module.exports = { check, start, windowOpen } + +function check () { + ipc.send('set-update-status', wName, 1) + + return new Promise(function (resolve) { + autoUpdater.autoDownload = false + autoUpdater.checkForUpdates() + .then(result => { + var available = result.updateInfo.version + resolve(available > app.getVersion()) + }) + .catch(() => { + setTimeout(async () => { + temp[0] = await check() + resolve(temp[0]) + }, 10 * 1000) + }) + }) +} + +async function start () { + ipc.send('set-update-status', wName, 2) + + return new Promise(function (resolve) { + autoUpdater.downloadUpdate() + .then(result => { + if( result.length > 0 ) { + ipc.send('set-update-status', wName, 3) + autoUpdater.quitAndInstall(true, true) + } + }) + .catch(() => { + setTimeout(async () => { + temp[1] = await start() + resolve(temp[1]) + }, 10 * 1000) + }) + }) + // app.exit() +} + +function windowOpen () { + Window.open(wName, { + height: 320, + width: 260 + }).then(window => { + window.webContents.openDevTools() + }) +} \ No newline at end of file diff --git a/dev-app-update.yml b/dev-app-update.yml new file mode 100644 index 0000000..c4d20f1 --- /dev/null +++ b/dev-app-update.yml @@ -0,0 +1,4 @@ +owner: anilibria +repo: electron +provider: github +updaterCacheDirName: anilibria-cross-app-updater diff --git a/public/update.html b/public/update.html new file mode 100644 index 0000000..3b0c805 --- /dev/null +++ b/public/update.html @@ -0,0 +1,15 @@ + + + + + + + + + AniLibria Обновление + + + + + + \ No newline at end of file diff --git a/source/assets/images/Nezuko-01.png b/source/assets/images/Nezuko-01.png new file mode 100644 index 0000000..cba958b Binary files /dev/null and b/source/assets/images/Nezuko-01.png differ diff --git a/source/assets/images/loading.gif b/source/assets/images/loading.gif new file mode 100644 index 0000000..3a76889 Binary files /dev/null and b/source/assets/images/loading.gif differ diff --git a/source/style/base.styl b/source/style/base.styl new file mode 100644 index 0000000..b036a78 --- /dev/null +++ b/source/style/base.styl @@ -0,0 +1,8 @@ +* + box-sizing border-box + font-family 'Roboto', sans-serif + margin 0 + padding 0 + text-decoration: none + transition .15s all + user-select none \ No newline at end of file diff --git a/source/style/palette.styl b/source/style/palette.styl new file mode 100644 index 0000000..0744ee1 --- /dev/null +++ b/source/style/palette.styl @@ -0,0 +1,6 @@ +$black = #000 +$white = #FFF +$red = #D73C2C + +$wetasphalt = #3C4A59 +$midnight = #2C3A49 \ No newline at end of file diff --git a/source/update.js b/source/update.js new file mode 100644 index 0000000..3997a9c --- /dev/null +++ b/source/update.js @@ -0,0 +1,11 @@ +import Vue from 'vue' + +// import router from ':src/script/router' +// import store from ':src/script/store' + +import index from ':src/update.vue' + +window.app = new Vue({ + // router, store, + render: handler => handler(index) +}).$mount('#app') \ No newline at end of file diff --git a/source/update.vue b/source/update.vue new file mode 100644 index 0000000..f2be57a --- /dev/null +++ b/source/update.vue @@ -0,0 +1,90 @@ + + + + + \ No newline at end of file