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 Feb 21, 2019
2 parents d67f681 + 260c001 commit f51ea8b
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 26 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@
### 最新版本下载

- Windows
- 链接: [whu-library-seat-setup-1.8.0.exe](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.8.0/whu-library-seat-setup-1.8.0.exe)
- 链接: [whu-library-seat-setup-1.8.1.exe](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.8.1/whu-library-seat-setup-1.8.1.exe)
- 备用地址: [whu-library-seat-setup-1.8.1.exe](https://assets.cs-tao.cc/whu-library-seat/releases/v1.8.1/whu-library-seat-setup-1.8.1.exe)

- Mac OS
- 链接: [whu-library-seat-1.8.0.dmg](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.8.0/whu-library-seat-1.8.0.dmg)
- 链接: [whu-library-seat-1.8.1.dmg](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.8.1/whu-library-seat-1.8.1.dmg)
- 备用地址: [whu-library-seat-1.8.1.dmg](https://assets.cs-tao.cc/whu-library-seat/releases/v1.8.1/whu-library-seat-1.8.1.dmg)

- Linux
- 链接: [whu-library-seat-1.8.0-x86_64.AppImage](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.8.0/whu-library-seat-1.8.0-x86_64.AppImage)
- 链接: [whu-library-seat-1.8.1-x86_64.AppImage](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.8.1/whu-library-seat-1.8.1-x86_64.AppImage)
- 备用地址: [whu-library-seat-1.8.1-x86_64.AppImage](https://assets.cs-tao.cc/whu-library-seat/releases/v1.8.1/whu-library-seat-1.8.1-x86_64.AppImage)

### 安装软件

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "whu-library-seat",
"version": "1.8.0",
"version": "1.8.1",
"author": "CS-Tao <[email protected]>",
"description": "武汉大学图书馆抢座软件",
"license": null,
Expand Down
4 changes: 3 additions & 1 deletion src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ const template = [
if (mainWindow) {
mainWindow.reload()
}
}}
}
}
]
}, {
label: '视图',
Expand Down Expand Up @@ -231,6 +232,7 @@ function createWindow () {
details.requestHeaders['Accept-Language'] = null
details.requestHeaders['Referer'] = null
details.requestHeaders['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'
details.requestHeaders['Origin'] = null
}
callback({ cancel: false, requestHeaders: details.requestHeaders }) // eslint-disable-line
})
Expand Down
46 changes: 37 additions & 9 deletions src/renderer/api/library.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,43 @@ export default {
},
// 预约位置
// t=1&startTime=1290&endTime=1350&seat=5728&date=2018-07-23&t2=2
Book: (t, t2, startTime, endTime, seat, date, token) => {
return request({
url: urls.library.Book.url(),
method: urls.library.Book.method,
headers: {
token
},
data: `t=${t}&startTime=${startTime}&endTime=${endTime}&seat=${seat}&date=${date}&t2=${t2}`
})
Book: async (t, t2, startTime, endTime, seat, date, account, passwd, updateToken, errorCallback) => {
try {
const responseData = await new Promise((resolve, reject) => {
request({
url: urls.library.Login.url(),
method: urls.library.Login.method,
params: {
username: account,
password: passwd
}
})
.then((response) => {
return resolve(response)
})
.catch((error) => {
return reject(error)
})
})
if (responseData.data.status === 'success' && responseData.data.data.token) {
updateToken(responseData.data.data.token)
return request({
url: urls.library.Book.url(),
method: urls.library.Book.method,
headers: {
token: responseData.data.data.token
},
data: `t=${t}&startTime=${startTime}&endTime=${endTime}&seat=${seat}&date=${date}&t2=${t2}`
})
} else {
const message = '网络拥堵,请重新预约'
errorCallback(message)
return Promise.reject(Error(message))
}
} catch (error) {
errorCallback(error.message)
return Promise.reject(error)
}
},
// 取消预约
Cancel: (id, token) => {
Expand Down
34 changes: 22 additions & 12 deletions src/renderer/components/Body/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ import usageApi from '@/api/usage.api'
import { ipcRenderer } from 'electron'
const emptyMessage = '数据加载失败'
const maxGrabCount = 10
const arbitraryGrabCount = 4
const maxGrabCount = 8
const arbitraryGrabCount = 3
export default {
props: {
Expand Down Expand Up @@ -270,6 +270,13 @@ export default {
message
})
},
showError (message) {
this.$message({
type: 'error',
duration: '3000',
message
})
},
getRoomDetail (roomId) {
for (let i = 0; i < this.roomsDetial.length; i++) {
if (this.roomsDetial[i].roomId === roomId) {
Expand Down Expand Up @@ -489,10 +496,10 @@ export default {
} else {
usageApi.grabState(this.userAccount, false, 13, `取消当前预约失败:${response.data.message}`)
}
this.reserveSeat(beginTime, endTime, seatNum, date, userToken)
this.reserveSeat(beginTime, endTime, seatNum, date, this.userToken)
}).catch((error) => {
usageApi.grabState(this.userAccount, false, 14, `取消当前预约出现异常:${error.message}`)
this.reserveSeat(beginTime, endTime, seatNum, date, userToken)
this.reserveSeat(beginTime, endTime, seatNum, date, this.userToken)
})
} else {
// 终止当前使用
Expand All @@ -506,28 +513,28 @@ export default {
} else {
usageApi.grabState(this.userAccount, false, 15, `终止当前使用失败:${response.data.message}`)
}
this.reserveSeat(beginTime, endTime, seatNum, date, userToken)
this.reserveSeat(beginTime, endTime, seatNum, date, this.userToken)
}).catch((error) => {
usageApi.grabState(this.userAccount, false, 16, `终止当前使用异常:${error.message}`)
this.reserveSeat(beginTime, endTime, seatNum, date, userToken)
this.reserveSeat(beginTime, endTime, seatNum, date, this.userToken)
})
}
} else {
usageApi.grabState(this.userAccount, false, 17, '准备取消预约,但当前无预约或正在使用的座位')
this.reserveSeat(beginTime, endTime, seatNum, date, userToken)
this.reserveSeat(beginTime, endTime, seatNum, date, this.userToken)
}
} else {
usageApi.grabState(this.userAccount, false, 18, `获取预约历史失败:${response.data.message}`)
this.reserveSeat(beginTime, endTime, seatNum, date, userToken)
this.reserveSeat(beginTime, endTime, seatNum, date, this.userToken)
}
}).catch((error) => {
usageApi.grabState(this.userAccount, false, 19, `获取预约历史出现异常:${error.message}`)
this.reserveSeat(beginTime, endTime, seatNum, date, userToken)
this.reserveSeat(beginTime, endTime, seatNum, date, this.userToken)
})
return
}
if (!this.triedSeatIds.includes(seatNum)) { this.triedSeatIds.push(seatNum) }
libraryRestApi.Book(1, 2, beginTime, endTime, seatNum, date, userToken).then((response) => {
libraryRestApi.Book(1, 2, beginTime, endTime, seatNum, date, this.userAccount, this.userPasswd, this.updateToken, this.showError).then((response) => {
if (response.data.status === 'success') {
this.$store.dispatch('updateTimer', 'success')
this.$notify({
Expand Down Expand Up @@ -601,9 +608,9 @@ export default {
this.sleep(120)
}
if (this.grabCount === arbitraryGrabCount) {
this.searchSeatsByTime(this.form.library, this.form.room, date, beginTime, endTime, userToken)
this.searchSeatsByTime(this.form.library, this.form.room, date, beginTime, endTime, this.userToken)
}
this.reserveSeat(beginTime, endTime, newSeatId, date, userToken, cancelCurrentBool)
this.reserveSeat(beginTime, endTime, newSeatId, date, this.userToken, cancelCurrentBool)
} else {
// 外部终止抢座,即 this.stopGrab === true
}
Expand Down Expand Up @@ -778,6 +785,9 @@ export default {
}
return str
},
updateToken (token) {
this.$store.dispatch('setToken', token)
},
formatDate (date, options) {
options = options || {}
options.sign = options.sign || 'yyyy-MM-dd'
Expand Down
10 changes: 10 additions & 0 deletions src/renderer/components/Header/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ export default {
return this.userInfo.account === 2017302590175
}
},
watch: {
authFormVisible () {
if (this.authFormVisible) {
this.settingsVisible = false
}
}
},
mounted () {
this.userInfo.account = this.userAccount
this.userInfo.passwd = this.userPasswd
Expand All @@ -147,6 +154,9 @@ export default {
methods: {
openSettings () {
this.settingsVisible = !this.settingsVisible
if (this.settingsVisible) {
this.$store.commit('TRIGGER_AUTH_FORM', false)
}
},
showInfo (message) {
this.$message({
Expand Down

0 comments on commit f51ea8b

Please sign in to comment.