mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-30 19:46:38 +08:00
Remove unused recycle bin and add optional local file delete (#26)
Soft-delete restore/purge/list and the recycle_purge job are gone. Admin delete now removes library index rows, with an optional delete_files query that also deletes local media + sidecar NFO. UI copy is renamed from 移入回收站 to 删除, with a confirm checkbox. Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: truewhile <truewhile@users.noreply.github.com>
This commit is contained in:
@@ -10,7 +10,7 @@ type LibraryMovieActionsProps = {
|
||||
onManualScrape: (media: Media) => void
|
||||
onProbe: (media: Media) => void
|
||||
onNFO: (media: Media) => void
|
||||
onSoftDelete: (media: Media) => void
|
||||
onDelete: (media: Media) => void
|
||||
}
|
||||
|
||||
export function LibraryMovieActions({
|
||||
@@ -20,11 +20,11 @@ export function LibraryMovieActions({
|
||||
onManualScrape,
|
||||
onProbe,
|
||||
onNFO,
|
||||
onSoftDelete,
|
||||
onDelete,
|
||||
}: LibraryMovieActionsProps) {
|
||||
const buttonClass = 'flex h-8 w-8 items-center justify-center rounded-lg border border-white/70 bg-white/90 text-gray-700 shadow-sm backdrop-blur transition hover:bg-brand-50 hover:text-brand-600 disabled:opacity-50'
|
||||
|
||||
// 远程 Emby 条目为只读视图:刮削/探测/NFO/回收站不适用。
|
||||
// 远程 Emby 条目为只读视图:刮削/探测/NFO/删除不适用。
|
||||
if (isRemoteEmbyID(media.id)) {
|
||||
return null
|
||||
}
|
||||
@@ -43,7 +43,7 @@ export function LibraryMovieActions({
|
||||
<button title="写出本地 NFO" disabled={busy} onClick={() => onNFO(media)} className={buttonClass}>
|
||||
<FileText size={13} />
|
||||
</button>
|
||||
<button title="移入回收站" disabled={busy} onClick={() => onSoftDelete(media)} className={`${buttonClass} hover:!bg-red-50 hover:!text-red-500`}>
|
||||
<button title="删除" disabled={busy} onClick={() => onDelete(media)} className={`${buttonClass} hover:!bg-red-50 hover:!text-red-500`}>
|
||||
<Trash2 size={13} />
|
||||
</button>
|
||||
</>
|
||||
|
||||
@@ -162,7 +162,7 @@ export function LibraryPage() {
|
||||
handleSeriesProbe,
|
||||
handleSeriesNFO,
|
||||
handleSeriesOrganize,
|
||||
handleSeriesSoftDelete,
|
||||
handleSeriesDelete,
|
||||
movieActions,
|
||||
} = useLibraryAdminActions({
|
||||
libraryID: id,
|
||||
@@ -283,7 +283,7 @@ export function LibraryPage() {
|
||||
onProbe={handleSeriesProbe}
|
||||
onNFO={handleSeriesNFO}
|
||||
onOrganize={handleSeriesOrganize}
|
||||
onSoftDelete={handleSeriesSoftDelete}
|
||||
onDelete={handleSeriesDelete}
|
||||
onSeasonChange={setSelectedSeason}
|
||||
/>
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ type LibrarySeriesDetailHeaderProps = {
|
||||
onProbe: () => void
|
||||
onNFO: () => void
|
||||
onOrganize: () => void
|
||||
onSoftDelete: () => void
|
||||
onDelete: () => void
|
||||
}
|
||||
|
||||
export function LibrarySeriesDetailHeader({
|
||||
@@ -47,7 +47,7 @@ export function LibrarySeriesDetailHeader({
|
||||
onProbe,
|
||||
onNFO,
|
||||
onOrganize,
|
||||
onSoftDelete,
|
||||
onDelete,
|
||||
}: LibrarySeriesDetailHeaderProps) {
|
||||
const firstEpisode = firstPlayableEpisode(visibleEpisodes.length > 0 ? visibleEpisodes : allEpisodes)
|
||||
|
||||
@@ -131,9 +131,9 @@ export function LibrarySeriesDetailHeader({
|
||||
<FolderInput size={13} />
|
||||
<span>{seriesToolBusy === 'organize' ? '整理中…' : '整理当前合集'}</span>
|
||||
</button>
|
||||
<button onClick={onSoftDelete} disabled={!!seriesToolBusy} className="btn-outline px-3.5 py-2 text-xs gap-1.5 !border-red-100 !text-red-500 hover:!border-red-200 hover:!bg-red-50">
|
||||
<button onClick={onDelete} disabled={!!seriesToolBusy} className="btn-outline px-3.5 py-2 text-xs gap-1.5 !border-red-100 !text-red-500 hover:!border-red-200 hover:!bg-red-50">
|
||||
<Trash2 size={13} />
|
||||
<span>{seriesToolBusy === 'delete' ? '处理中…' : '移入回收站'}</span>
|
||||
<span>{seriesToolBusy === 'delete' ? '处理中…' : '删除'}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -31,7 +31,7 @@ type LibrarySeriesDetailSectionProps = {
|
||||
onProbe: () => void
|
||||
onNFO: () => void
|
||||
onOrganize: () => void
|
||||
onSoftDelete: () => void
|
||||
onDelete: () => void
|
||||
onSeasonChange: (season: number) => void
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ export function LibrarySeriesDetailSection({
|
||||
onProbe,
|
||||
onNFO,
|
||||
onOrganize,
|
||||
onSoftDelete,
|
||||
onDelete,
|
||||
onSeasonChange,
|
||||
}: LibrarySeriesDetailSectionProps) {
|
||||
return (
|
||||
@@ -86,7 +86,7 @@ export function LibrarySeriesDetailSection({
|
||||
onProbe={onProbe}
|
||||
onNFO={onNFO}
|
||||
onOrganize={onOrganize}
|
||||
onSoftDelete={onSoftDelete}
|
||||
onDelete={onDelete}
|
||||
/>
|
||||
|
||||
<LibrarySeriesEpisodesPanel
|
||||
|
||||
@@ -14,7 +14,7 @@ type MediaDetailAdminPanelProps = {
|
||||
onOrganize: () => void
|
||||
onProbe: () => void
|
||||
onExportNFO: () => void
|
||||
onSoftDelete: () => void
|
||||
onDelete: () => void
|
||||
}
|
||||
|
||||
export function MediaDetailAdminPanel({
|
||||
@@ -27,7 +27,7 @@ export function MediaDetailAdminPanel({
|
||||
onOrganize,
|
||||
onProbe,
|
||||
onExportNFO,
|
||||
onSoftDelete,
|
||||
onDelete,
|
||||
}: MediaDetailAdminPanelProps) {
|
||||
if (isRemoteEmbyID(media.id)) {
|
||||
return null
|
||||
@@ -70,11 +70,11 @@ export function MediaDetailAdminPanel({
|
||||
<span>写出本地 NFO 属性</span>
|
||||
</button>
|
||||
<button
|
||||
onClick={onSoftDelete}
|
||||
onClick={onDelete}
|
||||
className="btn-outline py-2 px-3.5 text-xs gap-1.5 !border-red-100 !text-red-500 hover:!bg-red-50 hover:!border-red-200"
|
||||
>
|
||||
<Trash2 size={13} />
|
||||
<span>移入回收站</span>
|
||||
<span>删除</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -42,7 +42,7 @@ export function MediaDetailPage() {
|
||||
onOrganize={() => detail.setOrganizeOpen(true)}
|
||||
onProbe={detail.reprobe}
|
||||
onExportNFO={detail.exportNFO}
|
||||
onSoftDelete={detail.softDelete}
|
||||
onDelete={detail.deleteMedia}
|
||||
/>
|
||||
|
||||
{detail.hasEpisodes && (
|
||||
|
||||
@@ -31,7 +31,7 @@ interface MediaDetailMainContentProps extends MediaDetailPlaybackActionsProps {
|
||||
onOrganize: () => void
|
||||
onProbe: () => void
|
||||
onExportNFO: () => void
|
||||
onSoftDelete: () => void
|
||||
onDelete: () => void
|
||||
}
|
||||
|
||||
interface MediaDetailDialogsProps {
|
||||
@@ -147,7 +147,7 @@ export function MediaDetailMainContent({
|
||||
onOrganize,
|
||||
onProbe,
|
||||
onExportNFO,
|
||||
onSoftDelete,
|
||||
onDelete,
|
||||
}: MediaDetailMainContentProps) {
|
||||
return (
|
||||
<div className="relative z-10 p-6 sm:p-10 flex flex-col md:flex-row gap-8 lg:gap-12">
|
||||
@@ -174,7 +174,7 @@ export function MediaDetailMainContent({
|
||||
onOrganize={onOrganize}
|
||||
onProbe={onProbe}
|
||||
onExportNFO={onExportNFO}
|
||||
onSoftDelete={onSoftDelete}
|
||||
onDelete={onDelete}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -3,9 +3,9 @@ import toast from 'react-hot-toast'
|
||||
|
||||
import { api } from '../api/client'
|
||||
import { libraryAPI } from '../api/library'
|
||||
import { recycleAPI } from '../api/recycle'
|
||||
import { mediaAPI } from '../api/library'
|
||||
import { toolsAPI } from '../api/tools'
|
||||
import { confirmAction } from '../components/confirmAction'
|
||||
import { confirmAction, confirmActionResult } from '../components/confirmAction'
|
||||
import type { Library, Media } from '../types'
|
||||
import { seriesTitle, type SeriesCard } from '../utils/groupSeries'
|
||||
import { LibraryMovieActions } from './LibraryMovieActions'
|
||||
@@ -92,7 +92,7 @@ export function useLibraryAdminActions({
|
||||
}
|
||||
|
||||
const handleSeriesNFO = () => {
|
||||
runSeriesTool('nfo', '整剧 NFO 写出', (media) => recycleAPI.exportNFO(media.id))
|
||||
runSeriesTool('nfo', '整剧 NFO 写出', (media) => mediaAPI.exportNFO(media.id))
|
||||
}
|
||||
|
||||
const handleSeriesOrganize = async () => {
|
||||
@@ -128,14 +128,16 @@ export function useLibraryAdminActions({
|
||||
}
|
||||
}
|
||||
|
||||
const handleSeriesSoftDelete = async () => {
|
||||
const handleSeriesDelete = async () => {
|
||||
if (!selectedSeries || selectedSeriesEpisodes.length === 0) return
|
||||
if (!(await confirmAction({
|
||||
title: '移入回收站',
|
||||
message: `将「${seriesTitle(selectedSeries.rep)}」的 ${selectedSeriesEpisodes.length} 个媒体移至回收站? (磁盘文件保留)`,
|
||||
confirmText: '移入回收站',
|
||||
}))) return
|
||||
await runSeriesTool('delete', '整剧移入回收站', (media) => recycleAPI.softDelete(media.id))
|
||||
const result = await confirmActionResult({
|
||||
title: '删除整剧',
|
||||
message: `确定从媒体库删除「${seriesTitle(selectedSeries.rep)}」的 ${selectedSeriesEpisodes.length} 个媒体?\n默认仅移除索引记录,磁盘文件会保留。`,
|
||||
confirmText: '删除',
|
||||
checkboxLabel: '同时删除本地文件(含同名 NFO)',
|
||||
})
|
||||
if (!result.confirmed) return
|
||||
await runSeriesTool('delete', '整剧删除', (media) => mediaAPI.delete(media.id, { deleteFiles: result.checked }))
|
||||
clearSelectedSeries()
|
||||
}
|
||||
|
||||
@@ -166,16 +168,18 @@ export function useLibraryAdminActions({
|
||||
}
|
||||
|
||||
const handleMovieNFO = (media: Media) => {
|
||||
runMovieTool(media, 'nfo', 'NFO 写出', (item) => recycleAPI.exportNFO(item.id))
|
||||
runMovieTool(media, 'nfo', 'NFO 写出', (item) => mediaAPI.exportNFO(item.id))
|
||||
}
|
||||
|
||||
const handleMovieSoftDelete = async (media: Media) => {
|
||||
if (!(await confirmAction({
|
||||
title: '移入回收站',
|
||||
message: `将「${media.title}」移至回收站? (磁盘文件保留)`,
|
||||
confirmText: '移入回收站',
|
||||
}))) return
|
||||
await runMovieTool(media, 'delete', '移入回收站', (item) => recycleAPI.softDelete(item.id))
|
||||
const handleMovieDelete = async (media: Media) => {
|
||||
const result = await confirmActionResult({
|
||||
title: '删除媒体',
|
||||
message: `确定从媒体库删除「${media.title}」?\n默认仅移除索引记录,磁盘文件会保留。`,
|
||||
confirmText: '删除',
|
||||
checkboxLabel: '同时删除本地文件(含同名 NFO)',
|
||||
})
|
||||
if (!result.confirmed) return
|
||||
await runMovieTool(media, 'delete', '删除', (item) => mediaAPI.delete(item.id, { deleteFiles: result.checked }))
|
||||
}
|
||||
|
||||
const movieActions = (media: Media): ReactNode => {
|
||||
@@ -188,7 +192,7 @@ export function useLibraryAdminActions({
|
||||
onManualScrape={setManualMovie}
|
||||
onProbe={handleMovieProbe}
|
||||
onNFO={handleMovieNFO}
|
||||
onSoftDelete={handleMovieSoftDelete}
|
||||
onDelete={handleMovieDelete}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -205,7 +209,7 @@ export function useLibraryAdminActions({
|
||||
handleSeriesProbe,
|
||||
handleSeriesNFO,
|
||||
handleSeriesOrganize,
|
||||
handleSeriesSoftDelete,
|
||||
handleSeriesDelete,
|
||||
movieActions,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ import toast from 'react-hot-toast'
|
||||
import { api } from '../api/client'
|
||||
import { mediaAPI } from '../api/library'
|
||||
import { playbackAPI } from '../api/playback'
|
||||
import { recycleAPI } from '../api/recycle'
|
||||
import { confirmAction } from '../components/confirmAction'
|
||||
import { confirmActionResult } from '../components/confirmAction'
|
||||
import type { Media } from '../types'
|
||||
import { mediaLibraryBackTarget } from './MediaDetailPageModel'
|
||||
|
||||
@@ -181,11 +180,11 @@ function useMediaDetailActions({
|
||||
)
|
||||
const reprobe = useCallback(() => reprobeMedia(media, refresh), [media, refresh])
|
||||
const exportNFO = useCallback(() => exportMediaNFO(media), [media])
|
||||
const softDelete = useCallback(
|
||||
() => softDeleteMedia(media, navigate),
|
||||
const deleteMedia = useCallback(
|
||||
() => deleteMediaFromLibrary(media, navigate),
|
||||
[media, navigate],
|
||||
)
|
||||
return { goBack, toggleFavourite, rescrape, reprobe, exportNFO, softDelete }
|
||||
return { goBack, toggleFavourite, rescrape, reprobe, exportNFO, deleteMedia }
|
||||
}
|
||||
|
||||
function goBackFromMediaDetail(media: Media | null, navigate: NavigateFunction, replace = false): void {
|
||||
@@ -237,23 +236,24 @@ async function reprobeMedia(media: Media | null, refresh: () => Promise<void>):
|
||||
async function exportMediaNFO(media: Media | null): Promise<void> {
|
||||
if (!media) return
|
||||
try {
|
||||
const result = await recycleAPI.exportNFO(media.id)
|
||||
const result = await mediaAPI.exportNFO(media.id)
|
||||
toast.success(`NFO 已成功写入 ${result.path}`)
|
||||
} catch (err: unknown) {
|
||||
toast.error(apiErrorMessage(err, '导出失败'))
|
||||
}
|
||||
}
|
||||
|
||||
async function softDeleteMedia(media: Media | null, navigate: NavigateFunction): Promise<void> {
|
||||
async function deleteMediaFromLibrary(media: Media | null, navigate: NavigateFunction): Promise<void> {
|
||||
if (!media) return
|
||||
const confirmed = await confirmAction({
|
||||
title: '移入回收站',
|
||||
message: `将「${media.title}」移至回收站? (磁盘文件保留)`,
|
||||
confirmText: '移入回收站',
|
||||
const result = await confirmActionResult({
|
||||
title: '删除媒体',
|
||||
message: `确定从媒体库删除「${media.title}」?\n默认仅移除索引记录,磁盘文件会保留。`,
|
||||
confirmText: '删除',
|
||||
checkboxLabel: '同时删除本地文件(含同名 NFO)',
|
||||
})
|
||||
if (!confirmed) return
|
||||
await recycleAPI.softDelete(media.id)
|
||||
toast.success('已移至回收站')
|
||||
if (!result.confirmed) return
|
||||
await mediaAPI.delete(media.id, { deleteFiles: result.checked })
|
||||
toast.success(result.checked ? '已删除媒体及本地文件' : '已从媒体库删除')
|
||||
goBackFromMediaDetail(media, navigate, true)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user