mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-03-07 15:16:40 +08:00
Rename sign in
to sign
This commit is contained in:
parent
7d7b35f5fd
commit
3a74329548
@ -79,11 +79,11 @@ class AdminController extends Controller
|
||||
|
||||
})->handle();
|
||||
|
||||
$signIn = Option::form('sign_in', OptionForm::AUTO_DETECT, function($form)
|
||||
$sign = Option::form('sign', OptionForm::AUTO_DETECT, function($form)
|
||||
{
|
||||
$form->group('sign_score')
|
||||
->text('sign_score_from')->addon(trans('options.sign_in.sign_score.addon1'))
|
||||
->text('sign_score_to')->addon(trans('options.sign_in.sign_score.addon2'));
|
||||
->text('sign_score_from')->addon(trans('options.sign.sign_score.addon1'))
|
||||
->text('sign_score_to')->addon(trans('options.sign.sign_score.addon2'));
|
||||
|
||||
$form->group('sign_gap_time')->text('sign_gap_time')->addon();
|
||||
|
||||
@ -99,7 +99,7 @@ class AdminController extends Controller
|
||||
'sign_score_to' => @explode(',', option('sign_score'))[1]
|
||||
]);
|
||||
|
||||
return view('admin.score', ['forms' => compact('rate', 'signIn')]);
|
||||
return view('admin.score', ['forms' => compact('rate', 'sign')]);
|
||||
}
|
||||
|
||||
public function options()
|
||||
|
@ -60,24 +60,24 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle user signing in.
|
||||
* Handle user signing.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function signIn()
|
||||
public function sign()
|
||||
{
|
||||
if ($this->user->canSignIn()) {
|
||||
$acuiredScore = $this->user->signIn();
|
||||
if ($this->user->canSign()) {
|
||||
$acuiredScore = $this->user->sign();
|
||||
|
||||
return json([
|
||||
'errno' => 0,
|
||||
'msg' => trans('user.sign-in-success', ['score' => $acuiredScore]),
|
||||
'msg' => trans('user.sign-success', ['score' => $acuiredScore]),
|
||||
'score' => $this->user->getScore(),
|
||||
'storage' => $this->calculatePercentageUsed($this->user->getStorageUsed(), option('score_per_storage')),
|
||||
'remaining_time' => round($this->user->getSignInRemainingTime() / 3600)
|
||||
'remaining_time' => round($this->user->getSignRemainingTime() / 3600)
|
||||
]);
|
||||
} else {
|
||||
return json(trans('user.cant-sign-in-until', ['time' => round($this->user->getSignInRemainingTime() / 3600)]), 1);
|
||||
return json(trans('user.cant-sign-until', ['time' => round($this->user->getSignRemainingTime() / 3600)]), 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -273,13 +273,13 @@ class User extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* Sign in for the user, return false if unavailable.
|
||||
* Sign for the user, return false if unavailable.
|
||||
*
|
||||
* @return int|bool
|
||||
*/
|
||||
public function signIn()
|
||||
public function sign()
|
||||
{
|
||||
if ($this->canSignIn()) {
|
||||
if ($this->canSign()) {
|
||||
|
||||
$scoreLimits = explode(',', option('sign_score'));
|
||||
$acquiredScore = rand($scoreLimits[0], $scoreLimits[1]);
|
||||
@ -299,18 +299,18 @@ class User extends Model
|
||||
*
|
||||
* @return int Time in seconds.
|
||||
*/
|
||||
public function getSignInRemainingTime()
|
||||
public function getSignRemainingTime()
|
||||
{
|
||||
// convert to timestamp
|
||||
$lastSignInTime = Carbon::parse($this->getLastSignInTime());
|
||||
$lastSignTime = Carbon::parse($this->getLastSignTime());
|
||||
|
||||
if (option('sign_after_zero')) {
|
||||
return Carbon::now()->diffInSeconds(
|
||||
(($lastSignInTime <= Carbon::today()) ? $lastSignInTime : Carbon::tomorrow())
|
||||
(($lastSignTime <= Carbon::today()) ? $lastSignTime : Carbon::tomorrow())
|
||||
, false);
|
||||
}
|
||||
|
||||
return Carbon::now()->diffInSeconds($lastSignInTime->addSeconds(option('sign_gap_time') * 3600), false);
|
||||
return Carbon::now()->diffInSeconds($lastSignTime->addSeconds(option('sign_gap_time') * 3600), false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -318,9 +318,9 @@ class User extends Model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canSignIn()
|
||||
public function canSign()
|
||||
{
|
||||
return ($this->getSignInRemainingTime() <= 0);
|
||||
return ($this->getSignRemainingTime() <= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -328,7 +328,7 @@ class User extends Model
|
||||
*
|
||||
* @return string Formatted time string.
|
||||
*/
|
||||
public function getLastSignInTime()
|
||||
public function getLastSignTime()
|
||||
{
|
||||
return $this->last_sign_at;
|
||||
}
|
||||
|
@ -1,15 +1,16 @@
|
||||
/* exported signIn */
|
||||
/* exported sign */
|
||||
|
||||
function signIn() {
|
||||
function sign() {
|
||||
fetch({
|
||||
type: 'POST',
|
||||
url: url('user/sign-in'),
|
||||
url: url('user/sign'),
|
||||
dataType: 'json'
|
||||
}).then(result => {
|
||||
if (result.errno == 0) {
|
||||
$('#score').html(result.score);
|
||||
var dom = '<i class="fa fa-calendar-check-o"></i> ' + trans('user.signInRemainingTime', { time: String(result.remaining_time) });
|
||||
$('#sign-in-button').attr('disabled', 'disabled').html(dom);
|
||||
var dom = '<i class="fa fa-calendar-check-o"></i> ' + trans('user.signRemainingTime', { time: String(result.remaining_time) });
|
||||
|
||||
$('#sign-button').attr('disabled', 'disabled').html(dom);
|
||||
|
||||
if (result.storage.used > 1024) {
|
||||
$('#user-storage').html(`<b>${Math.round(result.storage.used)}</b>/ ${Math.round(result.storage.total)} MB`);
|
||||
|
@ -79,7 +79,7 @@
|
||||
deleteNotice: 'Are you sure to delete this texture?'
|
||||
},
|
||||
user: {
|
||||
signInRemainingTime: 'Available after :time hours',
|
||||
signRemainingTime: 'Available after :time hours',
|
||||
|
||||
// Closet
|
||||
emptyClosetMsg: '<p>Nothing in your closet...</p><p>Why not explore the <a href=":url">Skin Library</a> for a while?</p>',
|
||||
|
@ -47,8 +47,8 @@ rate:
|
||||
addon: scores = 1 player
|
||||
user_initial_score: User Initial Score
|
||||
|
||||
sign_in:
|
||||
title: Signing In
|
||||
sign:
|
||||
title: Signing
|
||||
|
||||
sign_score:
|
||||
title: Score Granted
|
||||
|
@ -5,11 +5,11 @@ used:
|
||||
|
||||
cur-score: Current Score
|
||||
score-notice: Click the score to show introduction.
|
||||
sign-in: Sign In
|
||||
sign-in-success: Signed in successfully. You got :score scores.
|
||||
cant-sign-in-until: You can't sign in in :time hours
|
||||
last-sign-in: Last signed in at :time
|
||||
sign-in-remain-time: Available after :time hours
|
||||
sign: Sign
|
||||
sign-success: Signed successfully. You got :score scores.
|
||||
cant-sign-until: You can't sign in in :time hours
|
||||
last-sign: Last signed at :time
|
||||
sign-remain-time: Available after :time hours
|
||||
announcement: Announcement
|
||||
|
||||
score-intro:
|
||||
|
@ -81,7 +81,7 @@
|
||||
deleteNotice: '真的要删除此材质吗?'
|
||||
},
|
||||
user: {
|
||||
signInRemainingTime: ':time 小时后可签到',
|
||||
signRemainingTime: ':time 小时后可签到',
|
||||
|
||||
// Closet
|
||||
emptyClosetMsg: '<p>衣柜里啥都没有哦~</p><p>去<a href=":url">皮肤库</a>看看吧~</p>',
|
||||
|
@ -47,7 +47,7 @@ rate:
|
||||
addon: 积分 = 一个角色
|
||||
user_initial_score: 新用户默认积分
|
||||
|
||||
sign_in:
|
||||
sign:
|
||||
title: 签到配置
|
||||
|
||||
sign_score:
|
||||
|
@ -5,11 +5,11 @@ used:
|
||||
|
||||
cur-score: 当前积分
|
||||
score-notice: 点击积分查看说明
|
||||
sign-in: 每日签到
|
||||
sign-in-success: 签到成功,获得了 :score 积分~
|
||||
cant-sign-in-until: :time 小时后才能再次签到哦~
|
||||
last-sign-in: 上次签到于 :time
|
||||
sign-in-remain-time: :time 小时后可签到
|
||||
sign: 每日签到
|
||||
sign-success: 签到成功,获得了 :score 积分~
|
||||
cant-sign-until: :time 小时后才能再次签到哦~
|
||||
last-sign: 上次签到于 :time
|
||||
sign-remain-time: :time 小时后可签到
|
||||
announcement: 公告
|
||||
|
||||
score-intro:
|
||||
|
@ -21,7 +21,7 @@
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{!! $forms['signIn']->render() !!}
|
||||
{!! $forms['sign']->render() !!}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -69,13 +69,13 @@
|
||||
</div><!-- /.row -->
|
||||
</div><!-- ./box-body -->
|
||||
<div class="box-footer">
|
||||
@if ($user->canSignIn())
|
||||
<button id="sign-in-button" class="btn btn-primary pull-left" onclick="signIn()">
|
||||
<i class="fa fa-calendar-check-o" aria-hidden="true"></i> {{ trans('user.sign-in') }}
|
||||
@if ($user->canSign())
|
||||
<button id="sign-button" class="btn btn-primary pull-left" onclick="sign()">
|
||||
<i class="fa fa-calendar-check-o" aria-hidden="true"></i> {{ trans('user.sign') }}
|
||||
</button>
|
||||
@else
|
||||
<button class="btn btn-primary pull-left" title="{{ trans('user.last-sign-in', ['time' => $user->getLastSignInTime()]) }}" disabled="disabled">
|
||||
<i class="fa fa-calendar-check-o" aria-hidden="true"></i> {{ trans('user.sign-in-remain-time', ['time' => round($user->getSignInRemainingTime() / 3600)]) }}
|
||||
<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> {{ trans('user.sign-remain-time', ['time' => round($user->getSignRemainingTime() / 3600)]) }}
|
||||
</button>
|
||||
@endif
|
||||
</div><!-- /.box-footer -->
|
||||
|
@ -45,7 +45,7 @@ Route::group(['prefix' => 'auth'], function ()
|
||||
Route::group(['middleware' => 'auth', 'prefix' => 'user'], function ()
|
||||
{
|
||||
Route::any ('', 'UserController@index');
|
||||
Route::any ('/sign-in', 'UserController@signIn');
|
||||
Route::any ('/sign', 'UserController@sign');
|
||||
|
||||
// Profile
|
||||
Route::get ('/profile', 'UserController@profile');
|
||||
|
Loading…
Reference in New Issue
Block a user