Merge branch 'alpha' into feature/claude-code
# Conflicts: # web/src/components/table/channels/modals/EditChannelModal.jsx
This commit is contained in:
@@ -884,12 +884,22 @@ export function renderQuotaWithAmount(amount) {
|
||||
}
|
||||
|
||||
export function renderQuota(quota, digits = 2) {
|
||||
|
||||
let quotaPerUnit = localStorage.getItem('quota_per_unit');
|
||||
let displayInCurrency = localStorage.getItem('display_in_currency');
|
||||
quotaPerUnit = parseFloat(quotaPerUnit);
|
||||
displayInCurrency = displayInCurrency === 'true';
|
||||
if (displayInCurrency) {
|
||||
return '$' + (quota / quotaPerUnit).toFixed(digits);
|
||||
const result = quota / quotaPerUnit;
|
||||
const fixedResult = result.toFixed(digits);
|
||||
|
||||
// 如果 toFixed 后结果为 0 但原始值不为 0,显示最小值
|
||||
if (parseFloat(fixedResult) === 0 && quota > 0 && result > 0) {
|
||||
const minValue = Math.pow(10, -digits);
|
||||
return '$' + minValue.toFixed(digits);
|
||||
}
|
||||
|
||||
return '$' + fixedResult;
|
||||
}
|
||||
return renderNumber(quota);
|
||||
}
|
||||
|
||||
@@ -560,12 +560,16 @@ export function setTableCompactMode(compact, tableKey = 'global') {
|
||||
|
||||
// -------------------------------
|
||||
// Select 组件统一过滤逻辑
|
||||
// 解决 label 为 ReactNode(带图标等)时无法用内置 filter 搜索的问题。
|
||||
// 使用方式: <Select filter={modelSelectFilter} ... />
|
||||
export const modelSelectFilter = (input, option) => {
|
||||
// 使用方式: <Select filter={selectFilter} ... />
|
||||
// 统一的 Select 搜索过滤逻辑 -- 支持同时匹配 option.value 与 option.label
|
||||
export const selectFilter = (input, option) => {
|
||||
if (!input) return true;
|
||||
const val = (option?.value || '').toString().toLowerCase();
|
||||
return val.includes(input.trim().toLowerCase());
|
||||
|
||||
const keyword = input.trim().toLowerCase();
|
||||
const valueText = (option?.value ?? '').toString().toLowerCase();
|
||||
const labelText = (option?.label ?? '').toString().toLowerCase();
|
||||
|
||||
return valueText.includes(keyword) || labelText.includes(keyword);
|
||||
};
|
||||
|
||||
// -------------------------------
|
||||
|
||||
Reference in New Issue
Block a user