Skip to content

Commit

Permalink
Merge branch 'hot-fix-4'
Browse files Browse the repository at this point in the history
  • Loading branch information
CS-Tao committed Oct 5, 2018
2 parents 073bf43 + b6316dd commit 0a3b908
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 82 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -26,13 +26,13 @@
### 稳定版本下载

- Windows
- 链接: [whu-library-seat-setup-1.3.1.exe](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.3.1/whu-library-seat-setup-1.3.1.exe)
- 链接: [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)

- Mac OS
- 链接: [whu-library-seat-1.3.1.dmg](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.3.1/whu-library-seat-1.3.1.dmg)
- 链接: [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)

- Linux
- 链接: [whu-library-seat-1.3.1-x86_64.AppImage](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.3.1/whu-library-seat-1.3.1-x86_64.AppImage)
- 链接: [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)

### 安装软件

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

- Windows
- 链接: [whu-library-seat-setup-1.3.1.exe](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.3.1/whu-library-seat-setup-1.3.1.exe)
- 链接: [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)

- Mac OS
- 链接: [whu-library-seat-1.3.1.dmg](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.3.1/whu-library-seat-1.3.1.dmg)
- 链接: [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)

- Linux
- 链接: [whu-library-seat-1.3.1-x86_64.AppImage](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.3.1/whu-library-seat-1.3.1-x86_64.AppImage)
- 链接: [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)

### 安装软件

Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "whu-library-seat",
"version": "1.3.1",
"version": "1.3.2",
"author": "CS-Tao <whucstao@qq.com>",
"description": "武汉大学图书馆抢座软件",
"license": null,
Expand Down
28 changes: 14 additions & 14 deletions src/renderer/api/mock/index.js
Expand Up @@ -5,43 +5,43 @@ import libraryApi from './library.api'
import urls from '../urls'

// 用户验证
Mock.mock(urls.gitcontents.validateUser.regular, gitcontentsApi.validateUser.method, gitcontentsApi.validateUser)
Mock.mock(urls.gitcontents.validateUser.regular, urls.gitcontents.validateUser.method, gitcontentsApi.validateUser)

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

// 抢座状态
Mock.mock(urls.gitcontents.grabState.regular, usageApi.grabState.method, usageApi.grabState)
Mock.mock(urls.usage.grabState.regular, urls.usage.grabState.method, usageApi.grabState)

// 登录
Mock.mock(urls.library.Login.regular, libraryApi.Login.method, libraryApi.Login)
Mock.mock(urls.library.Login.regular, urls.library.Login.method, libraryApi.Login)

// 得到可以使用的房间信息
Mock.mock(urls.library.FreeFilters.regular, libraryApi.FreeFilters.method, libraryApi.FreeFilters)
Mock.mock(urls.library.FreeFilters.regular, urls.library.FreeFilters.method, libraryApi.FreeFilters)

// 得到房间详细信息
Mock.mock(urls.library.RoomStats.regular, libraryApi.RoomStats.method, libraryApi.RoomStats)
Mock.mock(urls.library.RoomStats.regular, urls.library.RoomStats.method, libraryApi.RoomStats)

// 验证 token 是否可用
Mock.mock(urls.library.ValidateToken.regular, libraryApi.ValidateToken.method, libraryApi.ValidateToken)
Mock.mock(urls.library.ValidateToken.regular, urls.library.ValidateToken.method, libraryApi.ValidateToken)

// 得到位置详细信息
Mock.mock(urls.library.LayoutByDate.regular, libraryApi.LayoutByDate.method, libraryApi.LayoutByDate)
Mock.mock(urls.library.LayoutByDate.regular, urls.library.LayoutByDate.method, libraryApi.LayoutByDate)

// 按时间搜索位置
Mock.mock(urls.library.SearchSeat.regular, libraryApi.SearchSeat.method, libraryApi.SearchSeat)
Mock.mock(urls.library.SearchSeat.regular, urls.library.SearchSeat.method, libraryApi.SearchSeat)

// 预约位置
Mock.mock(urls.library.Book.regular, libraryApi.Book.method, libraryApi.Book)
Mock.mock(urls.library.Book.regular, urls.library.Book.method, libraryApi.Book)

// 取消预约
Mock.mock(urls.library.Cancel.regular, libraryApi.Cancel.method, libraryApi.Cancel)
Mock.mock(urls.library.Cancel.regular, urls.library.Cancel.method, libraryApi.Cancel)

// 得到用户信息
Mock.mock(urls.library.User.regular, libraryApi.User.method, libraryApi.User)
Mock.mock(urls.library.User.regular, urls.library.User.method, libraryApi.User)

// 得到预约历史
Mock.mock(urls.library.History.regular, libraryApi.History.method, libraryApi.History)
Mock.mock(urls.library.History.regular, urls.library.History.method, libraryApi.History)

// 终止使用
Mock.mock(urls.library.Stop.regular, libraryApi.Stop.method, libraryApi.Stop)
Mock.mock(urls.library.Stop.regular, urls.library.Stop.method, libraryApi.Stop)
106 changes: 47 additions & 59 deletions src/renderer/components/Body/index.vue
Expand Up @@ -377,73 +377,61 @@ export default {
usageApi.grabState(this.userAccount, true, 6)
} else {
if (response.data.code === 1 || response.data.code === '1') {
// 预约失败,请尽快选择其他时段或座位
// 系统可预约时间为 22:45 ~ 23:50
if (response.data.message === '预约失败,请尽快选择其他时段或座位' || response.data.message === '参数错误' || response.data.message === '已有1个有效预约,请在使用结束后再次进行选择') {
// 位置不可用,如果未达抢座上限则继续抢
this.grabCount += 1
var cancelCurrentBool = response.data.message === '已有1个有效预约,请在使用结束后再次进行选择' && this.grabCount < 2
var newSeatId = -1
if (cancelCurrentBool) {
newSeatId = seatNum
} else {
newSeatId = this.getNewSeatNum()
}
if (this.grabCount >= maxGrabCount) {
this.$store.dispatch('updateTimer', 'fail')
this.$message({
type: 'error',
duration: 0,
showClose: true,
message: `抢座失败:达到抢座尝试上限(${maxGrabCount}),结束抢座`
})
this.windowsNotification('抢座失败', `达到抢座尝试上限(${maxGrabCount}),结束抢座`)
usageApi.grabState(this.userAccount, false, 7, '抢座失败', `达到抢座尝试上限(${maxGrabCount}),结束抢座`)
} else if (newSeatId === -1) {
this.$store.dispatch('updateTimer', 'fail')
this.$message({
type: 'error',
duration: 0,
showClose: true,
message: '抢座失败:该房间在指定的时间段内没有空闲位置'
})
this.windowsNotification('抢座失败', '该房间在指定的时间段内没有空闲位置')
usageApi.grabState(this.userAccount, false, 8, '抢座失败:该房间在指定的时间段内没有空闲位置')
} else if (!this.stopGrab) {
this.$store.dispatch('updateTimer', 'working')
// 打印信息
var seatInTheRoom = this.seatsSearched === null ? this.seats.filter((item) => {
return item.type !== 'empty'
}) : this.seatsSearched
for (let index = 0; index < seatInTheRoom.length; index++) {
if (seatInTheRoom[index].id === newSeatId) {
// console.log('第' + (this.grabCount + 1) + '次尝试抢座(座位号: ' + seatInTheRoom[index].name + ', Id: ' + newSeatId + ')')
this.$store.dispatch('updateTimer', '尝试 ' + seatInTheRoom[index].name)
break
}
}
// 结束打印
// 开始下一次抢座
if (!this.isVip) {
this.sleep(200)
}
if (this.grabCount === arbitraryGrabCount) {
this.searchSeatsByTime(this.form.library, this.form.room, date, beginTime, endTime, userToken)
}
this.reserveSeat(beginTime, endTime, newSeatId, date, userToken, cancelCurrentBool)
} else {}
// 位置不可用,如果未达抢座上限则继续抢
this.grabCount += 1
var cancelCurrentBool = response.data.message === '已有1个有效预约,请在使用结束后再次进行选择' && this.grabCount < 2
var newSeatId = -1
if (cancelCurrentBool) {
newSeatId = seatNum
} else {
newSeatId = this.getNewSeatNum()
}
if (this.grabCount >= maxGrabCount) {
this.$store.dispatch('updateTimer', 'fail')
this.$message({
type: 'error',
duration: 0,
showClose: true,
message: `抢座失败:达到抢座尝试上限(${maxGrabCount}),结束抢座`
})
this.windowsNotification('抢座失败', `达到抢座尝试上限(${maxGrabCount}),结束抢座`)
usageApi.grabState(this.userAccount, false, 7, '抢座失败', `达到抢座尝试上限(${maxGrabCount}),结束抢座`)
} else if (newSeatId === -1) {
this.$store.dispatch('updateTimer', 'fail')
this.$message({
type: 'error',
duration: 0,
showClose: true,
message: response.data.message ? response.data.message : emptyMessage
message: '抢座失败:该房间在指定的时间段内没有空闲位置(请确保您要预约的时间无误)'
})
this.windowsNotification('抢座失败', response.data.message ? response.data.message : emptyMessage)
usageApi.grabState(this.userAccount, false, 9, response.data.message)
this.windowsNotification('抢座失败', '该房间在指定的时间段内没有空闲位置(请确保您要预约的时间无误)')
usageApi.grabState(this.userAccount, false, 8, '抢座失败:该房间在指定的时间段内没有空闲位置(请确保您要预约的时间无误)')
} else if (!this.stopGrab) {
this.$store.dispatch('updateTimer', 'working')
// 打印信息
var seatInTheRoom = this.seatsSearched === null ? this.seats.filter((item) => {
return item.type !== 'empty'
}) : this.seatsSearched
for (let index = 0; index < seatInTheRoom.length; index++) {
if (seatInTheRoom[index].id === newSeatId) {
// console.log('第' + (this.grabCount + 1) + '次尝试抢座(座位号: ' + seatInTheRoom[index].name + ', Id: ' + newSeatId + ')')
this.$store.dispatch('updateTimer', '尝试 ' + seatInTheRoom[index].name)
break
}
}
// 结束打印
// 开始下一次抢座
if (!this.isVip) {
this.sleep(200)
}
if (this.grabCount === arbitraryGrabCount) {
this.searchSeatsByTime(this.form.library, this.form.room, date, beginTime, endTime, userToken)
}
this.reserveSeat(beginTime, endTime, newSeatId, date, userToken, cancelCurrentBool)
} else {
// 外部终止抢座,即 this.stopGrab === true
}
} else if (response.data.code === 12 && response.data.code === '12') {
} else if (response.data.code === 12 || response.data.code === '12') {
// 登录失败: 用户名或密码不正确
this.$store.dispatch('updateTimer', 'fail')
this.$message({
Expand Down
8 changes: 6 additions & 2 deletions src/renderer/store/modules/app.js
Expand Up @@ -246,20 +246,24 @@ const app = {
if (timerInfo.totalTime < 0) {
timerInfo.totalTime = 0
timerInfo.timerId = setTimeout(() => {
let oppointmentTimeMilli = param.time.getTime()
while (oppointmentTimeMilli - (new Date()).getTime() > 0) {}
param.bookFunc()
// param.loginAndBookFunc()
}, timerInfo.totalTime)
} else if (timerInfo.totalTime > 5000) {
timerInfo.loginTimerId = setTimeout(() => {
param.loginFunc()
}, timerInfo.totalTime - 5000)
timerInfo.timerId = setTimeout(() => {
let oppointmentTimeMilli = param.time.getTime()
while (oppointmentTimeMilli - (new Date()).getTime() > 0) {}
param.bookFunc()
}, timerInfo.totalTime)
} else {
timerInfo.timerId = setTimeout(() => {
let oppointmentTimeMilli = param.time.getTime()
while (oppointmentTimeMilli - (new Date()).getTime() > 0) {}
param.bookFunc()
// param.loginAndBookFunc()
}, timerInfo.totalTime)
}
timerInfo.intervalId = setInterval(() => {
Expand Down
1 change: 1 addition & 0 deletions src/renderer/styles/element-ui.scss
Expand Up @@ -156,6 +156,7 @@
.el-message__content {
color: $heart-color!important;
height: 20px;
line-height: 1.5;
}
}

Expand Down

0 comments on commit 0a3b908

Please sign in to comment.