🎨 chore(web): apply ESLint and Prettier auto-fixes (baseline)

- Ran: bun run eslint:fix && bun run lint:fix
- Inserted AGPL license header via eslint-plugin-header
- Enforced no-multiple-empty-lines and other lint rules
- Formatted code using Prettier v3 (@so1ve/prettier-config)
- No functional changes; formatting-only baseline across JS/JSX files
This commit is contained in:
t0ng7u
2025-08-30 21:15:10 +08:00
parent 41cf516ec5
commit 0d57b1acd4
274 changed files with 11025 additions and 7659 deletions

View File

@@ -43,7 +43,7 @@ const LogsActions = ({
);
return (
<div className="flex flex-col md:flex-row justify-between items-start md:items-center gap-2 w-full">
<div className='flex flex-col md:flex-row justify-between items-start md:items-center gap-2 w-full'>
<Skeleton loading={needSkeleton} active placeholder={placeholder}>
<Space>
<Tag
@@ -92,4 +92,4 @@ const LogsActions = ({
);
};
export default LogsActions;
export default LogsActions;

View File

@@ -24,7 +24,7 @@ import {
Tag,
Tooltip,
Popover,
Typography
Typography,
} from '@douyinfe/semi-ui';
import {
timestamp2string,
@@ -38,7 +38,7 @@ import {
renderModelPriceSimple,
renderAudioModelPrice,
renderClaudeModelPrice,
renderModelPrice
renderModelPrice,
} from '../../../helpers';
import { IconHelpCircle } from '@douyinfe/semi-icons';
import { Route } from 'lucide-react';
@@ -181,7 +181,7 @@ function renderModelName(record, copyText, t) {
if (!modelMapped) {
return renderModelTag(record.model_name, {
onClick: (event) => {
copyText(event, record.model_name).then((r) => { });
copyText(event, record.model_name).then((r) => {});
},
});
} else {
@@ -198,7 +198,7 @@ function renderModelName(record, copyText, t) {
</Typography.Text>
{renderModelTag(record.model_name, {
onClick: (event) => {
copyText(event, record.model_name).then((r) => { });
copyText(event, record.model_name).then((r) => {});
},
})}
</div>
@@ -209,7 +209,7 @@ function renderModelName(record, copyText, t) {
{renderModelTag(other.upstream_model_name, {
onClick: (event) => {
copyText(event, other.upstream_model_name).then(
(r) => { },
(r) => {},
);
},
})}
@@ -220,7 +220,7 @@ function renderModelName(record, copyText, t) {
>
{renderModelTag(record.model_name, {
onClick: (event) => {
copyText(event, record.model_name).then((r) => { });
copyText(event, record.model_name).then((r) => {});
},
suffixIcon: (
<Route
@@ -264,7 +264,8 @@ export const getLogsColumns = ({
}
}
return isAdminUser && (record.type === 0 || record.type === 2 || record.type === 5) ? (
return isAdminUser &&
(record.type === 0 || record.type === 2 || record.type === 5) ? (
<Space>
<Tooltip content={record.channel_name || t('未知渠道')}>
<span>
@@ -456,10 +457,14 @@ export const getLogsColumns = ({
{
key: COLUMN_KEYS.IP,
title: (
<div className="flex items-center gap-1">
<div className='flex items-center gap-1'>
{t('IP')}
<Tooltip content={t('只有当用户设置开启IP记录时才会进行请求和错误类型日志的IP记录')}>
<IconHelpCircle className="text-gray-400 cursor-help" />
<Tooltip
content={t(
'只有当用户设置开启IP记录时才会进行请求和错误类型日志的IP记录',
)}
>
<IconHelpCircle className='text-gray-400 cursor-help' />
</Tooltip>
</div>
),
@@ -538,33 +543,33 @@ export const getLogsColumns = ({
}
let content = other?.claude
? renderModelPriceSimple(
other.model_ratio,
other.model_price,
other.group_ratio,
other?.user_group_ratio,
other.cache_tokens || 0,
other.cache_ratio || 1.0,
other.cache_creation_tokens || 0,
other.cache_creation_ratio || 1.0,
false,
1.0,
other?.is_system_prompt_overwritten,
'claude'
)
other.model_ratio,
other.model_price,
other.group_ratio,
other?.user_group_ratio,
other.cache_tokens || 0,
other.cache_ratio || 1.0,
other.cache_creation_tokens || 0,
other.cache_creation_ratio || 1.0,
false,
1.0,
other?.is_system_prompt_overwritten,
'claude',
)
: renderModelPriceSimple(
other.model_ratio,
other.model_price,
other.group_ratio,
other?.user_group_ratio,
other.cache_tokens || 0,
other.cache_ratio || 1.0,
0,
1.0,
false,
1.0,
other?.is_system_prompt_overwritten,
'openai'
);
other.model_ratio,
other.model_price,
other.group_ratio,
other?.user_group_ratio,
other.cache_tokens || 0,
other.cache_ratio || 1.0,
0,
1.0,
false,
1.0,
other?.is_system_prompt_overwritten,
'openai',
);
return (
<Typography.Paragraph
ellipsis={{
@@ -578,4 +583,4 @@ export const getLogsColumns = ({
},
},
];
};
};

View File

@@ -54,7 +54,7 @@ const LogsFilters = ({
placeholder={[t('开始时间'), t('结束时间')]}
showClear
pure
size="small"
size='small'
/>
</div>
@@ -65,7 +65,7 @@ const LogsFilters = ({
placeholder={t('令牌名称')}
showClear
pure
size="small"
size='small'
/>
<Form.Input
@@ -74,7 +74,7 @@ const LogsFilters = ({
placeholder={t('模型名称')}
showClear
pure
size="small"
size='small'
/>
<Form.Input
@@ -83,7 +83,7 @@ const LogsFilters = ({
placeholder={t('分组')}
showClear
pure
size="small"
size='small'
/>
{isAdminUser && (
@@ -94,7 +94,7 @@ const LogsFilters = ({
placeholder={t('渠道 ID')}
showClear
pure
size="small"
size='small'
/>
<Form.Input
field='username'
@@ -102,7 +102,7 @@ const LogsFilters = ({
placeholder={t('用户名称')}
showClear
pure
size="small"
size='small'
/>
</>
)}
@@ -124,26 +124,14 @@ const LogsFilters = ({
refresh();
}, 0);
}}
size="small"
size='small'
>
<Form.Select.Option value='0'>
{t('全部')}
</Form.Select.Option>
<Form.Select.Option value='1'>
{t('充值')}
</Form.Select.Option>
<Form.Select.Option value='2'>
{t('消费')}
</Form.Select.Option>
<Form.Select.Option value='3'>
{t('管理')}
</Form.Select.Option>
<Form.Select.Option value='4'>
{t('系统')}
</Form.Select.Option>
<Form.Select.Option value='5'>
{t('错误')}
</Form.Select.Option>
<Form.Select.Option value='0'>{t('全部')}</Form.Select.Option>
<Form.Select.Option value='1'>{t('充值')}</Form.Select.Option>
<Form.Select.Option value='2'>{t('消费')}</Form.Select.Option>
<Form.Select.Option value='3'>{t('管理')}</Form.Select.Option>
<Form.Select.Option value='4'>{t('系统')}</Form.Select.Option>
<Form.Select.Option value='5'>{t('错误')}</Form.Select.Option>
</Form.Select>
</div>
@@ -152,7 +140,7 @@ const LogsFilters = ({
type='tertiary'
htmlType='submit'
loading={loading}
size="small"
size='small'
>
{t('查询')}
</Button>
@@ -167,14 +155,14 @@ const LogsFilters = ({
}, 100);
}
}}
size="small"
size='small'
>
{t('重置')}
</Button>
<Button
type='tertiary'
onClick={() => setShowColumnSelector(true)}
size="small"
size='small'
>
{t('列设置')}
</Button>
@@ -185,4 +173,4 @@ const LogsFilters = ({
);
};
export default LogsFilters;
export default LogsFilters;

View File

@@ -55,13 +55,7 @@ const LogsTable = (logsData) => {
showUserInfoFunc,
isAdminUser,
});
}, [
t,
COLUMN_KEYS,
copyText,
showUserInfoFunc,
isAdminUser,
]);
}, [t, COLUMN_KEYS, copyText, showUserInfoFunc, isAdminUser]);
// Filter columns based on visibility settings
const getVisibleColumns = () => {
@@ -99,9 +93,7 @@ const LogsTable = (logsData) => {
size='middle'
empty={
<Empty
image={
<IllustrationNoResult style={{ width: 150, height: 150 }} />
}
image={<IllustrationNoResult style={{ width: 150, height: 150 }} />}
darkModeImage={
<IllustrationNoResultDark style={{ width: 150, height: 150 }} />
}
@@ -125,4 +117,4 @@ const LogsTable = (logsData) => {
);
};
export default LogsTable;
export default LogsTable;

View File

@@ -40,7 +40,7 @@ const LogsPage = () => {
{/* Main Content */}
<CardPro
type="type2"
type='type2'
statsArea={<LogsActions {...logsData} />}
searchArea={<LogsFilters {...logsData} />}
paginationArea={createCardProPagination({
@@ -60,4 +60,4 @@ const LogsPage = () => {
);
};
export default LogsPage;
export default LogsPage;

View File

@@ -49,10 +49,8 @@ const ColumnSelectorModal = ({
visible={showColumnSelector}
onCancel={() => setShowColumnSelector(false)}
footer={
<div className="flex justify-end">
<Button onClick={() => initDefaultColumns()}>
{t('重置')}
</Button>
<div className='flex justify-end'>
<Button onClick={() => initDefaultColumns()}>{t('重置')}</Button>
<Button onClick={() => setShowColumnSelector(false)}>
{t('取消')}
</Button>
@@ -75,7 +73,7 @@ const ColumnSelectorModal = ({
</Checkbox>
</div>
<div
className="flex flex-wrap max-h-96 overflow-y-auto rounded-lg p-4"
className='flex flex-wrap max-h-96 overflow-y-auto rounded-lg p-4'
style={{ border: '1px solid var(--semi-color-border)' }}
>
{allColumns.map((column) => {
@@ -90,7 +88,7 @@ const ColumnSelectorModal = ({
}
return (
<div key={column.key} className="w-1/2 mb-4 pr-2">
<div key={column.key} className='w-1/2 mb-4 pr-2'>
<Checkbox
checked={!!visibleColumns[column.key]}
onChange={(e) =>
@@ -107,4 +105,4 @@ const ColumnSelectorModal = ({
);
};
export default ColumnSelectorModal;
export default ColumnSelectorModal;

View File

@@ -28,7 +28,7 @@ const UserInfoModal = ({
t,
}) => {
const infoItemStyle = {
marginBottom: '16px'
marginBottom: '16px',
};
const labelStyle = {
@@ -37,7 +37,7 @@ const UserInfoModal = ({
marginBottom: '2px',
fontSize: '12px',
color: 'var(--semi-color-text-2)',
gap: '6px'
gap: '6px',
};
const renderLabel = (text, type = 'tertiary') => (
@@ -50,19 +50,19 @@ const UserInfoModal = ({
const valueStyle = {
fontSize: '14px',
fontWeight: '600',
color: 'var(--semi-color-text-0)'
color: 'var(--semi-color-text-0)',
};
const rowStyle = {
display: 'flex',
justifyContent: 'space-between',
marginBottom: '16px',
gap: '20px'
gap: '20px',
};
const colStyle = {
flex: 1,
minWidth: 0
minWidth: 0,
};
return (
@@ -100,7 +100,9 @@ const UserInfoModal = ({
</div>
<div style={colStyle}>
{renderLabel(t('已用额度'), 'warning')}
<div style={valueStyle}>{renderQuota(userInfoData.used_quota)}</div>
<div style={valueStyle}>
{renderQuota(userInfoData.used_quota)}
</div>
</div>
</div>
@@ -108,7 +110,9 @@ const UserInfoModal = ({
<div style={rowStyle}>
<div style={colStyle}>
{renderLabel(t('请求次数'), 'warning')}
<div style={valueStyle}>{renderNumber(userInfoData.request_count)}</div>
<div style={valueStyle}>
{renderNumber(userInfoData.request_count)}
</div>
</div>
{userInfoData.group && (
<div style={colStyle}>
@@ -130,25 +134,38 @@ const UserInfoModal = ({
{userInfoData.aff_count !== undefined && (
<div style={colStyle}>
{renderLabel(t('邀请人数'), 'tertiary')}
<div style={valueStyle}>{renderNumber(userInfoData.aff_count)}</div>
<div style={valueStyle}>
{renderNumber(userInfoData.aff_count)}
</div>
</div>
)}
</div>
)}
{/* 邀请获得额度 */}
{userInfoData.aff_quota !== undefined && userInfoData.aff_quota > 0 && (
<div style={infoItemStyle}>
{renderLabel(t('邀请获得额度'), 'success')}
<div style={valueStyle}>{renderQuota(userInfoData.aff_quota)}</div>
</div>
)}
{userInfoData.aff_quota !== undefined &&
userInfoData.aff_quota > 0 && (
<div style={infoItemStyle}>
{renderLabel(t('邀请获得额度'), 'success')}
<div style={valueStyle}>
{renderQuota(userInfoData.aff_quota)}
</div>
</div>
)}
{/* 备注 */}
{userInfoData.remark && (
<div style={{ marginBottom: 0 }}>
{renderLabel(t('备注'), 'tertiary')}
<div style={{ ...valueStyle, wordBreak: 'break-all', lineHeight: '1.4' }}>{userInfoData.remark}</div>
<div
style={{
...valueStyle,
wordBreak: 'break-all',
lineHeight: '1.4',
}}
>
{userInfoData.remark}
</div>
</div>
)}
</div>
@@ -157,4 +174,4 @@ const UserInfoModal = ({
);
};
export default UserInfoModal;
export default UserInfoModal;