diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index f75a5df7..d6f49319 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -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() diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index d37731a1..b3d07369 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -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); } } diff --git a/app/Models/User.php b/app/Models/User.php index ce50aa49..7e2c52c4 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -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; } diff --git a/resources/assets/src/js/user/sign.js b/resources/assets/src/js/user/sign.js index 449325ab..f0f90884 100644 --- a/resources/assets/src/js/user/sign.js +++ b/resources/assets/src/js/user/sign.js @@ -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 = '  ' + trans('user.signInRemainingTime', { time: String(result.remaining_time) }); - $('#sign-in-button').attr('disabled', 'disabled').html(dom); + var dom = '  ' + trans('user.signRemainingTime', { time: String(result.remaining_time) }); + + $('#sign-button').attr('disabled', 'disabled').html(dom); if (result.storage.used > 1024) { $('#user-storage').html(`${Math.round(result.storage.used)}/ ${Math.round(result.storage.total)} MB`); diff --git a/resources/lang/en/locale.js b/resources/lang/en/locale.js index 2c880e1d..725247ce 100644 --- a/resources/lang/en/locale.js +++ b/resources/lang/en/locale.js @@ -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: '

Nothing in your closet...

Why not explore the Skin Library for a while?

', diff --git a/resources/lang/en/options.yml b/resources/lang/en/options.yml index f6b65ff0..d28b4d0e 100644 --- a/resources/lang/en/options.yml +++ b/resources/lang/en/options.yml @@ -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 diff --git a/resources/lang/en/user.yml b/resources/lang/en/user.yml index aee3142b..d314bc7f 100644 --- a/resources/lang/en/user.yml +++ b/resources/lang/en/user.yml @@ -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: diff --git a/resources/lang/zh_CN/locale.js b/resources/lang/zh_CN/locale.js index 24a4066b..3f0cef04 100644 --- a/resources/lang/zh_CN/locale.js +++ b/resources/lang/zh_CN/locale.js @@ -81,7 +81,7 @@ deleteNotice: '真的要删除此材质吗?' }, user: { - signInRemainingTime: ':time 小时后可签到', + signRemainingTime: ':time 小时后可签到', // Closet emptyClosetMsg: '

衣柜里啥都没有哦~

皮肤库看看吧~

', diff --git a/resources/lang/zh_CN/options.yml b/resources/lang/zh_CN/options.yml index 72b43abc..58beb710 100644 --- a/resources/lang/zh_CN/options.yml +++ b/resources/lang/zh_CN/options.yml @@ -47,7 +47,7 @@ rate: addon: 积分 = 一个角色 user_initial_score: 新用户默认积分 -sign_in: +sign: title: 签到配置 sign_score: diff --git a/resources/lang/zh_CN/user.yml b/resources/lang/zh_CN/user.yml index 3b10455e..93a092e4 100644 --- a/resources/lang/zh_CN/user.yml +++ b/resources/lang/zh_CN/user.yml @@ -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: diff --git a/resources/views/admin/score.tpl b/resources/views/admin/score.tpl index 538862bf..4980a50b 100644 --- a/resources/views/admin/score.tpl +++ b/resources/views/admin/score.tpl @@ -21,7 +21,7 @@
- {!! $forms['signIn']->render() !!} + {!! $forms['sign']->render() !!}
diff --git a/resources/views/user/index.tpl b/resources/views/user/index.tpl index aaa7aeb9..7d6012ad 100644 --- a/resources/views/user/index.tpl +++ b/resources/views/user/index.tpl @@ -69,13 +69,13 @@ diff --git a/routes/web.php b/routes/web.php index 466cd5c0..c4ef9be3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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');