Changes: - Add monitor center page with KPI cards, charts and request logs - Implement channel stats, failure analysis, model distribution visualization - Support time range filtering (last 1/6/24 hours) - Add model disable feature with related hooks and state management - Optimize request logs list performance with virtual scrolling - Improve mobile styles and table scrolling experience - Add i18n support for Chinese and English Modified files: - src/pages/MonitorPage.tsx (added) - src/components/monitor/* (added, 10 components) - src/hooks/useDisableModel.ts (added) - src/utils/monitor.ts (added) - src/i18n/locales/*.json (modified) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
/**
|
|
* 禁用模型状态管理
|
|
* 全局管理已禁用的模型,确保所有组件状态同步
|
|
*/
|
|
|
|
import { create } from 'zustand';
|
|
|
|
interface DisabledModelsState {
|
|
/** 已禁用的模型集合,格式:`${source}|||${model}` */
|
|
disabledModels: Set<string>;
|
|
/** 添加禁用模型 */
|
|
addDisabledModel: (source: string, model: string) => void;
|
|
/** 移除禁用模型(恢复) */
|
|
removeDisabledModel: (source: string, model: string) => void;
|
|
/** 检查模型是否已禁用 */
|
|
isDisabled: (source: string, model: string) => boolean;
|
|
/** 清空所有禁用状态 */
|
|
clearAll: () => void;
|
|
}
|
|
|
|
export const useDisabledModelsStore = create<DisabledModelsState>()((set, get) => ({
|
|
disabledModels: new Set<string>(),
|
|
|
|
addDisabledModel: (source, model) => {
|
|
const key = `${source}|||${model}`;
|
|
set((state) => {
|
|
const newSet = new Set(state.disabledModels);
|
|
newSet.add(key);
|
|
return { disabledModels: newSet };
|
|
});
|
|
},
|
|
|
|
removeDisabledModel: (source, model) => {
|
|
const key = `${source}|||${model}`;
|
|
set((state) => {
|
|
const newSet = new Set(state.disabledModels);
|
|
newSet.delete(key);
|
|
return { disabledModels: newSet };
|
|
});
|
|
},
|
|
|
|
isDisabled: (source, model) => {
|
|
const key = `${source}|||${model}`;
|
|
return get().disabledModels.has(key);
|
|
},
|
|
|
|
clearAll: () => {
|
|
set({ disabledModels: new Set() });
|
|
},
|
|
}));
|