mirror of
https://github.com/linux-do/new-api.git
synced 2025-11-12 09:03:42 +08:00
feat: 钱包兼容非货币形式显示额度
This commit is contained in:
@@ -15,14 +15,18 @@ export function renderText(text, limit) {
|
||||
*/
|
||||
export function renderGroup(group) {
|
||||
if (group === '') {
|
||||
return <Tag size='large' key='default'>default</Tag>;
|
||||
return (
|
||||
<Tag size='large' key='default'>
|
||||
default
|
||||
</Tag>
|
||||
);
|
||||
}
|
||||
|
||||
const tagColors = {
|
||||
'vip': 'yellow',
|
||||
'pro': 'yellow',
|
||||
'svip': 'red',
|
||||
'premium': 'red'
|
||||
vip: 'yellow',
|
||||
pro: 'yellow',
|
||||
svip: 'red',
|
||||
premium: 'red',
|
||||
};
|
||||
|
||||
const groups = group.split(',').sort();
|
||||
@@ -97,12 +101,29 @@ export function getQuotaPerUnit() {
|
||||
return quotaPerUnit;
|
||||
}
|
||||
|
||||
export function renderUnitWithQuota(quota) {
|
||||
let quotaPerUnit = localStorage.getItem('quota_per_unit');
|
||||
quotaPerUnit = parseFloat(quotaPerUnit);
|
||||
quota = parseFloat(quota);
|
||||
return quotaPerUnit * quota;
|
||||
}
|
||||
|
||||
export function getQuotaWithUnit(quota, digits = 6) {
|
||||
let quotaPerUnit = localStorage.getItem('quota_per_unit');
|
||||
quotaPerUnit = parseFloat(quotaPerUnit);
|
||||
return (quota / quotaPerUnit).toFixed(digits);
|
||||
}
|
||||
|
||||
export function renderQuotaWithAmount(amount) {
|
||||
let displayInCurrency = localStorage.getItem('display_in_currency');
|
||||
displayInCurrency = displayInCurrency === 'true';
|
||||
if (displayInCurrency) {
|
||||
return '$' + amount;
|
||||
} else {
|
||||
return renderUnitWithQuota(amount);
|
||||
}
|
||||
}
|
||||
|
||||
export function renderQuota(quota, digits = 2) {
|
||||
let quotaPerUnit = localStorage.getItem('quota_per_unit');
|
||||
let displayInCurrency = localStorage.getItem('display_in_currency');
|
||||
|
||||
Reference in New Issue
Block a user