Use "min" as unit when sign remaining time is less than 1 hour
This commit is contained in:
parent
a2edc469ac
commit
0771c4c2dd
@ -77,8 +77,11 @@ class UserController extends Controller
|
||||
'remaining_time' => $this->getUserSignRemainingTimeWithPrecision()
|
||||
]);
|
||||
} else {
|
||||
$remaining_time = $this->getUserSignRemainingTimeWithPrecision();
|
||||
return json(trans('user.cant-sign-until', [
|
||||
'time' => $this->getUserSignRemainingTimeWithPrecision()
|
||||
'time' => $remaining_time >= 1 ?: round($remaining_time * 60),
|
||||
'unit' => $remaining_time >= 1
|
||||
? trans('user.time-unit-hour') : trans('user.time-unit-min')
|
||||
]), 1);
|
||||
}
|
||||
}
|
||||
@ -87,7 +90,7 @@ class UserController extends Controller
|
||||
{
|
||||
$hours = $this->user->getSignRemainingTime() / 3600;
|
||||
|
||||
return round($hours) ?: round($hours, 1);
|
||||
return $hours > 1 ? round($hours) : $hours;
|
||||
}
|
||||
|
||||
public function profile()
|
||||
|
@ -834,7 +834,7 @@ describe('tests for "sign" module', () => {
|
||||
errno: 0,
|
||||
msg: 'success',
|
||||
score: 100,
|
||||
remaining_time: 24,
|
||||
remaining_time: 0.1,
|
||||
storage: {
|
||||
used: 50,
|
||||
total: 100,
|
||||
@ -870,7 +870,10 @@ describe('tests for "sign" module', () => {
|
||||
dataType: 'json'
|
||||
});
|
||||
expect($('#score').html()).toBe('100');
|
||||
expect(trans).toBeCalledWith('user.signRemainingTime', { time: '24' });
|
||||
expect(trans).toBeCalledWith(
|
||||
'user.signRemainingTime',
|
||||
{ time: '6', unit: 'user.timeUnitMin' }
|
||||
);
|
||||
expect($('#sign-button').html()).toBe(
|
||||
'<i class="fa fa-calendar-check-o"></i> user.signRemainingTime'
|
||||
);
|
||||
@ -880,6 +883,10 @@ describe('tests for "sign" module', () => {
|
||||
expect(swal).toBeCalledWith({ type: 'success', html: 'success' });
|
||||
|
||||
await sign();
|
||||
expect(trans).toBeCalledWith(
|
||||
'user.signRemainingTime',
|
||||
{ time: '24', unit: 'user.timeUnitHour' }
|
||||
);
|
||||
expect($('#user-storage').html()).toBe('<b>2</b>/ 4 MB');
|
||||
|
||||
await sign();
|
||||
|
@ -6,7 +6,12 @@ function sign() {
|
||||
}).then(result => {
|
||||
if (result.errno == 0) {
|
||||
$('#score').html(result.score);
|
||||
var dom = '<i class="fa fa-calendar-check-o"></i> ' + trans('user.signRemainingTime', { time: String(result.remaining_time) });
|
||||
const dom = '<i class="fa fa-calendar-check-o"></i> ' + trans(
|
||||
'user.signRemainingTime',
|
||||
result.remaining_time >= 1
|
||||
? { time: result.remaining_time.toString(), unit: trans('user.timeUnitHour') }
|
||||
: { time: (result.remaining_time * 60).toFixed(), unit: trans('user.timeUnitMin') }
|
||||
);
|
||||
|
||||
$('#sign-button').attr('disabled', 'disabled').html(dom);
|
||||
|
||||
|
@ -79,7 +79,10 @@
|
||||
deleteNotice: 'Are you sure to delete this texture?'
|
||||
},
|
||||
user: {
|
||||
signRemainingTime: 'Available after :time hours',
|
||||
// Signing in
|
||||
signRemainingTime: 'Available after :time :unit',
|
||||
timeUnitHour: 'h',
|
||||
timeUnitMin: 'min',
|
||||
|
||||
// Closet
|
||||
emptyClosetMsg: '<p>Nothing in your closet...</p><p>Why not explore the <a href=":url">Skin Library</a> for a while?</p>',
|
||||
|
@ -7,9 +7,11 @@ cur-score: Current Score
|
||||
score-notice: Click the score to show introduction.
|
||||
sign: Sign
|
||||
sign-success: Signed successfully. You got :score scores.
|
||||
cant-sign-until: You can't sign in in :time hours
|
||||
time-unit-hour: h
|
||||
time-unit-min: min
|
||||
cant-sign-until: You can't sign in in :time :unit
|
||||
last-sign: Last signed at :time
|
||||
sign-remain-time: Available after :time hours
|
||||
sign-remain-time: Available after :time :unit
|
||||
announcement: Announcement
|
||||
|
||||
score-intro:
|
||||
|
@ -81,7 +81,10 @@
|
||||
deleteNotice: '真的要删除此材质吗?'
|
||||
},
|
||||
user: {
|
||||
signRemainingTime: ':time 小时后可签到',
|
||||
// Signing in
|
||||
signRemainingTime: ':time :unit 后可签到',
|
||||
timeUnitHour: '小时',
|
||||
timeUnitMin: '分钟',
|
||||
|
||||
// Closet
|
||||
emptyClosetMsg: '<p>衣柜里啥都没有哦~</p><p>去<a href=":url">皮肤库</a>看看吧~</p>',
|
||||
|
@ -7,9 +7,11 @@ cur-score: 当前积分
|
||||
score-notice: 点击积分查看说明
|
||||
sign: 每日签到
|
||||
sign-success: 签到成功,获得了 :score 积分~
|
||||
cant-sign-until: :time 小时后才能再次签到哦~
|
||||
time-unit-hour: 小时
|
||||
time-unit-min: 分钟
|
||||
cant-sign-until: :time :unit 后才能再次签到哦~
|
||||
last-sign: 上次签到于 :time
|
||||
sign-remain-time: :time 小时后可签到
|
||||
sign-remain-time: :time :unit 后可签到
|
||||
announcement: 公告
|
||||
|
||||
score-intro:
|
||||
|
@ -77,7 +77,11 @@
|
||||
<button class="btn btn-primary pull-left" title="{{ trans('user.last-sign', ['time' => $user->getLastSignTime()]) }}" disabled="disabled">
|
||||
<i class="fa fa-calendar-check-o" aria-hidden="true"></i>
|
||||
<?php $hours = $user->getSignRemainingTime() / 3600; ?>
|
||||
{{ trans('user.sign-remain-time', ['time' => round($hours) ?: round($hours, 1)]) }}
|
||||
@if ($hours >= 1)
|
||||
{{ trans('user.sign-remain-time', ['time' => round($hours), 'unit' => trans('user.time-unit-hour')]) }}
|
||||
@else
|
||||
{{ trans('user.sign-remain-time', ['time' => round($hours * 60), 'unit' => trans('user.time-unit-min')]) }}
|
||||
@endif
|
||||
</button>
|
||||
@endif
|
||||
</div><!-- /.box-footer -->
|
||||
|
Loading…
Reference in New Issue
Block a user