fix: 修复全量类型检查报错
- 收敛可选配置字段并补齐默认值,消除 strict 模式报错 - 补充页面脚本类型定义,移除未使用变量与隐式 any - 修复主题、表格、标签页等公共包类型边界
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user