This repository has been archived by the owner on Mar 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from anilibria/dev
dev
- Loading branch information
Showing
9 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
owner: anilibria | ||
repo: electron | ||
provider: github | ||
updaterCacheDirName: anilibria-cross-app-updater |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset='UTF-8'> | ||
<meta name='viewport', content='width=1920, initial-scale=1.0'> | ||
|
||
<link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400,500&display=swap&subset=cyrillic,cyrillic-ext,latin-ext' rel="stylesheet"> | ||
|
||
<title>AniLibria Обновление</title> | ||
</head> | ||
|
||
<body id="app"> | ||
|
||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$black = #000 | ||
$white = #FFF | ||
$red = #D73C2C | ||
|
||
$wetasphalt = #3C4A59 | ||
$midnight = #2C3A49 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<template lang="pug"> | ||
|
||
body#update | ||
h3( class='title center' ) AniLibria | ||
p( class='status center' ) {{ status.text[ status.code ] }} | ||
img( class='loading center' src='~src/assets/images/loading.gif' ) | ||
|
||
img( class='version-sticker' src='~src/assets/images/Nezuko-01.png' ) | ||
div( class='version-div' ) | ||
span( class='text' ) Version: 0.2.0 | ||
span( class='text' ) Nezuko | ||
|
||
</template> | ||
|
||
<script> | ||
export default { | ||
mounted: start, | ||
data: function () { | ||
return { | ||
status: { | ||
text: ['Подготовка', 'Проверка наличия обновлении', 'Скачиваем обновления', 'Установка'], | ||
code: 1 | ||
} | ||
} | ||
} | ||
} | ||
function start () { | ||
ipc.on('set-update-status', (sender, codess) => { | ||
this.status.code = code | ||
}) | ||
} | ||
</script> | ||
|
||
<style lang="stylus"> | ||
@import '~src/style/base' | ||
@import '~src/style/palette' | ||
#update | ||
background $midnight | ||
color $white | ||
position absolute | ||
top 0 | ||
left 0 | ||
right 0 | ||
bottom 0 | ||
.center | ||
display block | ||
margin 0 auto | ||
text-align center | ||
.title | ||
color $red | ||
font-size 52px | ||
font-weight 400 | ||
margin-top 32px | ||
.status | ||
color darken($white, 5) | ||
font-size 14px | ||
font-weight 300 | ||
margin-top 18px | ||
.loading | ||
height 8px | ||
margin-top 6px | ||
position relative | ||
left -10px | ||
.version-sticker | ||
position absolute | ||
bottom 2px | ||
right 6px | ||
max-height 128px | ||
max-width 128px | ||
.version-div | ||
position absolute | ||
bottom 12px | ||
left 14px | ||
.text | ||
color darken($white, 15) | ||
display block | ||
font-size 10px | ||
font-weight 300 | ||
line-height 11px | ||
</style> |