Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
Change-Id: Id4c4526dcda8e3dbf10d420175c79df2434342d1
  • Loading branch information
CS-Tao committed Oct 22, 2020
2 parents d5ffa64 + 747fae7 commit dc5bbd7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

| 平台 | Windows | Mac OS | Linux |
| :------- | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| 下载链接 | [![Windows 版本下载链接 v1.9.6](https://img.shields.io/badge/v1.9.6-Windows-limegreen.svg)](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.9.6/whu-library-seat-1.9.6.exe) | [![Mac OS 版本下载链接 v1.9.6](https://img.shields.io/badge/v1.9.6-Mac%20OS-limegreen.svg)](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.9.6/whu-library-seat-1.9.6.dmg) | [![Linux 版本下载链接 v1.9.6](https://img.shields.io/badge/v1.9.6-Linux-limegreen.svg)](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.9.6/whu-library-seat-1.9.6-x86_64.AppImage) |
| 下载链接 | [![Windows 版本下载链接 v1.9.7](https://img.shields.io/badge/v1.9.7-Windows-limegreen.svg)](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.9.7/whu-library-seat-1.9.7.exe) | [![Mac OS 版本下载链接 v1.9.7](https://img.shields.io/badge/v1.9.7-Mac%20OS-limegreen.svg)](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.9.7/whu-library-seat-1.9.7.dmg) | [![Linux 版本下载链接 v1.9.7](https://img.shields.io/badge/v1.9.7-Linux-limegreen.svg)](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.9.7/whu-library-seat-1.9.7-x86_64.AppImage) |

### 申请软件使用权

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "whu-library-seat",
"version": "1.9.6",
"version": "1.9.7",
"author": "CS-Tao <[email protected]>",
"description": "图书馆助手",
"license": null,
Expand All @@ -12,6 +12,7 @@
"build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js",
"build:docs": "vuepress build docs",
"dev": "node .electron-vue/dev-runner.js",
"dev:publish": "TEST_PUBLISH=true yarn dev",
"dev:docs": "vuepress dev docs",
"e2e": "npm run pack && mocha test/e2e",
"lint": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter src test",
Expand Down
3 changes: 3 additions & 0 deletions src/main/dev-app-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
owner: cs-tao
repo: whu-library-seat
provider: github
20 changes: 13 additions & 7 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import path from 'path'
import Store from 'electron-store'
import notifier from 'node-notifier'

const isDev = process.env.NODE_ENV !== 'production'

/**
* Set `__static` path to static files in production
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
*/
if (process.env.NODE_ENV !== 'development') {
if (!isDev) {
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
}

Expand All @@ -19,7 +21,7 @@ const store = new Store({
})

let mainWindow
const winURL = process.env.NODE_ENV === 'development'
const winURL = isDev
? `http://localhost:9080`
: `file://${__dirname}/index.html`

Expand Down Expand Up @@ -309,7 +311,7 @@ ipcMain.on('show-window-notify', (event, title, message) => {
title: title,
subTitle: title,
message: message,
icon: process.env.NODE_ENV !== 'production'
icon: isDev
? path.join(__static, 'toast.png')
: (process.platform === 'darwin'
? './Contents/Resources/static/toast.png'
Expand All @@ -331,11 +333,15 @@ autoUpdater.autoDownload = false
autoUpdater.autoInstallOnAppQuit = true
autoUpdater.allowDowngrade = true

if (isDev) {
autoUpdater.updateConfigPath = path.join(__dirname, 'dev-app-update.yml')
}

ipcMain.on('check-updates', (event, arg) => {
// 检查更新
if (process.env.NODE_ENV === 'production') {
if (!isDev || process.env.TEST_PUBLISH) {
autoUpdater.checkForUpdates().then((info) => {
mainWindow.webContents.send('update-available', info)
mainWindow.webContents.send('update-available', {...info, showOpenLink: process.platform === 'darwin'})
}).catch((error) => {
mainWindow.webContents.send('check-update-error', error)
})
Expand All @@ -344,12 +350,12 @@ ipcMain.on('check-updates', (event, arg) => {

ipcMain.on('download-update', (event, arg) => {
// 下载更新
if (process.env.NODE_ENV === 'production') autoUpdater.downloadUpdate()
if (!isDev || process.env.TEST_PUBLISH) autoUpdater.downloadUpdate()
})

ipcMain.on('quit-and-install', (event, arg) => {
// 退出安装
if (process.env.NODE_ENV === 'production') {
if (!isDev || process.env.TEST_PUBLISH) {
if (tray) {
tray.destroy()
}
Expand Down
18 changes: 15 additions & 3 deletions src/renderer/components/Footer/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<div class="footer" :class="{'footer-unlogin': !hasToken}">
<div class="warper flex-col" @click.stop="openMainBody()">
<span style="cursor: default!important;">&nbsp;&nbsp;</span>
<el-button v-if="updateAvailable" type="primary" class="el-icon-download update-button" @click.stop="downloadUpdate()">&nbsp;最新版本(v{{newVersion}})</el-button>
<el-button v-if="updateDownloaded" type="primary" class="el-icon-refresh update-button" @click.stop="quitAndUpdate()">&nbsp;重启更新</el-button>
<el-button v-if="updateAvailable" type="primary" class="el-icon-download update-button" @click.stop="updateAssetsLink ? openUpdateLink() : downloadUpdate()">&nbsp;最新版本(v{{newVersion}})</el-button>
<el-button v-else-if="updateDownloaded" type="primary" class="el-icon-refresh update-button" @click.stop="quitAndUpdate()">&nbsp;重启更新</el-button>
<div v-if="updateDownloadInfo" class="progress-wraper" @click.stop="showProgressInfo()">
<el-progress :text-inside="true" :stroke-width="26" color="rgba(0, 204, 0, 0.5)" :percentage="parseFloat(updateDownloadInfo.percent.toFixed(1))"></el-progress>
<span>&nbsp;&nbsp;{{`${this.getByteFormat(this.updateDownloadInfo.bytesPerSecond)}/s`}}</span>
Expand Down Expand Up @@ -62,6 +62,8 @@ import { mapGetters } from 'vuex'
import { ipcRenderer, remote } from 'electron'
import androidQrCode from '@/assets/last-android.png'
const updateUrl = 'https://github.com/CS-Tao/whu-library-seat#最新版本下载'
export default {
props: {
bodyMode: {
Expand All @@ -77,7 +79,8 @@ export default {
updateDownloadInfo: null,
// 更新下载完毕
updateDownloaded: false,
notifyUpdateInfo: false
notifyUpdateInfo: false,
updateAssetsLink: null
}
},
computed: {
Expand Down Expand Up @@ -111,6 +114,9 @@ export default {
mounted () {
// 有可用更新
ipcRenderer.on('update-available', (event, args) => {
if (args.showOpenLink) {
this.updateAssetsLink = updateUrl
}
this.newVersion = args.updateInfo.version
if (this.notifyUpdateInfo) {
if (this.updateAvailable) {
Expand Down Expand Up @@ -140,11 +146,13 @@ export default {
ipcRenderer.on('update-downloaded', () => {
this.updateDownloaded = true
this.updateDownloadInfo = null
this.updateAssetsLink = null
ipcRenderer.send('show-window-notify', '更新下载完毕', '请重启更新')
})
// 检查更新出现错误
ipcRenderer.on('check-update-error', (event, error) => {
this.updateDownloadInfo = null
this.updateAssetsLink = null
if (this.notifyUpdateInfo) {
this.$message({
type: 'info',
Expand All @@ -160,6 +168,7 @@ export default {
this.notifyUpdateInfo = true
this.newVersion = null
this.updateDownloadInfo = null
this.updateAssetsLink = null
this.updateDownloaded = false
this.$message({
type: 'info',
Expand Down Expand Up @@ -245,6 +254,9 @@ export default {
ipcRenderer.send('quit-and-install')
ipcRenderer.send('exit-app', 0)
},
openUpdateLink () {
this.$openLink(this.updateAssetsLink)
},
showProgressInfo () {
this.$message({
type: 'info',
Expand Down

0 comments on commit dc5bbd7

Please sign in to comment.