小改动

This commit is contained in:
wood 2023-11-15 04:45:14 +08:00
parent 876e0d429b
commit bff5456313
2 changed files with 3 additions and 7 deletions

View File

@ -37,21 +37,17 @@ export function renderNumber(num) {
} }
} }
export function renderQuota(quota, digits = 10) { export function renderQuota(quota, digits = 3) {
let quotaPerUnit = localStorage.getItem('quota_per_unit'); let quotaPerUnit = localStorage.getItem('quota_per_unit');
let displayInCurrency = localStorage.getItem('display_in_currency'); let displayInCurrency = localStorage.getItem('display_in_currency');
quotaPerUnit = parseFloat(quotaPerUnit); quotaPerUnit = parseFloat(quotaPerUnit);
displayInCurrency = displayInCurrency === 'true'; displayInCurrency = displayInCurrency === 'true';
if (displayInCurrency) { if (displayInCurrency) {
let displayValue = (quota / quotaPerUnit).toFixed(digits); return '$' + (quota / quotaPerUnit).toFixed(digits);
// 去除尾部多余的零
displayValue = parseFloat(displayValue).toString();
return '$' + displayValue;
} }
return renderNumber(quota); return renderNumber(quota);
} }
export function renderQuotaWithPrompt(quota, digits) { export function renderQuotaWithPrompt(quota, digits) {
let displayInCurrency = localStorage.getItem('display_in_currency'); let displayInCurrency = localStorage.getItem('display_in_currency');
displayInCurrency = displayInCurrency === 'true'; displayInCurrency = displayInCurrency === 'true';

View File

@ -11,7 +11,7 @@ const EditToken = () => {
const [loading, setLoading] = useState(isEdit); const [loading, setLoading] = useState(isEdit);
const originInputs = { const originInputs = {
name: '', name: '',
remain_quota: isEdit ? 0 : renderQuota(500000), remain_quota: isEdit ? 0 : 100,
expired_time: -1, expired_time: -1,
unlimited_quota: false unlimited_quota: false
}; };