feat: 1.统一右侧抽屉关闭按钮布局 2.统一 UI 组件为 Ant Design 移除 radix-ui、floating-ui 组件 3. 修复 ESLint 文件格式错误的问题

This commit is contained in:
zhanjunhao
2026-11-10 14:08:10 +08:00
parent 28e924e371
commit 584728590b
202 changed files with 29195 additions and 12732 deletions
@@ -60,7 +60,6 @@ const ChannelsTable = (channelsData) => {
setCurrentMultiKeyChannel,
// Auto-ban exclusion
isChannelExcluded,
excludedChannels,
autoBanExclusionFilter,
// Daily quota info
dailyQuotaInfo,
@@ -127,7 +126,7 @@ const ChannelsTable = (channelsData) => {
return channel;
})
.filter(Boolean);
}, [channels, autoBanExclusionFilter, isChannelExcluded, excludedChannels]);
}, [channels, autoBanExclusionFilter, isChannelExcluded]);
// Get all columns
const allColumns = useMemo(() => {
@@ -175,7 +174,6 @@ const ChannelsTable = (channelsData) => {
setShowMultiKeyManageModal,
setCurrentMultiKeyChannel,
isChannelExcluded,
excludedChannels,
dailyQuotaInfo,
]);
@@ -184,9 +182,7 @@ const ChannelsTable = (channelsData) => {
return allColumns.filter((column) => visibleColumns[column.key]);
};
const visibleColumnsList = useMemo(() => {
return getVisibleColumns();
}, [visibleColumns, allColumns]);
const visibleColumnsList = getVisibleColumns();
const tableColumns = useMemo(() => {
const sortableColumns = visibleColumnsList.map((column) =>
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import '../../../console/module-alignment.css';
import React, { useEffect, useState, useRef, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -964,7 +965,7 @@ const EditChannelModal = (props) => {
setModelOptions(optionsWithIcon);
}, [originModelOptions, inputs.models, t]);
useEffect(() => {
const onScopeChange = useEffectEvent(() => {
fetchModels().then();
fetchGroups().then();
if (!isEdit) {
@@ -977,7 +978,8 @@ const EditChannelModal = (props) => {
setBasicModels(localModels);
setInputs((inputs) => ({ ...inputs, models: localModels }));
}
}, [props.editingChannel.id]);
});
useEffect(() => onScopeChange(), [onScopeChange, props.editingChannel.id]);
useEffect(() => {
if (formApiRef.current) {
@@ -985,7 +987,7 @@ const EditChannelModal = (props) => {
}
}, [inputs]);
useEffect(() => {
const onVisibilityChange2 = useEffectEvent(() => {
if (props.visible) {
if (isEdit) {
loadChannel();
@@ -1004,7 +1006,11 @@ const EditChannelModal = (props) => {
// 关闭后作废在途的兜底数据请求
fallbackLoadSeqRef.current += 1;
}
}, [props.visible, channelId]);
});
useEffect(
() => onVisibilityChange2(),
[onVisibilityChange2, props.visible, channelId],
);
useEffect(() => {
if (!isEdit) {
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useState, useEffect, useRef } from 'react';
import {
API,
@@ -270,7 +271,7 @@ const EditTagModal = (props) => {
setModelOptions(localModelOptions);
}, [originModelOptions, inputs.models]);
useEffect(() => {
const onVisibilityChange = useEffectEvent(() => {
const fetchTagModels = async () => {
if (!tag) return;
setLoading(true);
@@ -305,7 +306,8 @@ const EditTagModal = (props) => {
tag: tag,
new_tag: tag,
});
}, [visible, tag]);
});
useEffect(() => onVisibilityChange(), [onVisibilityChange, visible, tag]);
useEffect(() => {
if (formApiRef.current) {
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import {
@@ -288,12 +289,16 @@ const MultiKeyManageModal = ({ visible, onCancel, channel, onRefresh }) => {
};
// Effect to load data when modal opens
useEffect(() => {
const onVisibilityChange = useEffectEvent(() => {
if (visible && channel?.id) {
setCurrentPage(1); // Reset to first page when opening
loadKeyStatus(1, pageSize);
}
}, [visible, channel?.id]);
});
useEffect(
() => onVisibilityChange(),
[onVisibilityChange, visible, channel?.id],
);
// Reset pagination when modal closes
useEffect(() => {
@@ -130,7 +130,9 @@ function renderType(type, t) {
);
case 'UPLOAD':
return (
<Tag color='blue' shape='circle' prefixIcon={<Upload size={14} />}>{t('上传文件')}</Tag>
<Tag color='blue' shape='circle' prefixIcon={<Upload size={14} />}>
{t('上传文件')}
</Tag>
);
case 'SHORTEN':
return (
@@ -404,9 +406,7 @@ export const getMjLogsColumns = ({
{
<Progress
stroke={
record.status === 'FAILURE'
? 'var(--ui-color-warning)'
: null
record.status === 'FAILURE' ? 'var(--ui-color-warning)' : null
}
percent={text ? parseInt(text.replace('%', '')) : 0}
showInfo={true}
+1 -3
View File
@@ -58,9 +58,7 @@ const MjLogsTable = (mjLogsData) => {
return allColumns.filter((column) => visibleColumns[column.key]);
};
const visibleColumnsList = useMemo(() => {
return getVisibleColumns();
}, [visibleColumns, allColumns]);
const visibleColumnsList = getVisibleColumns();
return (
<CardTable
@@ -17,16 +17,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../hooks/common/useEffectEvent';
import React, { useState, useEffect } from 'react';
import {
Card,
Row,
Col,
Typography,
Tag,
Spin,
Empty,
} from '@/components/ui';
import { Card, Row, Col, Typography, Tag, Spin, Empty } from '@/components/ui';
import { API, showError } from '../../../helpers';
import { MODEL_CATEGORY_NAMES } from '../../../constants';
@@ -53,9 +46,10 @@ const ModelsCategoryStats = ({ t }) => {
setLoading(false);
};
useEffect(() => {
const onMount = useEffectEvent(() => {
loadStats();
}, []);
});
useEffect(() => onMount(), [onMount]);
const getCategoryColor = (category) => {
const colorMap = {
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useState, useEffect } from 'react';
import { Modal, Select, Typography, Spin } from '@/components/ui';
import { API, showError } from '../../../../helpers';
@@ -66,11 +67,12 @@ const BatchCategoryModal = ({
};
// 当弹窗打开时加载分类
useEffect(() => {
const onVisibilityChange = useEffectEvent(() => {
if (visible) {
loadCategories();
}
}, [visible]);
});
useEffect(() => onVisibilityChange(), [onVisibilityChange, visible]);
const handleConfirm = async () => {
if (selectedCategories.length === 0) return;
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import '../../../console/module-alignment.css';
import React, { useState, useEffect, useRef } from 'react';
import JSONEditor from '../../../common/ui/JSONEditor';
@@ -228,7 +229,7 @@ const EditModelModal = (props) => {
setLoading(false);
};
useEffect(() => {
const onScopeChange = useEffectEvent(() => {
if (formApiRef.current) {
if (!isEdit) {
formApiRef.current.setValues({
@@ -237,9 +238,13 @@ const EditModelModal = (props) => {
});
}
}
}, [props.editingModel?.id, props.editingModel?.model_name]);
});
useEffect(
() => onScopeChange(),
[onScopeChange, props.editingModel?.id, props.editingModel?.model_name],
);
useEffect(() => {
const onVisibilityChange2 = useEffectEvent(() => {
if (props.visiable) {
if (isEdit) {
loadModel();
@@ -252,7 +257,16 @@ const EditModelModal = (props) => {
} else {
formApiRef.current?.reset();
}
}, [props.visiable, props.editingModel?.id, props.editingModel?.model_name]);
});
useEffect(
() => onVisibilityChange2(),
[
onVisibilityChange2,
props.visiable,
props.editingModel?.id,
props.editingModel?.model_name,
],
);
const submit = async (values) => {
setLoading(true);
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useState, useRef, useEffect } from 'react';
import { Modal, Form, Col, Row } from '@/components/ui';
import { API, showError, showSuccess } from '../../../../helpers';
@@ -67,7 +68,7 @@ const EditVendorModal = ({ visible, handleClose, refresh, editingVendor }) => {
setLoading(false);
};
useEffect(() => {
const onVisibilityChange = useEffectEvent(() => {
if (visible) {
if (isEdit) {
loadVendor();
@@ -77,7 +78,11 @@ const EditVendorModal = ({ visible, handleClose, refresh, editingVendor }) => {
} else {
formApiRef.current?.reset();
}
}, [visible, editingVendor?.id]);
});
useEffect(
() => onVisibilityChange(),
[onVisibilityChange, visible, editingVendor?.id],
);
const submit = async (values) => {
setLoading(true);
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useEffect, useState } from 'react';
import {
Modal,
@@ -59,7 +60,7 @@ const MissingModelsModal = ({ visible, onClose, onConfigureModel, t }) => {
setLoading(false);
};
useEffect(() => {
const onVisibilityChange = useEffectEvent(() => {
if (visible) {
fetchMissing();
setSearchKeyword('');
@@ -67,7 +68,8 @@ const MissingModelsModal = ({ visible, onClose, onConfigureModel, t }) => {
} else {
setMissingModels([]);
}
}, [visible]);
});
useEffect(() => onVisibilityChange(), [onVisibilityChange, visible]);
// 过滤和分页逻辑
const filteredModels = missingModels.filter((model) =>
@@ -238,14 +238,7 @@ const UpstreamConflictModal = ({
});
return [...base, ...cols.filter(Boolean)];
}, [
t,
selections,
filteredDataSource,
getHeaderState,
applyHeaderChange,
toggleField,
]);
}, [t, selections, getHeaderState, applyHeaderChange, toggleField]);
const pagedDataSource = useMemo(() => {
const start = (currentPage - 1) * paginationSize;
@@ -57,19 +57,7 @@ const RedemptionsTable = (redemptionsData) => {
};
// Get all columns
const columns = useMemo(() => {
return getRedemptionsColumns({
t,
manageRedemption,
copyText,
setEditingRedemption,
setShowEdit,
refresh,
redemptions,
activePage,
showDeleteRedemptionModal,
});
}, [
const columns = getRedemptionsColumns({
t,
manageRedemption,
copyText,
@@ -79,7 +67,7 @@ const RedemptionsTable = (redemptionsData) => {
redemptions,
activePage,
showDeleteRedemptionModal,
]);
});
// Handle compact mode by removing fixed positioning
const tableColumns = useMemo(() => {
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useEffect, useState, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import {
@@ -87,7 +88,7 @@ const EditRedemptionModal = (props) => {
setLoading(false);
};
useEffect(() => {
const onScopeChange = useEffectEvent(() => {
if (formApiRef.current) {
if (isEdit) {
loadRedemption();
@@ -95,7 +96,8 @@ const EditRedemptionModal = (props) => {
formApiRef.current.setValues(getInitValues());
}
}
}, [props.editingRedemption.id]);
});
useEffect(() => onScopeChange(), [onScopeChange, props.editingRedemption.id]);
const submit = async (values) => {
let name = values.name;
@@ -72,9 +72,7 @@ const TaskLogsTable = (taskLogsData) => {
return allColumns.filter((column) => visibleColumns[column.key]);
};
const visibleColumnsList = useMemo(() => {
return getVisibleColumns();
}, [visibleColumns, allColumns]);
const visibleColumnsList = getVisibleColumns();
const tableColumns = useMemo(() => {
return compactMode
+17 -17
View File
@@ -17,14 +17,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../hooks/common/useEffectEvent';
import React, { useEffect, useRef, useState } from 'react';
import {
Notification,
Button,
Space,
Toast,
Select,
} from '@/components/ui';
import { Notification, Button, Space, Toast, Select } from '@/components/ui';
import {
API,
showError,
@@ -51,14 +46,18 @@ function TokensPage({ labelReplace } = {}) {
// Create a wrapped translation function that replaces labels if needed
const originalT = tokensData.t;
const t = labelReplace
? (key, options) => {
const result = originalT(key, options);
return typeof result === 'string'
? result.replace(/密钥/g, labelReplace)
: result;
}
: originalT;
const t = React.useMemo(
() =>
labelReplace
? (key, options) => {
const result = originalT(key, options);
return typeof result === 'string'
? result.replace(/密钥/g, labelReplace)
: result;
}
: originalT,
[originalT, labelReplace],
);
const latestRef = useRef({
tokens: [],
@@ -256,7 +255,7 @@ function TokensPage({ labelReplace } = {}) {
};
// Show notification when Fluent container is available
useEffect(() => {
const onMount = useEffectEvent(() => {
const onAppeared = () => {
openFluentNotification();
};
@@ -271,7 +270,8 @@ function TokensPage({ labelReplace } = {}) {
window.removeEventListener('fluent-container:appeared', onAppeared);
window.removeEventListener('fluent-container:removed', onRemoved);
};
}, []);
});
useEffect(() => onMount(), [onMount]);
// When modelOptions or language changes while the notice is open, refresh the content
useEffect(() => {
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useEffect, useState, useContext, useRef } from 'react';
import {
API,
@@ -277,7 +278,7 @@ const EditTokenModal = (props) => {
setLoading(false);
};
useEffect(() => {
const onScopeChange = useEffectEvent(() => {
if (formApiRef.current) {
if (!isEdit) {
formApiRef.current.setValues(getInitValues());
@@ -286,9 +287,10 @@ const EditTokenModal = (props) => {
loadModels();
loadGroups();
loadSkillOptions();
}, [props.editingToken.id]);
});
useEffect(() => onScopeChange(), [onScopeChange, props.editingToken.id]);
useEffect(() => {
const onVisibilityChange2 = useEffectEvent(() => {
if (props.visiable) {
if (isEdit) {
loadToken();
@@ -308,7 +310,11 @@ const EditTokenModal = (props) => {
setNeverExpire(true);
setExpireDate(null);
}
}, [props.visiable, props.editingToken.id]);
});
useEffect(
() => onVisibilityChange2(),
[onVisibilityChange2, props.visiable, props.editingToken.id],
);
const generateRandomSuffix = () => {
const characters =
+9 -22
View File
@@ -125,31 +125,18 @@ const UsersTable = (usersData) => {
};
// Get all columns
const columns = useMemo(() => {
return getUsersColumns({
t,
setEditingUser,
setShowEditUser,
showPromoteModal: showPromoteUserModal,
showDemoteModal: showDemoteUserModal,
showEnableDisableModal: showEnableDisableUserModal,
showDeleteModal: showDeleteUserModal,
showResetPasskeyModal: showResetPasskeyUserModal,
showResetTwoFAModal: showResetTwoFAUserModal,
showInvitedUsersModal: showInvitedUsersUserModal,
});
}, [
const columns = getUsersColumns({
t,
setEditingUser,
setShowEditUser,
showPromoteUserModal,
showDemoteUserModal,
showEnableDisableUserModal,
showDeleteUserModal,
showResetPasskeyUserModal,
showResetTwoFAUserModal,
showInvitedUsersUserModal,
]);
showPromoteModal: showPromoteUserModal,
showDemoteModal: showDemoteUserModal,
showEnableDisableModal: showEnableDisableUserModal,
showDeleteModal: showDeleteUserModal,
showResetPasskeyModal: showResetPasskeyUserModal,
showResetTwoFAModal: showResetTwoFAUserModal,
showInvitedUsersModal: showInvitedUsersUserModal,
});
// Handle compact mode by removing fixed positioning
const tableColumns = useMemo(() => {
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useEffect, useState, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { API, showError, showSuccess, renderQuota } from '../../../../helpers';
@@ -122,13 +123,14 @@ const EditUserModal = (props) => {
setLoading(false);
};
useEffect(() => {
const onScopeChange = useEffectEvent(() => {
loadUser();
if (userId) {
fetchGroups();
fetchLevels();
}
}, [props.editingUser.id]);
});
useEffect(() => onScopeChange(), [onScopeChange, props.editingUser.id]);
/* ----------------------- submit ----------------------- */
const submit = async (values) => {
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../../../hooks/common/useEffectEvent';
import React, { useState, useEffect } from 'react';
import { Modal, Table, Tag, Spin } from '@/components/ui';
import { API, renderQuota, renderNumber, showError } from '../../../../helpers';
@@ -27,11 +28,12 @@ const InvitedUsersModal = ({ visible, onCancel, user, t }) => {
const [loading, setLoading] = useState(false);
const [total, setTotal] = useState(0);
useEffect(() => {
const onVisibilityChange = useEffectEvent(() => {
if (visible && user) {
fetchInvitedUsers();
}
}, [visible, user]);
});
useEffect(() => onVisibilityChange(), [onVisibilityChange, visible, user]);
const fetchInvitedUsers = async () => {
if (!user?.id) return;