diff --git a/README.md b/README.md index 82c06bd0..ff4f7fae 100644 --- a/README.md +++ b/README.md @@ -24,16 +24,16 @@ ### 最新版本下载 - Windows - - 链接: [whu-library-seat-setup-1.8.4.exe](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.8.4/whu-library-seat-setup-1.8.4.exe) - - 备用地址: [whu-library-seat-setup-1.8.4.exe](https://assets.cs-tao.cc/whu-library-seat/releases/v1.8.4/whu-library-seat-setup-1.8.4.exe) + - 链接: [whu-library-seat-setup-1.9.0.exe](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.9.0/whu-library-seat-setup-1.9.0.exe) + - 备用地址: [whu-library-seat-setup-1.9.0.exe](https://assets.cs-tao.cc/whu-library-seat/releases/v1.9.0/whu-library-seat-setup-1.9.0.exe) - Mac OS - - 链接: [whu-library-seat-1.8.4.dmg](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.8.4/whu-library-seat-1.8.4.dmg) - - 备用地址: [whu-library-seat-1.8.4.dmg](https://assets.cs-tao.cc/whu-library-seat/releases/v1.8.4/whu-library-seat-1.8.4.dmg) + - 链接: [whu-library-seat-1.9.0.dmg](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.9.0/whu-library-seat-1.9.0.dmg) + - 备用地址: [whu-library-seat-1.9.0.dmg](https://assets.cs-tao.cc/whu-library-seat/releases/v1.9.0/whu-library-seat-1.9.0.dmg) - Linux - - 链接: [whu-library-seat-1.8.4-x86_64.AppImage](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.8.4/whu-library-seat-1.8.4-x86_64.AppImage) - - 备用地址: [whu-library-seat-1.8.4-x86_64.AppImage](https://assets.cs-tao.cc/whu-library-seat/releases/v1.8.4/whu-library-seat-1.8.4-x86_64.AppImage) + - 链接: [whu-library-seat-1.9.0-x86_64.AppImage](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.9.0/whu-library-seat-1.9.0-x86_64.AppImage) + - 备用地址: [whu-library-seat-1.9.0-x86_64.AppImage](https://assets.cs-tao.cc/whu-library-seat/releases/v1.9.0/whu-library-seat-1.9.0-x86_64.AppImage) ### 安装软件 diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index d9ee8ae7..97da6e3e 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -50,9 +50,9 @@ module.exports = { ['menu', '菜单'], ['settings', '软件设置'], ['reservation', '定时预约'], - ['cancel', '取消预约'], - ['stop', '结束使用'], - ['change', '更改位置'], + ['monitor', '座位监控'], + ['protect', '座位保护'], + ['seatoperate', '位置操作'], ['others', '其他'] ] } diff --git a/docs/README.md b/docs/README.md index cbc0ebc8..c67d7d1d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -8,12 +8,12 @@ features: details: 软件提供了定时抢座的功能,用户可以指定时间开始抢座,也可以通过勾选"√使用当前时间"立即抢座 - title: 错误处理 details: 当位置已经被别人预约之后,软件会根据用户提供的时间段和房间信息,自动预约距离该位置较近的座位 +- title: 座位监控 + details: 在"位置"的下拉框选择"监控"功能,可以监控指定房间的座位信息,当有座位可用时,软件会第一时间为您预约 - title: 座位更改 details: 勾选"√使用当前时间"立即抢座,如果当前已有预约、正在使用、暂离状态的座位,软件会取消当前座位,重新预约 -- title: 取消预约 - details: 在预约历史界面,如果您有处于预约的座位,可以点击对应记录后面的取消预约按钮取消座位 -- title: 终止使用 - details: 在预约历史界面,如果您有处于正在使用或暂离状态的座位,可以点击对应记录后面的终止使用的按钮结束使用该座位 +- title: 座位保护 + details: 出馆前可设置一段时间后更改此座位的时间,即通过定时执行"座位更改"功能实现座位保护 - title: 开源跨平台 details: 本软件为开源跨平台软件,有 WIndows、MacOS、Linux、Android 等版本可供用户下载使用 footer: Copyright © 2018 CS-Tao diff --git a/docs/specification/README.md b/docs/specification/README.md index 8ab37dd0..4532e801 100644 --- a/docs/specification/README.md +++ b/docs/specification/README.md @@ -1,12 +1,12 @@ -### 下载软件 +## 下载软件 本软件是针对`武汉大学`图书馆预约系统开发的抢座软件,支持 Windows、Mac OS、Linux、Android 等操作系统 -#### 桌面端下载 +### 桌面端下载 安装包链接: [https://github.com/CS-Tao/whu-library-seat#最新版本下载](https://github.com/CS-Tao/whu-library-seat#最新版本下载) -#### 移动端(Android)下载 +### 移动端(Android)下载 安装包链接: [https://github.com/CS-Tao/whu-library-seat-mobile#最新版本下载](https://github.com/CS-Tao/whu-library-seat-mobile#最新版本下载) @@ -14,16 +14,16 @@ ![安卓版本二维码](https://raw.githubusercontent.com/CS-Tao/whu-library-seat/user-validation/last-android-qr.jpg) -### 安装软件 +## 安装软件 运行安装包即可 -### 申请软件使用权 +## 申请软件使用权 > v1.8.0 已移除本功能,改为 GitHub Star 认证,具体请查看 [GitHub Star 认证](./auth.html) -### 软件更新 +## 软件更新 ![图片加载失败](https://home.cs-tao.cc/github-content/contents/github/whu-library-seat/update.png) diff --git a/docs/specification/auth.md b/docs/specification/auth.md index 75acb127..73f8f2f6 100644 --- a/docs/specification/auth.md +++ b/docs/specification/auth.md @@ -1,14 +1,16 @@ # GitHub Star 认证 -> 无法连接服务器请移步[手动申请 Token](manualtoken.html) - 请按照以下步骤登录本软件并获取永久授权 1. 点击软件下方的**钥匙**进入软件授权页面(第一次打开软件会默认进入本页面) ![图片加载失败](https://home.cs-tao.cc/github-content/contents/github/whu-library-seat/OAuth/1.png) -1. 点击`GitHub Star 永久授权`按钮,软件会打开系统浏览器访问认证页面,如果出现无法连接服务器的弹窗,请移步[手动申请 Token](manualtoken.html)进行认证 +1. 点击`GitHub Star 永久授权`按钮,软件会打开系统浏览器访问认证页面 + + ::: warning 友情提示 + 如果出现`无法连接服务器`的弹窗,请移步[手动申请 Token](manualtoken.html)进行认证 + ::: ![图片加载失败](https://home.cs-tao.cc/github-content/contents/github/whu-library-seat/OAuth/3.png) diff --git a/docs/specification/cancel.md b/docs/specification/cancel.md deleted file mode 100644 index eee49022..00000000 --- a/docs/specification/cancel.md +++ /dev/null @@ -1,3 +0,0 @@ -### 取消预约 - -在`预约历史`界面,如果您有处于`预约`状态的座位,可以点击对应记录后面的`取消预约`的按钮取消预约 diff --git a/docs/specification/change.md b/docs/specification/change.md deleted file mode 100644 index 859c5580..00000000 --- a/docs/specification/change.md +++ /dev/null @@ -1,5 +0,0 @@ -### 座位更改(即"改签") - -在预约座位时,如果您当前已有处于`预约`、`正在使用`、`暂离`状态的座位,在开始预约之前软件会自动取消已有的座位,重新预约 - -也就是说如果您希望的重新预约的座位和正在使用的座位信息一致,便能更改当前座位的使用时间 diff --git a/docs/specification/monitor.md b/docs/specification/monitor.md new file mode 100644 index 00000000..e094aaed --- /dev/null +++ b/docs/specification/monitor.md @@ -0,0 +1,15 @@ +### 座位监控 + +#### 功能说明 + +本功能用于监控房间座位,并第一时间预约,不需要手动检查位置是否可用,让学习更加便捷。 + +::: warning 友情提示 +但本功能会加重后台程序负担,也会给座位改签的同学带来困扰 + +非万不得已不建议使用 +::: + +#### 操作方法 + +登录软件后,在`位置`下拉框的`可选功能`中选择`监控`功能,点击`打开监控器`按钮,设置`监控间隔`和`监控时长`,点击`启动`即可 diff --git a/docs/specification/protect.md b/docs/specification/protect.md new file mode 100644 index 00000000..1cdf347b --- /dev/null +++ b/docs/specification/protect.md @@ -0,0 +1,5 @@ +### 座位保护 + +出馆前可设置一段时间后更改此座位的时间,即通过定时执行"座位更改"功能实现座位保护 + +比如`11.40`出馆,可在出馆前打开软件设置`12.39`重新预约本位置(注意日期、时间以及座位信息不要设置错) diff --git a/docs/specification/reservation.md b/docs/specification/reservation.md index 30f028f6..32a7cca0 100644 --- a/docs/specification/reservation.md +++ b/docs/specification/reservation.md @@ -1,12 +1,12 @@ -### 登录到图书馆 +## 登录到图书馆 启动软件,输入用户名和密码(点击输入框旁边的小锁图标可以保存用户名或密码),点击`登录`按钮登录到图书馆 -### 选择座位 +## 选择座位 在主界面中选择日期、时间、场馆、房间、位置等参数,选中电源图标或太阳图标可以对座位进行预筛选(当您选择的座位已经被别人预约时,经过预筛选的座位会被优先选择),在座位号的下拉列表中,座位号为红色表示当前座位处于不可用的状态 -### 定时抢座 +## 定时抢座 选择好座位之后,点击`定时预约`按钮可以打开`定时器`界面 @@ -16,6 +16,6 @@ 如果选择的时间小于当前时间,启动定时器时会直接开始抢座 ::: -### 取消定时器 +## 取消定时器 定时器启动后,点击`取消定时`按钮可以取消定时器 diff --git a/docs/specification/seatoperate.md b/docs/specification/seatoperate.md new file mode 100644 index 00000000..5e559166 --- /dev/null +++ b/docs/specification/seatoperate.md @@ -0,0 +1,13 @@ +## 取消预约 + +在`预约历史`界面,如果您有处于`预约`状态的座位,可以点击对应记录后面的`取消预约`的按钮取消预约 + +## 结束使用 + +在`预约历史`界面,如果您有处于`正在使用`或`暂离`状态的座位,可以点击对应记录后面的`终止使用`的按钮结束使用该座位 + +## 座位更改(即"改签") + +在预约座位时,如果您当前已有处于`预约`、`正在使用`、`暂离`状态的座位,在开始预约之前软件会自动取消已有的座位,重新预约 + +也就是说如果您希望的重新预约的座位和正在使用的座位信息一致,便能更改当前座位的使用时间 diff --git a/docs/specification/stop.md b/docs/specification/stop.md deleted file mode 100644 index 51e2eade..00000000 --- a/docs/specification/stop.md +++ /dev/null @@ -1,3 +0,0 @@ -### 结束使用 - -在`预约历史`界面,如果您有处于`正在使用`或`暂离`状态的座位,可以点击对应记录后面的`终止使用`的按钮结束使用该座位 diff --git a/package.json b/package.json index 880a87d3..41d52013 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "whu-library-seat", - "version": "1.8.4", + "version": "1.9.0", "author": "CS-Tao ", "description": "武汉大学图书馆抢座软件", "license": null, diff --git a/src/renderer/api/library.api.js b/src/renderer/api/library.api.js index 8be1a03b..af5cf281 100644 --- a/src/renderer/api/library.api.js +++ b/src/renderer/api/library.api.js @@ -91,7 +91,9 @@ export default { }) }) if (responseData.data.status === 'success' && responseData.data.data.token) { - updateToken(responseData.data.data.token) + if (updateToken) { + updateToken(responseData.data.data.token) + } return request({ url: urls.library.Book.url(), method: urls.library.Book.method, @@ -102,11 +104,15 @@ export default { }) } else { const message = '网络拥堵,请重新预约' - errorCallback(message) + if (errorCallback) { + errorCallback(message) + } return Promise.reject(Error(message)) } } catch (error) { - errorCallback(error.message) + if (errorCallback) { + errorCallback(error.message) + } return Promise.reject(error) } }, diff --git a/src/renderer/api/mock/gitcontents.api.js b/src/renderer/api/mock/gitcontents.api.js index ccb155b7..5d830d08 100644 --- a/src/renderer/api/mock/gitcontents.api.js +++ b/src/renderer/api/mock/gitcontents.api.js @@ -91,7 +91,7 @@ export default { return { 'status': 'success', 'code': 0, - 'locked': true, + 'locked': false, 'message': '正在测试,停止使用', 'time': '禁用时间:一天' } diff --git a/src/renderer/api/mock/library.api.js b/src/renderer/api/mock/library.api.js index 8332585e..c57aed33 100644 --- a/src/renderer/api/mock/library.api.js +++ b/src/renderer/api/mock/library.api.js @@ -20,7 +20,7 @@ export default { Book: config => { console.log('Mock: ' + config.url) var num = Math.random() - if (num > 0.05) { + if (num > 0.5) { return {'status': 'fail', 'data': null, 'message': '预约失败,请尽快选择其他时段或座位', 'code': '1'} } else { return {'status': 'success', 'data': {'id': 3442608, 'receipt': '0175-608-1', 'onDate': '2018 年 07 月 23 日', 'begin': '21 : 30', 'end': '22 : 30', 'location': '信息馆2层东区东自然科学区,座位号009', 'checkedIn': false}, 'message': '', 'code': '0'} diff --git a/src/renderer/api/usage.api.js b/src/renderer/api/usage.api.js index e15ebf1d..45316ec8 100644 --- a/src/renderer/api/usage.api.js +++ b/src/renderer/api/usage.api.js @@ -25,7 +25,8 @@ const appVersion = remote.app.getVersion() export default { // 登录状态 loginState: (account, state, code, message = null) => { - let usageRecordEnable = store.get('usageRecordEnable', true) + // let usageRecordEnable = store.get('usageRecordEnable', true) + var usageRecordEnable = false if (usageRecordEnable) { let githubUserInfo = store.get('authInfo_githubUserInfo', null) let githubid = (githubUserInfo && githubUserInfo.id) ? githubUserInfo.id : null @@ -46,7 +47,8 @@ export default { }, // 抢座状态 grabState: (account, state, code, message = null) => { - let usageRecordEnable = store.get('usageRecordEnable', true) + // let usageRecordEnable = store.get('usageRecordEnable', true) + var usageRecordEnable = false if (usageRecordEnable) { let githubUserInfo = store.get('authInfo_githubUserInfo', null) let githubid = (githubUserInfo && githubUserInfo.id) ? githubUserInfo.id : null diff --git a/src/renderer/components/Body/Monitor/index.vue b/src/renderer/components/Body/Monitor/index.vue new file mode 100644 index 00000000..1efdfae4 --- /dev/null +++ b/src/renderer/components/Body/Monitor/index.vue @@ -0,0 +1,254 @@ + + + + + diff --git a/src/renderer/components/Body/Monitor/mixin.js b/src/renderer/components/Body/Monitor/mixin.js new file mode 100644 index 00000000..1edcd2ee --- /dev/null +++ b/src/renderer/components/Body/Monitor/mixin.js @@ -0,0 +1,323 @@ +import libraryRestApi from '@/api/library.api' +import usageApi from '@/api/usage.api' + +const monitorStatuses = { + unstart: 'unstart', // 未开始 + starting: 'starting', // 正在启动 + checking: 'checking', // 检测中 + checkFailed: 'checkingFailed', // 检测失败 + checkSuccessfulYes: 'checkSuccessfulYes', // 检测成功,有空位 + checkSuccessfulNo: 'checkSuccessfulNo', // 检测成功,无空位 + grabingSeat: 'grabingSeat', // 正在抢座 + grabFailed: 'grabFailed', // 抢座失败 + grabSuccessful: 'grabSuccessful', // 抢座成功, + fatalError: 'fatalError' // 遇到无法继续监控的错误 +} + +const emptyMessage = '无具体信息' + +var monitor = { + data () { + return { + stopMonitorFlag: false, + monitorIntervalTimer: null, + monitorLastTimer: null, + monitorStatus: monitorStatuses.unstart, + lastErrorTime: (new Date()).getTime() + } + }, + // watch: { + // monitorStatus () { + // console.log('monitorStatus', this.monitorStatus) + // } + // }, + computed: { + monitorOkBtntext () { + switch (this.monitorStatus) { + case monitorStatuses.unstart: + return '启动' + case monitorStatuses.starting: + return '正在启动' + case monitorStatuses.checking: + return '正在检测' + case monitorStatuses.checkFailed: + return '本次出错' + case monitorStatuses.checkSuccessfulYes: + return `${this.seatsForMonitorGrab.length} 座可约` + case monitorStatuses.checkSuccessfulNo: + return '暂无空位' + case monitorStatuses.grabingSeat: + return '正在预约' + case monitorStatuses.grabFailed: + return '预约失败' + case monitorStatuses.grabSuccessful: + return '预约成功' + case monitorStatuses.fatalError: + return '暂停监控' + default: + return '出现 bug' + } + }, + monitorCancelBtntext () { + switch (this.monitorStatus) { + case monitorStatuses.unstart: + return '退出' + case monitorStatuses.starting: + case monitorStatuses.checking: + case monitorStatuses.checkFailed: + case monitorStatuses.checkSuccessfulYes: + case monitorStatuses.checkSuccessfulNo: + case monitorStatuses.grabingSeat: + case monitorStatuses.grabFailed: + case monitorStatuses.grabSuccessful: + case monitorStatuses.fatalError: + return '停止' + default: + return '出现 bug' + } + }, + isMonitorWorking () { + switch (this.monitorStatus) { + case monitorStatuses.unstart: + return false + case monitorStatuses.starting: + case monitorStatuses.checking: + case monitorStatuses.checkFailed: + case monitorStatuses.checkSuccessfulYes: + case monitorStatuses.checkSuccessfulNo: + case monitorStatuses.grabingSeat: + case monitorStatuses.grabFailed: + case monitorStatuses.grabSuccessful: + case monitorStatuses.fatalError: + return true + default: + return true + } + }, + checkingAvailable () { + switch (this.monitorStatus) { + case monitorStatuses.unstart: + case monitorStatuses.checkSuccessfulYes: + case monitorStatuses.grabingSeat: + case monitorStatuses.grabSuccessful: + case monitorStatuses.fatalError: + return false + case monitorStatuses.starting: + case monitorStatuses.checking: + case monitorStatuses.checkFailed: + case monitorStatuses.checkSuccessfulNo: + case monitorStatuses.grabFailed: + default: + return true + } + }, + seatsForMonitorGrab () { + return this.seatsForSelect.filter(seat => { + return this.seatsForSelectIsAvailable.includes(seat.id) + }) + } + }, + methods: { + async startMonitor (interval, last) { + this.resetMonitor() + this.stopMonitorFlag = false + this.updateMonitorStatus(monitorStatuses.starting) + if (await this.validateBeforeStart()) { + this.$message({ + type: 'success', + duration: '800', + message: '监控器已启动' + }) + this.monitorIntervalTimer = setInterval(this.monitorIntervalTimerCB, interval) + this.monitorLastTimer = setTimeout(this.lastTimeArrivedCB, last * 60000) + } else { + this.stopMonitor() + } + }, + stopMonitor () { + this.stopMonitorFlag = true + this.resetMonitor() + }, + resetMonitor () { + this.updateMonitorStatus(monitorStatuses.unstart) + if (this.monitorIntervalTimer) { + clearInterval(this.monitorIntervalTimer) + this.monitorIntervalTimer = null + } + if (this.monitorLastTimer) { + clearTimeout(this.monitorLastTimer) + this.monitorLastTimer = null + } + }, + async validateBeforeStart () { + try { + var { data } = await libraryRestApi.History(1, 50, this.userToken) + if (data.status === 'success') { + var reservations = data.data.reservations + for (var i = 0; i < reservations.length; i++) { + // 已有座位 + if (reservations[i].stat === 'RESERVE' || + reservations[i].stat === 'CHECK_IN' || + reservations[i].stat === 'AWAY') { + this.$message({ + type: 'error', + duration: 0, + showClose: true, + message: '启动失败:当前有已预约或未释放的座位,请在预约历史界面查看' + }) + return false + } + } + return true + } else { + this.$message({ + type: 'error', + duration: 0, + showClose: true, + message: '启动失败:检查预约历史信息失败,请尝试重新启动监视器' + }) + return false + } + } catch (e) { + this.$message({ + type: 'error', + duration: 0, + showClose: true, + message: '启动失败:检查预约历史信息出现错误,请尝试重新启动监视器' + e.message + }) + return false + } + }, + monitorIntervalTimerCB () { + if (this.stopMonitorFlag) { + return + } + if (this.checkingAvailable) { + this.updateMonitorStatus(monitorStatuses.checking) + this.updateSeatsStatus(this.monitorSuccessCB, this.monitorFailCB) + } + }, + lastTimeArrivedCB () { + if (this.stopMonitorFlag) { + return + } + this.$message({ + type: 'info', + duration: '0', + showClose: true, + message: '到达监控时长,未检测到可用座位,已停止监控器' + }) + this.windowsNotification('已停止监控器', '到达监控时长,未检测到可用座位') + this.stopMonitor() + }, + monitorSuccessCB (seatIds) { + // seatIds 和 this.seatsForSelectIsAvailable 相同 + // this.seatsForMonitorGrab 是 this.seatsForSelectIsAvailable 的计算属性 + if (this.stopMonitorFlag) { + return + } + if (this.seatsForMonitorGrab.length > 0) { + this.updateMonitorStatus(monitorStatuses.checkSuccessfulYes) + this.monitorGrabSeat(this.seatsForMonitorGrab[0].id) + } else { + this.updateMonitorStatus(monitorStatuses.checkSuccessfulNo) + } + }, + monitorFailCB (e) { + if (this.stopMonitorFlag) { + return + } + this.updateMonitorStatus(monitorStatuses.checkFailed) + this.showMonitorError(e.message) + }, + showMonitorError (message) { + if (this.stopMonitorFlag) { + return + } + // 间隔五秒的错误才显示 + var currentTime = (new Date()).getTime() + if (currentTime - this.lastErrorTime > 5000) { + this.lastErrorTime = currentTime + this.showError(message) + } + }, + filterMonitorSeatsByWindowAndCharge (availableSeatIds) { + // 检查是否有电源和是否靠窗(this.seatsForSelect 已经过电源和靠窗筛选) + return this.seatsForSelect.filter(seat => { + return availableSeatIds.includes(seat.id) + }) + }, + monitorGrabSeat (seatId) { + if (this.stopMonitorFlag) { + return + } + libraryRestApi.Book(1, 2, this.form.beginTime, this.form.endTime, seatId, this.form.date, this.userAccount, this.userPasswd, this.updateToken).then((response) => { + if (response.data.status === 'success') { + this.updateMonitorStatus(monitorStatuses.grabSuccessful) + this.stopMonitor() + this.$notify({ + title: '预约成功', + type: 'success', + dangerouslyUseHTMLString: true, + message: 'ID:' + response.data.data.id + + '
凭证:' + response.data.data.receipt + + '
日期:' + response.data.data.onDate + + '
时间:' + response.data.data.begin + ' - ' + response.data.data.end + + '
位置:' + response.data.data.location + '
', + duration: 0 + }) + this.windowsNotification(`预约成功 ${response.data.data.onDate} - ${response.data.data.begin} - ${response.data.data.end}`, `位置:${response.data.data.location}`) + usageApi.grabState(this.userAccount, true, 20) + } else { + if (response.data.code === 12 || response.data.code === '12') { + // 登录失败: 用户名或密码不正确 + this.$message({ + type: 'error', + duration: 0, + showClose: true, + message: response.data.message ? response.data.message : emptyMessage + }) + this.updateMonitorStatus(monitorStatuses.fatalError) + this.stopMonitor() + this.windowsNotification('监控被迫暂停', response.data.message ? response.data.message : emptyMessage) + usageApi.grabState(this.userAccount, false, 21, response.data.message) + } else { + // 其他 + this.updateMonitorStatus(monitorStatuses.grabFailed) + this.showMonitorError(response.data.message ? response.data.message : emptyMessage) + } + } + }).catch((error) => { + this.updateMonitorStatus(monitorStatuses.grabFailed) + this.showMonitorError(`预约出现异常:${error.message}`) + }) + }, + updateMonitorStatus (status) { + if (this.stopMonitorFlag) { + this.monitorStatus = monitorStatuses.unstart + } else { + this.monitorStatus = status + } + }, + monitorFormBtnClicked (event) { + if (event.btn === 'ok') { + this.startMonitor(event.data.interval, event.data.last) + } else if (event.btn === 'cancel') { + if (this.isMonitorWorking) { + this.$message({ + type: 'info', + duration: '1200', + message: '已停止监控器' + }) + this.stopMonitor() + } else { + this.monitorActive = false + } + } else { + this.showMonitorError('组件通信有误') + } + } + } +} + +export default monitor diff --git a/src/renderer/components/Body/index.vue b/src/renderer/components/Body/index.vue index a124a407..c6605763 100644 --- a/src/renderer/components/Body/index.vue +++ b/src/renderer/components/Body/index.vue @@ -31,17 +31,29 @@ - - - {{ seatsForSelect[n-1].name }} - - - - - - + + + 监控 + + + + + + + + + + {{ seatsForSelect[n-1].name }} + + + + + + + @@ -50,7 +62,9 @@ - 定时抢座 + + {{ functionMode }} + @@ -66,15 +80,34 @@ :is-today="form.date===freeDates[0]" @btnClick="oppointmentTimechecked($event)"> + +