fix(@vben/web-antdv-next): clean AI template refs and index typing

- remove unused AI template refs

- normalize document split and upload indexes
pull/369/head
XuZhiqiang 2026-06-20 23:55:39 +08:00
parent 22ba329ad3
commit 5a21adf5bf
5 changed files with 9 additions and 18 deletions

View File

@ -22,8 +22,6 @@ const document = ref<null | {
}[]; }[];
title: string; title: string;
}>(null); // }>(null); //
const dialogVisible = ref(false); //
const documentRef = ref<HTMLElement>(); // Ref
/** 按照 document 聚合 segments */ /** 按照 document 聚合 segments */
const documentList = computed(() => { const documentList = computed(() => {
@ -49,7 +47,6 @@ const documentList = computed(() => {
/** 点击 document 处理 */ /** 点击 document 处理 */
function handleClick(doc: any) { function handleClick(doc: any) {
document.value = doc; document.value = doc;
dialogVisible.value = true;
} }
</script> </script>
@ -79,7 +76,7 @@ function handleClick(doc: any) {
</div> </div>
</div> </div>
<Tooltip placement="topLeft" :trigger="['click']"> <Tooltip placement="topLeft" :trigger="['click']">
<div ref="documentRef"></div> <div></div>
<template #title> <template #title>
<div class="mb-3 text-base font-bold">{{ document?.title }}</div> <div class="mb-3 text-base font-bold">{{ document?.title }}</div>
<div class="max-h-[60vh] overflow-y-auto"> <div class="max-h-[60vh] overflow-y-auto">

View File

@ -19,8 +19,6 @@ const props = defineProps({
}); });
const emits = defineEmits(['onBtnClick', 'onMjBtnClick']); const emits = defineEmits(['onBtnClick', 'onMjBtnClick']);
const cardImageRef = ref<any>(); // image ref
/** 处理点击事件 */ /** 处理点击事件 */
async function handleButtonClick(type: string, detail: AiImageApi.Image) { async function handleButtonClick(type: string, detail: AiImageApi.Image) {
emits('onBtnClick', type, detail); emits('onBtnClick', type, detail);
@ -110,7 +108,7 @@ onMounted(async () => {
</div> </div>
<!-- 图片展示区域 --> <!-- 图片展示区域 -->
<div class="mt-5 h-72 flex-1 overflow-hidden" ref="cardImageRef"> <div class="mt-5 h-72 flex-1 overflow-hidden">
<Image class="w-full rounded-lg" :src="detail?.picUrl" /> <Image class="w-full rounded-lg" :src="detail?.picUrl" />
<div v-if="detail?.status === AiImageStatusEnum.FAIL"> <div v-if="detail?.status === AiImageStatusEnum.FAIL">
{{ detail?.errorMessage }} {{ detail?.errorMessage }}

View File

@ -33,7 +33,6 @@ const queryParams = reactive({
}); // }); //
const pageTotal = ref<number>(0); // page size const pageTotal = ref<number>(0); // page size
const imageList = ref<AiImageApi.Image[]>([]); // image const imageList = ref<AiImageApi.Image[]>([]); // image
const imageListRef = ref<any>(); // ref
const inProgressImageMap = ref<{}>({}); // image key image value image const inProgressImageMap = ref<{}>({}); // image key image value image
const inProgressTimer = ref<any>(); // image const inProgressTimer = ref<any>(); // image
@ -192,7 +191,6 @@ onUnmounted(async () => {
<div <div
class="flex flex-1 flex-wrap content-start overflow-y-auto p-3 pb-28 pt-5" class="flex flex-1 flex-wrap content-start overflow-y-auto p-3 pb-28 pt-5"
ref="imageListRef"
> >
<ImageCard <ImageCard
v-for="image in imageList" v-for="image in imageList"

View File

@ -44,8 +44,8 @@ const currentFile = ref<any>(null); // 当前选中的文件
const submitLoading = ref(false); // const submitLoading = ref(false); //
/** 选择文件 */ /** 选择文件 */
async function selectFile(index: number) { async function selectFile(index: number | string) {
currentFile.value = modelData.value.list[index]; currentFile.value = modelData.value.list[Number(index)];
await splitContentFile(currentFile.value); await splitContentFile(currentFile.value);
} }
@ -258,7 +258,8 @@ onMounted(async () => {
class="mb-2.5" class="mb-2.5"
> >
<div class="mb-1 text-sm text-gray-500"> <div class="mb-1 text-sm text-gray-500">
分片-{{ index + 1 }} · {{ segment.contentLength || 0 }} 字符数 · 分片-{{ Number(index) + 1 }} ·
{{ segment.contentLength || 0 }} 字符数 ·
{{ segment.tokens || 0 }} Token {{ segment.tokens || 0 }} Token
</div> </div>
<div class="rounded-md bg-card p-2"> <div class="rounded-md bg-card p-2">

View File

@ -22,8 +22,6 @@ const props = defineProps({
}); });
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
const formRef = ref(); //
const uploadRef = ref(); //
const parent = inject('parent', null); // const parent = inject('parent', null); //
const { uploadUrl, httpRequest } = useUpload(); // 使 const { uploadUrl, httpRequest } = useUpload(); // 使
const fileList = ref<UploadProps['fileList']>([]); // const fileList = ref<UploadProps['fileList']>([]); //
@ -147,10 +145,10 @@ async function customRequest(info: UploadRequestOption) {
* *
* @param index 要移除的文件索引 * @param index 要移除的文件索引
*/ */
function removeFile(index: number) { function removeFile(index: number | string) {
// //
const newList = [...props.modelValue.list]; const newList = [...props.modelValue.list];
newList.splice(index, 1); newList.splice(Number(index), 1);
// //
emit('update:modelValue', { emit('update:modelValue', {
...props.modelValue, ...props.modelValue,
@ -185,14 +183,13 @@ onMounted(() => {
</script> </script>
<template> <template>
<Form ref="formRef" :model="modelData" label-width="0" class="mt-5"> <Form :model="modelData" label-width="0" class="mt-5">
<FormItem class="mb-5"> <FormItem class="mb-5">
<div class="w-full"> <div class="w-full">
<div <div
class="w-full rounded-md border-2 border-dashed border-gray-200 p-5 text-center hover:border-blue-500" class="w-full rounded-md border-2 border-dashed border-gray-200 p-5 text-center hover:border-blue-500"
> >
<UploadDragger <UploadDragger
ref="uploadRef"
class="upload-demo" class="upload-demo"
:action="uploadUrl" :action="uploadUrl"
v-model:file-list="fileList" v-model:file-list="fileList"