@@ -15,6 +15,8 @@ import {
1515 adminStartMediaScan ,
1616 adminStartMediaScrape ,
1717 adminClearMediaDB ,
18+ adminClearMediaScrape ,
19+ adminDeleteInvalidMedia ,
1820 adminExportMediaDB ,
1921 adminImportMediaDB ,
2022 adminGetMediaScanProgress ,
@@ -499,6 +501,48 @@ export const MediaManagePage = (props: MediaManagePageProps) => {
499501 } )
500502 }
501503
504+ // 仅清空刮削数据(保留扫描记录)
505+ const handleClearScrape = async ( ) => {
506+ showConfirm ( {
507+ title : `清空 ${ props . title } 刮削数据` ,
508+ message : `确定要清空 ${ props . title } 的所有刮削结果吗?\n(扫描得到的文件记录会保留,仅清空封面、简介、评分、刮削时间等字段,便于重新刮削。)` ,
509+ confirmText : "清空刮削" ,
510+ type : "warning" ,
511+ onConfirm : async ( ) => {
512+ const resp = await adminClearMediaScrape ( props . mediaType )
513+ if ( resp . code === 200 ) {
514+ const affected = resp . data ?. affected ?? 0
515+ showToast ( `已清空刮削数据,共影响 ${ affected } 条` )
516+ refetchItems ( )
517+ } else {
518+ showToast ( "清空刮削失败: " + resp . message , "error" )
519+ }
520+ } ,
521+ } )
522+ }
523+
524+ // 删除已失效条目(对应文件已不存在)
525+ const handleDeleteInvalid = async ( ) => {
526+ showConfirm ( {
527+ title : `删除 ${ props . title } 失效条目` ,
528+ message : `将检测 ${ props . title } 中所有条目对应的文件 / 文件夹是否仍存在,已失效的条目会被删除。\n此过程可能耗时较久(取决于条目数量),是否继续?` ,
529+ confirmText : "删除已失效" ,
530+ type : "danger" ,
531+ onConfirm : async ( ) => {
532+ showToast ( "正在检测失效条目..." , "info" )
533+ const resp = await adminDeleteInvalidMedia ( props . mediaType )
534+ if ( resp . code === 200 ) {
535+ const checked = resp . data ?. checked ?? 0
536+ const deleted = resp . data ?. deleted ?? 0
537+ showToast ( `检测 ${ checked } 条,删除 ${ deleted } 条已失效条目` )
538+ refetchItems ( )
539+ } else {
540+ showToast ( "删除失败: " + resp . message , "error" )
541+ }
542+ } ,
543+ } )
544+ }
545+
502546 // ============== 导入 / 导出 ==============
503547
504548 // 触发浏览器下载 Blob
@@ -806,6 +850,12 @@ export const MediaManagePage = (props: MediaManagePageProps) => {
806850 < button onClick = { handleImportAll } style = { btnStyle ( "#8b5cf6" ) } >
807851 ⬆️ 导入数据
808852 </ button >
853+ < button onClick = { handleDeleteInvalid } style = { btnStyle ( "#f97316" ) } >
854+ 🧹 删除已失效
855+ </ button >
856+ < button onClick = { handleClearScrape } style = { btnStyle ( "#eab308" ) } >
857+ ♻️ 清空刮削
858+ </ button >
809859 < button onClick = { handleClearAll } style = { btnStyle ( "#ef4444" ) } >
810860 🗑️ 清空全部
811861 </ button >
0 commit comments