fix(ui): 修复登录与并发请求并统一表格、主题和页面展示

验证:868 项单测、ESLint、Prettier、UI 依赖审计和差异检查通过。
This commit is contained in:
zhanjunhao
2026-11-19 18:58:46 +08:00
parent 9f5e0cddfb
commit e70e0d2224
128 changed files with 4672 additions and 5391 deletions
+52
View File
@@ -0,0 +1,52 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
export const toFiniteNumber = (value) => {
if (value === null || value === undefined || value === '') return null;
const number = Number(value);
return Number.isFinite(number) ? number : null;
};
export const formatPercent = (value, digits = 1, fallback = '-') => {
const number = toFiniteNumber(value);
return number === null ? fallback : `${number.toFixed(digits)}%`;
};
export const formatRatioPercent = (part, total, digits = 1, fallback = '-') => {
const numerator = toFiniteNumber(part);
const denominator = toFiniteNumber(total);
if (numerator === null || denominator === null || denominator <= 0) {
return fallback;
}
return formatPercent((numerator / denominator) * 100, digits, fallback);
};
export const formatUserReference = (name, id, fallback = '-') => {
const displayName = typeof name === 'string' ? name.trim() : name;
if (displayName) return String(displayName);
const userId = toFiniteNumber(id);
return userId === null ? fallback : `User#${userId}`;
};
export const formatIdReference = (id, fallback = '-') => {
if (id === null || id === undefined || id === '') return fallback;
const value = String(id).trim();
return value ? `#${value}` : fallback;
};