fix: 修复全量类型检查报错
- 收敛可选配置字段并补齐默认值,消除 strict 模式报错 - 补充页面脚本类型定义,移除未使用变量与隐式 any - 修复主题、表格、标签页等公共包类型边界
This commit is contained in:
@@ -92,7 +92,7 @@ function createRequestClient(baseURL: string, options?: RequestClientOptions) {
|
||||
client,
|
||||
doReAuthenticate,
|
||||
doRefreshToken,
|
||||
enableRefreshToken: preferences.app.enableRefreshToken,
|
||||
enableRefreshToken: preferences.app.enableRefreshToken ?? false,
|
||||
formatToken,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -22,7 +22,7 @@ async function generateAccess(options: GenerateMenuAndRoutesOptions) {
|
||||
IFrameView,
|
||||
};
|
||||
|
||||
return await generateAccessible(preferences.app.accessMode, {
|
||||
return await generateAccessible(preferences.app.accessMode ?? 'frontend', {
|
||||
...options,
|
||||
fetchMenuListAsync: async () => {
|
||||
ElMessage({
|
||||
|
||||
@@ -54,11 +54,9 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
if (accessStore.loginExpired) {
|
||||
accessStore.setLoginExpired(false);
|
||||
} else {
|
||||
onSuccess
|
||||
? await onSuccess?.()
|
||||
: await router.push(
|
||||
userInfo.homePath || preferences.app.defaultHomePath,
|
||||
);
|
||||
const homePath =
|
||||
userInfo.homePath || preferences.app.defaultHomePath || '/';
|
||||
onSuccess ? await onSuccess?.() : await router.push(homePath);
|
||||
}
|
||||
|
||||
if (userInfo?.nickname) {
|
||||
|
||||
@@ -8,7 +8,6 @@ import { useAppConfig } from '@easyflow/hooks';
|
||||
import { $t } from '@easyflow/locales';
|
||||
import { preferences } from '@easyflow/preferences';
|
||||
|
||||
import { api } from '#/api/request';
|
||||
import { useAuthStore } from '#/store';
|
||||
|
||||
defineOptions({ name: 'Login' });
|
||||
@@ -18,8 +17,6 @@ const authStore = useAuthStore();
|
||||
|
||||
const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
|
||||
|
||||
type PlatformType = 'ding_talk' | 'wx_web';
|
||||
|
||||
const title = computed(() => preferences.auth.welcomeBack);
|
||||
const subTitle = computed(() => preferences.auth.loginSubtitle);
|
||||
const formSchema = computed((): EasyFlowFormSchema[] => {
|
||||
@@ -91,14 +88,6 @@ function onSubmit(values: any) {
|
||||
console.error('初始化tac失败', error);
|
||||
});
|
||||
}
|
||||
|
||||
function getAuthUrl(platform: PlatformType) {
|
||||
return api.get('/thirdAuth/getAuthUrl', {
|
||||
params: {
|
||||
platform,
|
||||
},
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -29,6 +29,26 @@ import AddPluginModal from '#/views/ai/plugin/AddPluginModal.vue';
|
||||
import CategoryPluginModal from '#/views/ai/plugin/CategoryPluginModal.vue';
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
interface PluginCategory {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface PluginRecord {
|
||||
id: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
interface HeaderActionEvent {
|
||||
key?: string;
|
||||
}
|
||||
|
||||
interface CategoryFormData {
|
||||
id?: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
// 操作按钮配置
|
||||
const actions: ActionButton[] = [
|
||||
{
|
||||
@@ -74,12 +94,12 @@ const actions: ActionButton[] = [
|
||||
},
|
||||
},
|
||||
];
|
||||
const categoryList = ref([]);
|
||||
const categoryList = ref<PluginCategory[]>([]);
|
||||
const controlBtns = [
|
||||
{
|
||||
icon: Edit,
|
||||
label: $t('button.edit'),
|
||||
onClick(row) {
|
||||
onClick(row: PluginCategory) {
|
||||
formData.value.name = row.name;
|
||||
formData.value.id = row.id;
|
||||
isEdit.value = true;
|
||||
@@ -90,7 +110,7 @@ const controlBtns = [
|
||||
type: 'danger',
|
||||
icon: Delete,
|
||||
label: $t('button.delete'),
|
||||
onClick(row) {
|
||||
onClick(row: PluginCategory) {
|
||||
handleDeleteCategory(row);
|
||||
},
|
||||
},
|
||||
@@ -106,9 +126,12 @@ const footerButton = {
|
||||
const getPluginCategoryList = async () => {
|
||||
return api.get('/api/v1/pluginCategory/list').then((res) => {
|
||||
if (res.errorCode === 0) {
|
||||
const serverCategories = Array.isArray(res.data)
|
||||
? (res.data as PluginCategory[])
|
||||
: [];
|
||||
categoryList.value = [
|
||||
{ id: '0', name: $t('common.allCategories') },
|
||||
...res.data,
|
||||
...serverCategories,
|
||||
];
|
||||
}
|
||||
});
|
||||
@@ -116,7 +139,7 @@ const getPluginCategoryList = async () => {
|
||||
onMounted(() => {
|
||||
getPluginCategoryList();
|
||||
});
|
||||
const handleDelete = (item) => {
|
||||
const handleDelete = (item: PluginRecord) => {
|
||||
ElMessageBox.confirm($t('message.deleteAlert'), $t('message.noticeTitle'), {
|
||||
confirmButtonText: $t('message.ok'),
|
||||
cancelButtonText: $t('message.cancel'),
|
||||
@@ -148,7 +171,7 @@ const headerButtons = [
|
||||
const pluginCategoryId = ref('0');
|
||||
const dialogVisible = ref(false); // 弹窗显隐
|
||||
const isEdit = ref(false); // 是否为编辑模式
|
||||
const formData = ref({ name: '', id: '' });
|
||||
const formData = ref<CategoryFormData>({ name: '', id: '' });
|
||||
|
||||
const handleSubmit = () => {
|
||||
// 触发对应事件,传递表单数据
|
||||
@@ -160,7 +183,7 @@ const handleSubmit = () => {
|
||||
// 提交后关闭弹窗
|
||||
dialogVisible.value = false;
|
||||
};
|
||||
const handleButtonClick = (event, _item) => {
|
||||
const handleButtonClick = (event: HeaderActionEvent, _item: unknown) => {
|
||||
switch (event.key) {
|
||||
case 'add': {
|
||||
aiPluginModalRef.value.openDialog({});
|
||||
@@ -168,10 +191,10 @@ const handleButtonClick = (event, _item) => {
|
||||
}
|
||||
}
|
||||
};
|
||||
const handleSearch = (params) => {
|
||||
pageDataRef.value.setQuery({ title: params, isQueryOr: true });
|
||||
const handleSearch = (params?: string) => {
|
||||
pageDataRef.value.setQuery({ title: params ?? '', isQueryOr: true });
|
||||
};
|
||||
const handleEditCategory = (params) => {
|
||||
const handleEditCategory = (params: CategoryFormData) => {
|
||||
api
|
||||
.post('/api/v1/pluginCategory/update', {
|
||||
id: params.id,
|
||||
@@ -184,7 +207,7 @@ const handleEditCategory = (params) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
const handleAddCategory = (params) => {
|
||||
const handleAddCategory = (params: CategoryFormData) => {
|
||||
api.post('/api/v1/pluginCategory/save', { name: params.name }).then((res) => {
|
||||
if (res.errorCode === 0) {
|
||||
getPluginCategoryList();
|
||||
@@ -192,7 +215,7 @@ const handleAddCategory = (params) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
const handleDeleteCategory = (params) => {
|
||||
const handleDeleteCategory = (params: PluginCategory) => {
|
||||
api
|
||||
.get(`/api/v1/pluginCategory/doRemoveCategory?id=${params.id}`)
|
||||
.then((res) => {
|
||||
@@ -202,7 +225,7 @@ const handleDeleteCategory = (params) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
const handleClickCategory = (item) => {
|
||||
const handleClickCategory = (item: PluginCategory) => {
|
||||
pageDataRef.value.setQuery({ category: item.id });
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -29,6 +29,7 @@ const pageDataRef = ref();
|
||||
const saveDialog = ref();
|
||||
const formInline = ref({
|
||||
id: '',
|
||||
title: '',
|
||||
});
|
||||
function search(formEl: FormInstance | undefined) {
|
||||
formEl?.validate((valid) => {
|
||||
|
||||
@@ -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