feat: 自行开发设计 ui样式优化 超管端-控制台 相关的页面

This commit is contained in:
zhanjunhao
2026-11-09 21:45:37 +08:00
parent 9fc5fd212d
commit 28e924e371
242 changed files with 9242 additions and 5043 deletions
+35 -19
View File
@@ -17,7 +17,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { useState, useEffect, useMemo } from 'react';
import { writeClipboardText } from '../../helpers/clipboard';
import { useState, useEffect, useMemo, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { API, showError, showSuccess } from '../../helpers';
import { ITEMS_PER_PAGE } from '../../constants';
@@ -92,6 +93,7 @@ export const useModelsData = () => {
// Vendor list
const [vendors, setVendors] = useState([]);
const [vendorCounts, setVendorCounts] = useState({});
const vendorCountsRequestRef = useRef(0);
const [activeVendorKey, setActiveVendorKey] = useState('all');
const [showAddVendor, setShowAddVendor] = useState(false);
const [showEditVendor, setShowEditVendor] = useState(false);
@@ -120,6 +122,33 @@ export const useModelsData = () => {
}
};
// Counts belong to the full catalog, independently of the visible vendor filter.
const loadVendorCounts = async () => {
const requestId = ++vendorCountsRequestRef.current;
try {
const res = await API.get('/api/models/?p=1&page_size=1', {
disableDuplicate: true,
});
const { success, data, message } = res.data;
if (requestId !== vendorCountsRequestRef.current) return;
if (!success) {
showError(message);
return;
}
if (data.vendor_counts) {
const all =
data.total ??
Object.values(data.vendor_counts).reduce(
(sum, value) => sum + Number(value || 0),
0,
);
setVendorCounts({ ...data.vendor_counts, all });
}
} catch (error) {
if (requestId === vendorCountsRequestRef.current) showError(error);
}
};
// Load models data
const loadModels = async (
page = 1,
@@ -141,14 +170,6 @@ export const useModelsData = () => {
setActivePage(data.page || page);
setModelCount(data.total || newPageData.length);
setModelFormat(newPageData);
if (data.vendor_counts) {
const sumAll = Object.values(data.vendor_counts).reduce(
(acc, v) => acc + v,
0,
);
setVendorCounts({ ...data.vendor_counts, all: sumAll });
}
} else {
showError(message);
setModels([]);
@@ -163,7 +184,7 @@ export const useModelsData = () => {
// Refresh data
const refresh = async (page = activePage) => {
await loadModels(page, pageSize);
await Promise.all([loadModels(page, pageSize), loadVendorCounts()]);
};
// Sync upstream models/vendors for missing models only
@@ -278,13 +299,6 @@ export const useModelsData = () => {
setActivePage(data.page || 1);
setModelCount(data.total || newPageData.length);
setModelFormat(newPageData);
if (data.vendor_counts) {
const sumAll = Object.values(data.vendor_counts).reduce(
(acc, v) => acc + v,
0,
);
setVendorCounts({ ...data.vendor_counts, all: sumAll });
}
} else {
showError(message);
setModels([]);
@@ -399,7 +413,8 @@ export const useModelsData = () => {
if (res.data.success) {
successCount++;
} else {
showError(`删除模型 ${selectedKeys[index].model_name} 失败: ${res.data.message}`,
showError(
`删除模型 ${selectedKeys[index].model_name} 失败: ${res.data.message}`,
);
}
});
@@ -447,7 +462,7 @@ export const useModelsData = () => {
// Copy text helper
const copyText = async (text) => {
try {
await navigator.clipboard.writeText(text);
await writeClipboardText(text);
showSuccess(t('复制成功'));
} catch (error) {
console.error('Copy failed:', error);
@@ -459,6 +474,7 @@ export const useModelsData = () => {
useEffect(() => {
(async () => {
await loadVendors();
await loadVendorCounts();
})();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);