Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Commit

Permalink
Merge pull request #4 from anilibria/dev
Browse files Browse the repository at this point in the history
dev
  • Loading branch information
turarabu authored Sep 25, 2019
2 parents 78a62e0 + b0d66ac commit 93294b5
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 0 deletions.
59 changes: 59 additions & 0 deletions core/update.js
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()
})
}
4 changes: 4 additions & 0 deletions dev-app-update.yml
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
15 changes: 15 additions & 0 deletions public/update.html
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>
Binary file added source/assets/images/Nezuko-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/assets/images/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions source/style/base.styl
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
6 changes: 6 additions & 0 deletions source/style/palette.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$black = #000
$white = #FFF
$red = #D73C2C

$wetasphalt = #3C4A59
$midnight = #2C3A49
11 changes: 11 additions & 0 deletions source/update.js
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')
90 changes: 90 additions & 0 deletions source/update.vue
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>

0 comments on commit 93294b5

Please sign in to comment.