Fix possible duplicated signings (fix #68)

This commit is contained in:
Pig Fang 2019-06-25 22:59:05 +08:00
parent 0a1f9ea3d6
commit 7cb3e246a8
4 changed files with 21 additions and 0 deletions

View File

@ -73,6 +73,7 @@
class="btn btn-primary pull-left"
type="primary"
round
:disabled="signing"
@click="sign"
>
<i class="far fa-calendar-check" aria-hidden="true" /> &nbsp;{{ $t('user.sign') }}
@ -114,6 +115,7 @@ export default {
lastSignAt: new Date(),
signAfterZero: false,
signGap: 0,
signing: false,
playersUsed: 0,
playersTotal: 1,
storageUsed: 0,
@ -186,6 +188,7 @@ export default {
this.score = data.user.score
},
async sign() {
this.signing = true
const {
code, message, data,
} = await this.$http.post('/user/sign')
@ -199,6 +202,7 @@ export default {
} else {
this.$message.warning(message)
}
this.signing = false
},
},
}

View File

@ -166,3 +166,12 @@ test('sign', async () => {
expect(button.attributes('disabled')).toBe('disabled')
expect(wrapper.text()).toContain('3 / 4 KB')
})
test('disable button when signing', () => {
Vue.prototype.$http.get.mockResolvedValue(scoreInfo())
const wrapper = mount(Dashboard)
const button = wrapper.find(Button)
expect(button.attributes('disabled')).toBeFalsy()
wrapper.setData({ signing: true })
expect(button.attributes('disabled')).toBeTruthy()
})

View File

@ -7,3 +7,7 @@
- Tweaked style of chart at administration panel.
- Optimized panel of changing theme color.
## Fixed
- Fixed that possible duplicated signings.

View File

@ -7,3 +7,7 @@
- 调整管理面板中的图表样式
- 优化「更改配色」的面板
## 修复
- 修复可能存在的重复签到问题