From ba2d350bafbe47780a4dfe16f725ddcd639bdd1c Mon Sep 17 00:00:00 2001 From: Chenx221 Date: Sun, 3 Mar 2024 13:45:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E7=99=BE=E5=88=86=E6=AF=94=E8=AE=A1=E7=AE=97=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=A4=87=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/UserController.php | 2 +- views/user/info.php | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/controllers/UserController.php b/controllers/UserController.php index e51dc0e..150a2a7 100644 --- a/controllers/UserController.php +++ b/controllers/UserController.php @@ -338,7 +338,7 @@ class UserController extends Controller return $this->render('info', [ 'model' => $model, 'usedSpace' => $usedSpace, // B - 'vaultUsedSpace' => $vaultUsedSpace, + 'vaultUsedSpace' => $vaultUsedSpace, // B 'storageLimit' => $storageLimit, // MB ]); } diff --git a/views/user/info.php b/views/user/info.php index 6c2045c..fdec04b 100644 --- a/views/user/info.php +++ b/views/user/info.php @@ -16,16 +16,17 @@ use yii\bootstrap5\Html; $this->title = '个人设置'; FontAwesomeAsset::register($this); $this->registerCssFile('@web/css/user-info.css'); -$details = IPLocation::getDetails($model->last_login_ip); +$details = IPLocation::getDetails($model->last_login_ip); // IP LOCATION -$usedSpace_F = FileSizeHelper::formatBytes($usedSpace); -$vaultUsedSpace_F = FileSizeHelper::formatBytes($vaultUsedSpace); -$storageLimit_F = FileSizeHelper::formatMegaBytes($storageLimit); -$totalUsed_F = FileSizeHelper::formatBytes($usedSpace + $vaultUsedSpace); -$is_unlimited = ($storageLimit === -1); -$usedPercent = $is_unlimited ? 0 : round($usedSpace / $storageLimit * 100); -$vaultUsedPercent = $is_unlimited ? 0 : round($vaultUsedSpace / $storageLimit * 100); -$totalUsedPercent = min(($usedPercent + $vaultUsedPercent), 100); +// 容量计算 +$usedSpace_F = FileSizeHelper::formatBytes($usedSpace); //网盘已用空间 格式化文本 +$vaultUsedSpace_F = FileSizeHelper::formatBytes($vaultUsedSpace); //保险箱已用空间 格式化文本 +$storageLimit_F = FileSizeHelper::formatMegaBytes($storageLimit); //存储限制 格式化文本 +$totalUsed_F = FileSizeHelper::formatBytes($usedSpace + $vaultUsedSpace); //总已用空间 格式化文本 +$is_unlimited = ($storageLimit === -1); //检查是否为无限制容量 +$usedPercent = $is_unlimited ? 0 : round($usedSpace / ($storageLimit * 1024 * 1024) * 100); //网盘已用百分比 +$vaultUsedPercent = $is_unlimited ? 0 : round($vaultUsedSpace / ($storageLimit * 1024 * 1024) * 100); //保险箱已用百分比 +$totalUsedPercent = min(($usedPercent + $vaultUsedPercent), 100); //总已用百分比 ?>