diff --git a/README.md b/README.md index 009ccf8e..2ff40359 100644 --- a/README.md +++ b/README.md @@ -24,13 +24,13 @@ ### 最新版本下载 - Windows - - 链接: [whu-library-seat-setup-1.5.0.exe](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.5.0/whu-library-seat-setup-1.5.0.exe) + - 链接: [whu-library-seat-setup-1.6.0.exe](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.6.0/whu-library-seat-setup-1.6.0.exe) - Mac OS - - 链接: [whu-library-seat-1.5.0.dmg](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.5.0/whu-library-seat-1.5.0.dmg) + - 链接: [whu-library-seat-1.6.0.dmg](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.6.0/whu-library-seat-1.6.0.dmg) - Linux - - 链接: [whu-library-seat-1.5.0-x86_64.AppImage](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.5.0/whu-library-seat-1.5.0-x86_64.AppImage) + - 链接: [whu-library-seat-1.6.0-x86_64.AppImage](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.6.0/whu-library-seat-1.6.0-x86_64.AppImage) ### 安装软件 @@ -38,6 +38,8 @@ ### 申请软件使用权 +> 不再对桌面版本低于 v1.5.0、安卓版本低于 v1.2.0 的软件提供用户认证支持 + 在您登录之前,软件会检查您的学号是否被记录在[这个文件](https://github.com/CS-Tao/whu-library-seat/blob/user-validation/validation.json)中,只有被记录在这个文件中的学号(经过加密)才能使用本软件,如果您的学号(经过加密)没有被记录,您可以通过邮件[联系我](http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=whucstao@qq.com)(请在邮件中注明学号、院系和姓名) 当然,因为本软件为开源软件,您可以在遵守本软件[版权声明](#版权声明)的前提下,自己构建软件并删除其中的认证代码,具体请查看[面向开发者](#面向开发者) diff --git a/docs/specification/README.md b/docs/specification/README.md index cd18f3ac..8e061d6d 100644 --- a/docs/specification/README.md +++ b/docs/specification/README.md @@ -5,13 +5,13 @@ #### 桌面端下载 - Windows - - 链接: [whu-library-seat-setup-1.5.0.exe](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.5.0/whu-library-seat-setup-1.5.0.exe) + - 链接: [whu-library-seat-setup-1.6.0.exe](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.6.0/whu-library-seat-setup-1.6.0.exe) - Mac OS - - 链接: [whu-library-seat-1.5.0.dmg](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.5.0/whu-library-seat-1.5.0.dmg) + - 链接: [whu-library-seat-1.6.0.dmg](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.6.0/whu-library-seat-1.6.0.dmg) - Linux - - 链接: [whu-library-seat-1.5.0-x86_64.AppImage](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.5.0/whu-library-seat-1.5.0-x86_64.AppImage) + - 链接: [whu-library-seat-1.6.0-x86_64.AppImage](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.6.0/whu-library-seat-1.6.0-x86_64.AppImage) #### 移动端下载 diff --git a/docs/specification/reservation.md b/docs/specification/reservation.md index 92e3c30b..30f028f6 100644 --- a/docs/specification/reservation.md +++ b/docs/specification/reservation.md @@ -4,9 +4,7 @@ ### 选择座位 -在主界面中选择日期、时间、场馆、房间、位置等参数,选中电源图标或太阳图标可以对座位进行预筛选(当您选择的座位已经被别人预约时,经过预筛选的座位会被优先选择) - -您选择的除了日期之外的所有参数都会被保存到配置文件中,以便下次读取 +在主界面中选择日期、时间、场馆、房间、位置等参数,选中电源图标或太阳图标可以对座位进行预筛选(当您选择的座位已经被别人预约时,经过预筛选的座位会被优先选择),在座位号的下拉列表中,座位号为红色表示当前座位处于不可用的状态 ### 定时抢座 diff --git a/package.json b/package.json index a45b4c67..d47bf08d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "whu-library-seat", - "version": "1.5.0", + "version": "1.6.0", "author": "CS-Tao ", "description": "武汉大学图书馆抢座软件", "license": null, diff --git a/src/main/index.js b/src/main/index.js index b0234c6e..7a4e7e6f 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -1,7 +1,7 @@ 'use strict' import { autoUpdater } from 'electron-updater' -import { app, BrowserWindow, Menu, Tray, ipcMain, screen } from 'electron' +import { app, BrowserWindow, Menu, Tray, ipcMain, screen, session } from 'electron' import path from 'path' import Store from 'electron-store' import notifier from 'node-notifier' @@ -221,6 +221,16 @@ function createWindow () { mainWindow.setPosition(position[0], position[1] === -1 ? mainWindow.getPosition()[1] : position[1]) } + session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => { + details.requestHeaders['User-Agent'] = null + details.requestHeaders['Accept'] = null + details.requestHeaders['Accept-Encoding'] = null + details.requestHeaders['Accept-Language'] = null + details.requestHeaders['Referer'] = null + details.requestHeaders['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8' + callback({ cancel: false, requestHeaders: details.requestHeaders }) // eslint-disable-line + }) + mainWindow.loadURL(winURL) mainWindow.onbeforeunload = (e) => { diff --git a/src/renderer/api/library.api.js b/src/renderer/api/library.api.js index 4634f48b..dcd8ec3a 100644 --- a/src/renderer/api/library.api.js +++ b/src/renderer/api/library.api.js @@ -1,5 +1,6 @@ import request from './config' import urls from './urls' +import Mock from 'mockjs' export default { // 登录 @@ -7,6 +8,9 @@ export default { return request({ url: urls.library.Login.url(), method: urls.library.Login.method, + headers: { + token: Mock.mock(/[A-Z\d]{18}/) + }, params: { username: account, password: passwd diff --git a/src/renderer/components/Body/index.vue b/src/renderer/components/Body/index.vue index 49eab282..f1a64103 100644 --- a/src/renderer/components/Body/index.vue +++ b/src/renderer/components/Body/index.vue @@ -3,16 +3,16 @@
- + 今天  {{freeDates[0]}} 明天  {{freeDates[1]}} - + - + @@ -26,15 +26,16 @@ {{ room[1] }} {{ room[3] }} F - {{ getRoomDetail(room[0]).free }} 座可用 + {{ getRoomDetail(room[0]).free }} 座空闲 - {{ seatsForSelect[n-1].name }} + {{ seatsForSelect[n-1].name }} + @@ -97,6 +98,7 @@ export default { singleLibRooms: [], seats: [], seatsForSelect: [], + seatsForSelectIsAvailable: null, seatsSearched: null, reserveTime: null, checkReserveTime: false, @@ -134,6 +136,11 @@ export default { return this.userAccount === 2015302590039 || this.userAccount === 2017302590175 } }, + watch: { + seats () { + this.updateSeatsStatus() + } + }, mounted () { this.form = {...this.seatInfo} this.form.date = this.freeDates.length > 0 ? this.freeDates[0] : null @@ -159,9 +166,9 @@ export default { this.singleLibRooms.sort((x, y) => { return parseInt(x[3]) - parseInt(y[3]) }) - libraryRestApi.RoomStats(this.form.library, this.userToken).then((reponse) => { - if (reponse.data.status === 'success') { - this.roomsDetial = reponse.data.data + libraryRestApi.RoomStats(this.form.library, this.userToken).then((response) => { + if (response.data.status === 'success') { + this.roomsDetial = response.data.data } }).catch(() => {}) this.form.room = null @@ -169,9 +176,9 @@ export default { }, roomChanged () { if (this.form.room === null || this.form.date === null) { return } + this.seats = [] libraryRestApi.LayoutByDate(this.form.room, this.form.date, this.userToken).then((response) => { if (response.data.status === 'success') { - this.seats = [] for (var key in response.data.data.layout) { this.seats.push(response.data.data.layout[key]) } @@ -389,7 +396,7 @@ export default { } else { if (response.data.code === 1 || response.data.code === '1') { // 位置不可用,如果未达抢座上限则继续抢 - usageApi.grabState(this.userAccount, false, 12, `位置不可用,如果未达抢座上限则继续抢(${this.grabCount}/${maxGrabCount}):${response.data.message}`) + usageApi.grabState(this.userAccount, false, 12, `位置不可用,如果未达抢座上限则继续抢(${seatNum}:${this.grabCount}/${maxGrabCount}):${response.data.message}`) this.grabCount += 1 var cancelCurrentBool = response.data.message === '已有1个有效预约,请在使用结束后再次进行选择' && this.grabCount < 2 var newSeatId = -1 @@ -434,7 +441,9 @@ export default { // 结束打印 // 开始下一次抢座 if (!this.isVip) { - this.sleep(100) + this.sleep(200) + } else { + this.sleep(120) } if (this.grabCount === arbitraryGrabCount) { this.searchSeatsByTime(this.form.library, this.form.room, date, beginTime, endTime, userToken) @@ -468,6 +477,7 @@ export default { } } }).catch((error) => { + this.$store.dispatch('updateTimer', 'fail') usageApi.grabState(this.userAccount, false, 20, `预约出现异常:${error.message}`) }) }, @@ -546,6 +556,48 @@ export default { }).catch(() => { this.seatsSearched = null }) + }, + updateSeatsStatus () { + this.seatsForSelectIsAvailable = null + if (this.form.library === null || + this.form.room === null || + this.form.date === null || + this.form.beginTime === null || + this.form.endTime === null) { + return + } + libraryRestApi.SearchSeat( + this.form.library, + this.form.room, + this.form.date, + this.form.beginTime, + this.form.endTime, + this.userToken).then((response) => { + if (response.data.status) { + this.seatsForSelectIsAvailable = [] + if (response.data.data.seats) { + for (var key in response.data.data.seats) { + if (response.data.data.seats[key].status === 'FREE') { + this.seatsForSelectIsAvailable.push(response.data.data.seats[key].id) + } + } + } + } else { + this.seatsForSelectIsAvailable = null + } + }).catch(() => { + this.seatsForSelectIsAvailable = null + }) + }, + getSeatColor (seatId) { + if (this.seatsForSelectIsAvailable === null) { + // 数据未获取 + return null + } else if (this.seatsForSelectIsAvailable.length === 0 || !this.seatsForSelectIsAvailable.includes(seatId)) { + return 'red' + } else { + return 'rgb(0, 204, 0)' + } } } } @@ -564,7 +616,7 @@ export default { margin: 0 3px; } .num { - width: 120px; + width: 130px; flex: 1; float: left; margin: 0 5px; @@ -647,10 +699,10 @@ export default { .seat-option-right { float: right; .seat-flag { - cursor: default; + cursor: pointer; margin: 0 0 0 5px; fill: $text-color-lowlight; - width: $text-size-small; + width: $text-size-small + 1; } .seat-flag-power { fill: $button-green; @@ -658,5 +710,8 @@ export default { .seat-flag-window { fill: $button-yellow; } + .seat-flag-computer { + fill: $button-blue; + } } diff --git a/src/renderer/store/modules/Counter.js b/src/renderer/store/modules/Counter.js deleted file mode 100644 index 44a8ab4c..00000000 --- a/src/renderer/store/modules/Counter.js +++ /dev/null @@ -1,25 +0,0 @@ -const state = { - main: 0 -} - -const mutations = { - DECREMENT_MAIN_COUNTER (state) { - state.main-- - }, - INCREMENT_MAIN_COUNTER (state) { - state.main++ - } -} - -const actions = { - someAsyncTask ({ commit }) { - // do something async - commit('INCREMENT_MAIN_COUNTER') - } -} - -export default { - state, - mutations, - actions -}