Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
CS-Tao committed Oct 8, 2018
2 parents 0a3b908 + 00c5c93 commit 09a77bd
Show file tree
Hide file tree
Showing 18 changed files with 432 additions and 58 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
### 稳定版本下载

- Windows
- 链接: [whu-library-seat-setup-1.3.2.exe](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.3.2/whu-library-seat-setup-1.3.2.exe)
- 链接: [whu-library-seat-setup-1.4.0.exe](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.4.0/whu-library-seat-setup-1.4.0.exe)

- Mac OS
- 链接: [whu-library-seat-1.3.2.dmg](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.3.2/whu-library-seat-1.3.2.dmg)
- 链接: [whu-library-seat-1.4.0.dmg](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.4.0/whu-library-seat-1.4.0.dmg)

- Linux
- 链接: [whu-library-seat-1.3.2-x86_64.AppImage](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.3.2/whu-library-seat-1.3.2-x86_64.AppImage)
- 链接: [whu-library-seat-1.4.0-x86_64.AppImage](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.4.0/whu-library-seat-1.4.0-x86_64.AppImage)

### 安装软件

Expand Down
6 changes: 3 additions & 3 deletions docs/specification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
#### 稳定版本下载

- Windows
- 链接: [whu-library-seat-setup-1.3.2.exe](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.3.2/whu-library-seat-setup-1.3.2.exe)
- 链接: [whu-library-seat-setup-1.4.0.exe](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.4.0/whu-library-seat-setup-1.4.0.exe)

- Mac OS
- 链接: [whu-library-seat-1.3.2.dmg](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.3.2/whu-library-seat-1.3.2.dmg)
- 链接: [whu-library-seat-1.4.0.dmg](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.4.0/whu-library-seat-1.4.0.dmg)

- Linux
- 链接: [whu-library-seat-1.3.2-x86_64.AppImage](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.3.2/whu-library-seat-1.3.2-x86_64.AppImage)
- 链接: [whu-library-seat-1.4.0-x86_64.AppImage](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.4.0/whu-library-seat-1.4.0-x86_64.AppImage)

### 安装软件

Expand Down
4 changes: 3 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.3.2",
"version": "1.4.0",
"author": "CS-Tao <whucstao@qq.com>",
"description": "武汉大学图书馆抢座软件",
"license": null,
Expand Down Expand Up @@ -66,10 +66,12 @@
"electron-store": "^2.0.0",
"electron-updater": "^3.0.3",
"element-ui": "^2.4.4",
"js-md5": "^0.7.3",
"mockjs": "^1.0.1-beta3",
"node-notifier": "^5.2.1",
"vue": "^2.3.3",
"vue-electron": "^1.0.6",
"vue-markdown": "^2.2.4",
"vue-router": "^2.5.3",
"vuepress-theme-vue": "^1.0.3",
"vuex": "^2.3.1"
Expand Down
27 changes: 23 additions & 4 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ const template = [
label: '更新日志',
click () { require('electron').shell.openExternal('https://github.com/CS-Tao/whu-library-seat/releases') }
},
{
label: '检查更新',
click () { mainWindow.webContents.send('check-update-menu-clicked') }
},
{ type: 'separator' },
{
label: '文档',
Expand Down Expand Up @@ -297,18 +301,33 @@ ipcMain.on('show-window-notify', (event, title, message) => {

// 配置自动更新

autoUpdater.autoDownload = false
autoUpdater.autoInstallOnAppQuit = true

ipcMain.on('check-updates', (event, arg) => {
// 检查更新
if (process.env.NODE_ENV === 'production') autoUpdater.checkForUpdates()
if (process.env.NODE_ENV === 'production') {
autoUpdater.checkForUpdates().then((info) => {
mainWindow.webContents.send('update-available', info)
})
}
})

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

ipcMain.on('quit-and-install', (event, arg) => {
// 退出安装
if (process.env.NODE_ENV === 'production') autoUpdater.quitAndInstall()
if (process.env.NODE_ENV === 'production') {
if (tray) {
tray.destroy()
}
autoUpdater.quitAndInstall()
}
})

autoUpdater.autoInstallOnAppQuit = false

autoUpdater.on('update-downloaded', () => {
// 更新下载完毕
mainWindow.webContents.send('update-downloaded')
Expand Down
33 changes: 10 additions & 23 deletions src/renderer/api/gitcontents.api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import axios from 'axios'
import { Message } from 'element-ui'
import urls from './urls'

var service = axios.create({
Expand All @@ -8,28 +7,6 @@ var service = axios.create({
withCredentials: true
})

// request interceptor
service.interceptors.request.use(config => {
// Do something before request is sent
return config
}, error => {
// Do something with request error
Promise.reject(error)
})

// respone interceptor
service.interceptors.response.use(
response => response,
error => {
Message({
message: error.message,
type: 'error',
duration: 3000,
showClose: true
})
return Promise.reject(error)
})

export default {
// 用户验证
validateUser: () => {
Expand All @@ -40,5 +17,15 @@ export default {
time: new Date()
}
})
},
// 公告
announce: () => {
return service({
url: urls.gitcontents.announce.url(),
method: urls.gitcontents.announce.method,
params: {
time: new Date()
}
})
}
}
26 changes: 26 additions & 0 deletions src/renderer/api/mock/gitcontents.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,31 @@ export default {
]
}
}
},
announce: config => {
console.log('Mock: ' + config.url)
return `### 公告
- 本软件的最新版本是 v1.3.2,点击菜单: \`关于 > 更新日志\`可以查看最新版本
- 短时间内向图书馆后台发送大量请求会被图书馆暂时性封号(30min),请节制使用本软件
- 如果有任何疑问可以联系我📧: whucstao@qq.com
- 发现 bug 请点击: \`关于 > 问题反馈\`
- 设置页面的软件使用数据可以帮助我改善软件,希望您可以把软件使用数据提交给我😋
- 移动端还要好几个月才会发布,敬请期待🤕
#### 如果您有多的钱,让我们支付宝见!
<p align="center"><img alt="支付宝二维码.jpg" src="https://home.cs-tao.cc/blog/img/alipayimg.jpg" width="70%" height="70%"></p>
#### 或者微信见!
<p align="center"><img alt="微信二维码.jpg" src="https://home.cs-tao.cc/blog/img/wechatimg.jpg" width="70%" height="70%"></p>
#### 祝您使用愉快,学习进步😉~
`
}
}
3 changes: 3 additions & 0 deletions src/renderer/api/mock/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import urls from '../urls'
// 用户验证
Mock.mock(urls.gitcontents.validateUser.regular, urls.gitcontents.validateUser.method, gitcontentsApi.validateUser)

// 公告
Mock.mock(urls.gitcontents.announce.regular, urls.gitcontents.announce.method, gitcontentsApi.announce)

// 登录状态
Mock.mock(urls.usage.loginState.regular, urls.usage.loginState.method, usageApi.loginState)

Expand Down
10 changes: 9 additions & 1 deletion src/renderer/api/urls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ const urls = {
},
regular: /\/user-validation\/validation.json/,
method: 'get'
},
// 公告
announce: {
url () {
return '/user-validation/announce.md'
},
regular: /\/user-validation\/announce.md/,
method: 'get'
}
},
usage: {
Expand All @@ -15,7 +23,7 @@ const urls = {
url () {
return '/loginState'
},
regular: /\/user-loginState/,
regular: /\/loginState/,
method: 'post'
},
// 抢座状态
Expand Down
71 changes: 71 additions & 0 deletions src/renderer/components/Body/Announce/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<template>
<div class="flex-row">
<div class="warp">
<vue-markdown class="mark-down" html :source="source"/>
</div>
</div>
</template>

<script>
import VueMarkdown from 'vue-markdown'
import gitcontentsApi from '@/api/gitcontents.api'
import Store from 'electron-store'
import md5 from 'js-md5'
const store = new Store({
name: 'whu-library-seat'
})
export default {
data () {
return {
source: ''
}
},
components: {
VueMarkdown
},
mounted () {
gitcontentsApi.announce().then((response) => {
if (response.status === 200) {
this.source = response.data
this.$store.dispatch('setAnnounceViewed', true)
store.set('announceMd5', md5(response.data))
}
}).catch(() => {
this.showError('公告加载失败')
})
},
methods: {
showError (message) {
this.$message({
type: 'error',
duration: '0',
showClose: true,
dangerouslyUseHTMLString: true,
message: '<p style="line-height:20px;">' + message + '</p>'
})
}
}
}
</script>

<style lang="scss" scoped>
@import '@/styles/index.scss';
$warp-width: 280px;
$warp-height: 300px;
$warp-padding: 20px;
.warp {
width: $warp-width;
height: $warp-height;
margin: $layout-header-h ($layout-width - $warp-width)/2 - $warp-padding $layout-footer-h ($layout-width - $warp-width)/2 - $warp-padding;
padding: $warp-padding;
border: 1px solid $text-color;
border-radius: 4px;
overflow-y: scroll;
cursor: default !important;
.mark-down {
color: white;
}
}
</style>
Loading

0 comments on commit 09a77bd

Please sign in to comment.