diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 6e058203..569f7de1 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -73,6 +73,7 @@ class UserController extends Controller 'errno' => 0, 'msg' => trans('user.sign-in-success', ['score' => $acuiredScore]), 'score' => $this->user->getScore(), + 'storage' => $this->calculatePercentageUsed($this->user->getStorageUsed(), option('score_per_storage')), 'remaining_time' => round($this->user->getSignInRemainingTime() / 3600) ]); } else { diff --git a/resources/assets/src/scripts/user.js b/resources/assets/src/scripts/user.js index b14864af..d775288e 100644 --- a/resources/assets/src/scripts/user.js +++ b/resources/assets/src/scripts/user.js @@ -554,6 +554,14 @@ function signIn() { var dom = '  ' + trans('user.signInRemainingTime', { time: String(json.remaining_time) }); $('#sign-in-button').attr('disabled', 'disabled').html(dom); + if (json.storage.used > 1024) { + $('#user-storage').html(`${Math.round(json.storage.used)}/ ${Math.round(json.storage.total)} MB`); + } else { + $('#user-storage').html(`${Math.round(json.storage.used)}/ ${Math.round(json.storage.total)} KB`); + } + + $('#user-storage-bar').css('width', `${json.storage.percentage}%`) + swal({ type: 'success', html: json.msg diff --git a/resources/views/user/index.tpl b/resources/views/user/index.tpl index e7dac682..22d3bdb4 100644 --- a/resources/views/user/index.tpl +++ b/resources/views/user/index.tpl @@ -44,18 +44,16 @@ $total = $statistics['storage']['total']; ?> - @if ($used > 1024) - - {{ round($used / 1024, 1) }}/ {{ is_string($total) ? $total : round($total / 1024, 1) }} MB + + @if ($used > 1024) + {{ round($used / 1024, 1) }}/ {{ is_string($total) ? $total : round($total / 1024, 1) }} MB + @else + {{ $used }}/ {{ $total }} KB + @endif - @else - - {{ $used }}/ {{ $total }} KB - - @endif
-
+