修复错误的百分比计算
更新备注
This commit is contained in:
parent
9686944875
commit
ba2d350baf
@ -338,7 +338,7 @@ class UserController extends Controller
|
|||||||
return $this->render('info', [
|
return $this->render('info', [
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
'usedSpace' => $usedSpace, // B
|
'usedSpace' => $usedSpace, // B
|
||||||
'vaultUsedSpace' => $vaultUsedSpace,
|
'vaultUsedSpace' => $vaultUsedSpace, // B
|
||||||
'storageLimit' => $storageLimit, // MB
|
'storageLimit' => $storageLimit, // MB
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -16,16 +16,17 @@ use yii\bootstrap5\Html;
|
|||||||
$this->title = '个人设置';
|
$this->title = '个人设置';
|
||||||
FontAwesomeAsset::register($this);
|
FontAwesomeAsset::register($this);
|
||||||
$this->registerCssFile('@web/css/user-info.css');
|
$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);
|
$usedSpace_F = FileSizeHelper::formatBytes($usedSpace); //网盘已用空间 格式化文本
|
||||||
$storageLimit_F = FileSizeHelper::formatMegaBytes($storageLimit);
|
$vaultUsedSpace_F = FileSizeHelper::formatBytes($vaultUsedSpace); //保险箱已用空间 格式化文本
|
||||||
$totalUsed_F = FileSizeHelper::formatBytes($usedSpace + $vaultUsedSpace);
|
$storageLimit_F = FileSizeHelper::formatMegaBytes($storageLimit); //存储限制 格式化文本
|
||||||
$is_unlimited = ($storageLimit === -1);
|
$totalUsed_F = FileSizeHelper::formatBytes($usedSpace + $vaultUsedSpace); //总已用空间 格式化文本
|
||||||
$usedPercent = $is_unlimited ? 0 : round($usedSpace / $storageLimit * 100);
|
$is_unlimited = ($storageLimit === -1); //检查是否为无限制容量
|
||||||
$vaultUsedPercent = $is_unlimited ? 0 : round($vaultUsedSpace / $storageLimit * 100);
|
$usedPercent = $is_unlimited ? 0 : round($usedSpace / ($storageLimit * 1024 * 1024) * 100); //网盘已用百分比
|
||||||
$totalUsedPercent = min(($usedPercent + $vaultUsedPercent), 100);
|
$vaultUsedPercent = $is_unlimited ? 0 : round($vaultUsedSpace / ($storageLimit * 1024 * 1024) * 100); //保险箱已用百分比
|
||||||
|
$totalUsedPercent = min(($usedPercent + $vaultUsedPercent), 100); //总已用百分比
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
|
Loading…
Reference in New Issue
Block a user