@@ -172,7 +195,8 @@ import {
InfoCircleOutlined,
SettingOutlined,
DownCircleOutlined,
- LoadingOutlined
+ LoadingOutlined,
+ SearchOutlined
} from '@ant-design/icons-vue';
import { useConfigStore } from '@/stores/config';
import { modelIcons } from '@/utils/modelIcon';
@@ -204,6 +228,7 @@ const providerConfig = reactive({
allModels: [], // 所有可用的模型
selectedModels: [], // 用户选择的模型
loading: false,
+ searchQuery: '',
});
// 筛选 modelStatus 中为真的key
@@ -314,6 +339,18 @@ const toggleExpand = (item) => {
expandedModels[item] = !expandedModels[item];
};
+// 处理模型选择
+const handleModelSelect = (modelId, checked) => {
+ const selectedModels = providerConfig.selectedModels;
+ const index = selectedModels.indexOf(modelId);
+
+ if (checked && index === -1) {
+ selectedModels.push(modelId);
+ } else if (!checked && index > -1) {
+ selectedModels.splice(index, 1);
+ }
+};
+
// 打开提供商配置
const openProviderConfig = (provider) => {
providerConfig.provider = provider;
@@ -321,6 +358,7 @@ const openProviderConfig = (provider) => {
providerConfig.allModels = [];
providerConfig.visible = true;
providerConfig.loading = true;
+ providerConfig.searchQuery = ''; // 重置搜索关键词
// 获取当前选择的模型作为初始选中值
const currentModels = modelNames.value[provider]?.models || [];
@@ -396,6 +434,13 @@ const saveProviderConfig = async () => {
const cancelProviderConfig = () => {
providerConfig.visible = false;
};
+
+// 计算筛选后的模型列表
+const filteredModels = computed(() => {
+ const allModels = providerConfig.allModels || [];
+ const searchQuery = providerConfig.searchQuery.toLowerCase();
+ return allModels.filter(model => model.id.toLowerCase().includes(searchQuery));
+});