删除文件上传离开页面的提示信息

This commit is contained in:
2025-06-06 11:32:19 +08:00
parent 358e9ab745
commit 7009227806
4 changed files with 36 additions and 119 deletions
+1 -1
View File
@@ -81,7 +81,7 @@ export function Breadcrumb({ items = [], className = '' }: BreadcrumbProps) {
return ( return (
<nav className={finalClassName} aria-label="面包屑导航"> <nav className={finalClassName} aria-label="面包屑导航">
<ol className="flex items-center space-x-2 text-sm text-gray-500"> <ol className="flex items-center space-x-2 text-sm text-gray-500 mb-0">
<li> <li>
<Link to="/" className="hover:text-primary-600 flex items-center"> <Link to="/" className="hover:text-primary-600 flex items-center">
<i className="ri-home-line mr-1" /> <i className="ri-home-line mr-1" />
+2 -85
View File
@@ -720,7 +720,7 @@ export function ReviewPointsList({
if (rule.type === 'consistency') { if (rule.type === 'consistency') {
// if (rule.res === true && reviewPoint.result === true) { // if (rule.res === true && reviewPoint.result === true) {
return <div key={`rule-${index}`}> return <div key={`rule-${index}`}>
<div key="line" className=" bg-gray-50 rounded border border-gray-200 text-xs mb-3"></div> {otherRules.length > 0 && <div key="line" className=" bg-gray-50 rounded border border-gray-200 text-xs mb-3"></div>}
{renderConsistencyRule(rule, reviewPoint)} {renderConsistencyRule(rule, reviewPoint)}
</div>; </div>;
// }else { // }else {
@@ -730,94 +730,11 @@ export function ReviewPointsList({
if (rule.type === 'ai') { if (rule.type === 'ai') {
return <div key={`rule-${index}`}> return <div key={`rule-${index}`}>
<div key="line" className=" bg-gray-50 rounded border border-gray-200 text-xs mb-3"></div> {otherRules.length > 0 && <div key="line" className=" bg-gray-50 rounded border border-gray-200 text-xs mb-3"></div>}
{renderModelRule(rule, reviewPoint)} {renderModelRule(rule, reviewPoint)}
</div>; </div>;
} }
// return (
// <>
// {/* 渲染组内内容 */}
// {entries.map(([key, value], index) =>
// !(result && value.value?.toString().trim() == '') && (
// <div
// key={`${groupKey}_${index}`}
// className="mb-2 pb-2 border-b border-gray-100 last:border-b-0 last:mb-0 cursor-pointer hover:bg-gray-100 transition-colors duration-200 rounded p-1 group"
// onClick={(e) => {
// e.stopPropagation();
// console.log(`单独点击${key}----`, reviewPoint);
// const valuePage = parseInt(value.page as string);
// const contentPage = parseInt(reviewPoint.contentPage?.[key] as string);
// // 检查value中的page属性是否存在,优先取value中的page
// if (valuePage > 0) {
// console.log(`存在page且不为空:单独点击${key}---------->evaluated_results内的页码:`, valuePage);
// onReviewPointSelect(reviewPoint.id, valuePage);
// } else if(contentPage && contentPage > 0) {
// console.log(`存在page且为空:单独点击${key}---------->ocr_result内的页码:`, contentPage);
// onReviewPointSelect(reviewPoint.id, contentPage);
// }else {
// toastService.error(`无法找到"${key}"对应的索引内容`);
// console.log(`单独点击${key}--------没有对应页码`);
// }
// }}
// onKeyDown={(e) => {
// if (e.key === 'Enter' || e.key === ' ') {
// e.preventDefault();
// const valuePage = parseInt(value.page as string);
// const contentPage = parseInt(reviewPoint.contentPage?.[key] as string);
// // 检查value中的page属性是否存在,优先取value中的page
// if (valuePage > 0) {
// onReviewPointSelect(reviewPoint.id, valuePage);
// } else if(contentPage && contentPage > 0) {
// onReviewPointSelect(reviewPoint.id, contentPage);
// } else {
// toastService.error(`无法找到"${key}"对应的索引内容`);
// console.log(`单独点击${key}--------没有对应页码`);
// }
// }
// }}
// role="button"
// tabIndex={0}
// aria-label={`查看${key}内容详情`}
// onMouseLeave={(e) => {
// // 获取容器内的滚动区域元素
// const scrollContainer = e.currentTarget.querySelector('.text-container');
// if (scrollContainer) {
// // 在文本缩回之前重置滚动位置
// scrollContainer.scrollTop = 0;
// }
// }}
// >
// {/* <div className="flex justify-between items-center mb-1"> */}
// <div className="flex items-center mb-1">
// <span className="text-xs pr-5">
// {key}
// </span>
// <span className={`flex-shrink-0 text-xs w-15 ${value.value?.toString().trim() ? 'text-error' : 'text-warning'}`}>
// {parseInt(value.page as string)>0 || parseInt(reviewPoint.contentPage?.[key] as string)>0 ? '' : <i title="无法找到索引内容" className="ri-alert-line text-red-500 mr-2"></i>}
// {value.value?.toString().trim() ? '' : '缺失'}
// </span>
// </div>
// <div className="relative text-container max-h-96 group-hover:overflow-auto overflow-hidden">
// <p
// className="text-xs text-left select-text block overflow-hidden !line-clamp-2
// group-hover:!line-clamp-none group-hover:bg-white group-hover:shadow-md
// group-hover:z-10 group-hover:relative px-1 rounded transition-all duration-300 ease-in-out cursor-text"
// // title={value.value?.toString() || ''}
// // style={{ userSelect: 'all' }}
// >
// {(value.value?.toString().trim() === '')
// ? ""
// : value.value?.toString() || ''}
// </p>
// </div>
// </div>
// ))}
// </>
// );
})} })}
</> </>
+32 -32
View File
@@ -1560,44 +1560,44 @@ export default function FilesUpload() {
]; ];
// 添加路由阻止器 // 添加路由阻止器
const shouldBlock = uploadStage === "uploading" || uploadStage === "processing"; // const shouldBlock = uploadStage === "uploading" || uploadStage === "processing";
// 使用useBlocker来阻止页面导航 // 使用useBlocker来阻止页面导航
const blocker = useBlocker( // const blocker = useBlocker(
({ nextLocation }) => { // ({ nextLocation }) => {
return shouldBlock && window.location.pathname !== nextLocation.pathname; // return shouldBlock && window.location.pathname !== nextLocation.pathname;
} // }
); // );
// 处理阻止导航的逻辑 // // 处理阻止导航的逻辑
useEffect(() => { // useEffect(() => {
if (blocker.state === "blocked") { // if (blocker.state === "blocked") {
const confirmed = window.confirm( // const confirmed = window.confirm(
"文件正在上传或处理中,离开页面将中断操作。确定要离开吗?" // "文件正在上传或处理中,离开页面将中断操作。确定要离开吗?"
); // );
if (confirmed) { // if (confirmed) {
blocker.proceed(); // blocker.proceed();
} else { // } else {
blocker.reset(); // blocker.reset();
} // }
} // }
}, [blocker]); // }, [blocker]);
// 添加页面刷新/关闭提示 // 添加页面刷新/关闭提示
useEffect(() => { // useEffect(() => {
const handleBeforeUnload = (e: BeforeUnloadEvent) => { // const handleBeforeUnload = (e: BeforeUnloadEvent) => {
if (shouldBlock) { // if (shouldBlock) {
e.preventDefault(); // e.preventDefault();
e.returnValue = "文件正在上传或处理中,离开页面将中断操作。确定要离开吗?"; // e.returnValue = "文件正在上传或处理中,离开页面将中断操作。确定要离开吗?";
return e.returnValue; // return e.returnValue;
} // }
}; // };
window.addEventListener("beforeunload", handleBeforeUnload); // window.addEventListener("beforeunload", handleBeforeUnload);
return () => { // return () => {
window.removeEventListener("beforeunload", handleBeforeUnload); // window.removeEventListener("beforeunload", handleBeforeUnload);
}; // };
}, [shouldBlock]); // }, [shouldBlock]);
return ( return (
<div className="file-upload-page"> <div className="file-upload-page">
+1 -1
View File
@@ -527,7 +527,7 @@ export default function ReviewDetails() {
) : reviewData && ( ) : reviewData && (
<> <>
{/* 自定义面包屑 */} {/* 自定义面包屑 */}
<div className="flex justify-between items-center mb-2"> <div className="flex justify-between items-center mb-4">
<Breadcrumb <Breadcrumb
items={getBreadcrumbItems()} items={getBreadcrumbItems()}
className="items-center flex !mb-0" className="items-center flex !mb-0"