fix: 修复全量类型检查报错
- 收敛可选配置字段并补齐默认值,消除 strict 模式报错 - 补充页面脚本类型定义,移除未使用变量与隐式 any - 修复主题、表格、标签页等公共包类型边界
This commit is contained in:
@@ -17,17 +17,47 @@ import {
|
||||
import { api } from '#/api/request.js';
|
||||
import providerList from '#/views/ai/model/modelUtils/providerList.json';
|
||||
|
||||
const providerOptions =
|
||||
ref<Array<{ label: string; options: any; value: string }>>(providerList);
|
||||
const brands = ref([]);
|
||||
const llmOptions = ref([]);
|
||||
interface ProviderOptionExtra {
|
||||
chatPath?: string;
|
||||
llmEndpoint?: string;
|
||||
}
|
||||
|
||||
interface ProviderOption {
|
||||
label: string;
|
||||
options?: ProviderOptionExtra;
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface ModelProvider {
|
||||
key: string;
|
||||
options?: ProviderOptionExtra;
|
||||
title: string;
|
||||
}
|
||||
|
||||
interface LlmOption {
|
||||
extra: Map<string, string | undefined>;
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface SettingsEntity {
|
||||
chatgpt_api_key: string;
|
||||
chatgpt_chatPath: string;
|
||||
chatgpt_endpoint: string;
|
||||
chatgpt_model_name: string;
|
||||
model_of_chat: string;
|
||||
}
|
||||
|
||||
const providerOptions = ref<ProviderOption[]>(providerList as ProviderOption[]);
|
||||
const brands = ref<ModelProvider[]>([]);
|
||||
const llmOptions = ref<LlmOption[]>([]);
|
||||
|
||||
// 获取品牌接口数据
|
||||
function getBrands() {
|
||||
api.get('/api/v1/modelProvider/list').then((res) => {
|
||||
if (res.errorCode === 0) {
|
||||
brands.value = res.data;
|
||||
llmOptions.value = formatLlmList(res.data);
|
||||
brands.value = (res.data ?? []) as ModelProvider[];
|
||||
llmOptions.value = formatLlmList(brands.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -47,7 +77,7 @@ onMounted(() => {
|
||||
getBrands();
|
||||
});
|
||||
|
||||
const entity = ref({
|
||||
const entity = ref<SettingsEntity>({
|
||||
model_of_chat: '',
|
||||
chatgpt_api_key: '',
|
||||
chatgpt_chatPath: '',
|
||||
@@ -55,7 +85,7 @@ const entity = ref({
|
||||
chatgpt_model_name: '',
|
||||
});
|
||||
|
||||
function formatLlmList(data) {
|
||||
function formatLlmList(data: ModelProvider[]): LlmOption[] {
|
||||
return data.map((item) => {
|
||||
const extra = new Map([
|
||||
['chatPath', item.options?.chatPath],
|
||||
@@ -68,10 +98,10 @@ function formatLlmList(data) {
|
||||
};
|
||||
});
|
||||
}
|
||||
function handleChangeModel(value) {
|
||||
function handleChangeModel(value: string) {
|
||||
const extra = providerList.find((item) => item.value === value);
|
||||
entity.value.chatgpt_chatPath = extra.options.chatPath;
|
||||
entity.value.chatgpt_endpoint = extra.options.llmEndpoint;
|
||||
entity.value.chatgpt_chatPath = extra?.options?.chatPath ?? '';
|
||||
entity.value.chatgpt_endpoint = extra?.options?.llmEndpoint ?? '';
|
||||
}
|
||||
function handleSave() {
|
||||
api.post('/api/v1/sysOption/save', entity.value).then((res) => {
|
||||
|
||||
Reference in New Issue
Block a user