mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-05-30 12:49:55 +08:00
fix scrape
This commit is contained in:
@@ -6,7 +6,7 @@ import api from '@/api'
|
||||
import { numberValidator } from '@/@validators'
|
||||
import { useDisplay } from 'vuetify'
|
||||
import ProgressDialog from './ProgressDialog.vue'
|
||||
import { MediaDirectory } from '@/api/types'
|
||||
import { FileItem, MediaDirectory } from '@/api/types'
|
||||
|
||||
// 显示器宽度
|
||||
const display = useDisplay()
|
||||
@@ -17,9 +17,9 @@ const props = defineProps({
|
||||
type: String,
|
||||
default: () => 'local',
|
||||
},
|
||||
paths: Array<string>,
|
||||
target: String,
|
||||
logids: Array<number>,
|
||||
items: Array<FileItem>,
|
||||
target: String,
|
||||
})
|
||||
|
||||
// 定义事件
|
||||
@@ -56,9 +56,9 @@ const progressValue = ref(0)
|
||||
|
||||
// 标题
|
||||
const dialogTitle = computed(() => {
|
||||
if (props.paths) {
|
||||
if (props.paths.length > 1) return `整理 - 共 ${props.paths.length} 项`
|
||||
return `整理 - ${props.paths[0]}`
|
||||
if (props.items) {
|
||||
if (props.items.length > 1) return `整理 - 共 ${props.items.length} 项`
|
||||
return `整理 - ${props.items[0].path}`
|
||||
} else if (props.logids) {
|
||||
return `整理 - 共 ${props.logids.length} 项`
|
||||
}
|
||||
@@ -70,6 +70,9 @@ const transferForm = reactive({
|
||||
storage: props.storage,
|
||||
logid: 0,
|
||||
path: '',
|
||||
drive_id: '',
|
||||
fileid: '',
|
||||
filetype: '',
|
||||
target: props.target ?? null,
|
||||
tmdbid: null,
|
||||
doubanid: null,
|
||||
@@ -128,7 +131,7 @@ function stopLoadingProgress() {
|
||||
|
||||
// 整理文件
|
||||
async function transfer() {
|
||||
if (!props.logids && !props.paths) return
|
||||
if (!props.logids && !props.items) return
|
||||
|
||||
// 显示进度条
|
||||
progressDialog.value = true
|
||||
@@ -136,9 +139,9 @@ async function transfer() {
|
||||
startLoadingProgress()
|
||||
|
||||
// 文件整理
|
||||
if (props.paths) {
|
||||
for (const path of props.paths) {
|
||||
await handleTransfer(path)
|
||||
if (props.items) {
|
||||
for (const item of props.items) {
|
||||
await handleTransfer(item)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,11 +161,15 @@ async function transfer() {
|
||||
}
|
||||
|
||||
// 整理文件
|
||||
async function handleTransfer(path: string) {
|
||||
transferForm.path = path
|
||||
async function handleTransfer(item: FileItem) {
|
||||
transferForm.path = item.path
|
||||
transferForm.fileid = item.fileid || ''
|
||||
transferForm.drive_id = item.drive_id || ''
|
||||
transferForm.filetype = item.type || 'dir'
|
||||
|
||||
try {
|
||||
const result: { [key: string]: any } = await api.post('transfer/manual', {}, { params: transferForm })
|
||||
if (!result.success) $toast.error(`文件 ${path} 整理失败:${result.message}!`)
|
||||
if (!result.success) $toast.error(`文件 ${item.path} 整理失败:${result.message}!`)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
@@ -111,8 +111,8 @@ const isDir = computed(() => inProps.item.path?.endsWith('/'))
|
||||
// 是否文件
|
||||
const isFile = computed(() => !isDir.value)
|
||||
|
||||
// 需要整理的path
|
||||
const transferPaths = ref<string[]>([])
|
||||
// 需要整理的文件项
|
||||
const transferItems = ref<FileItem[]>([])
|
||||
|
||||
// 大小控制
|
||||
const scrollStyle = computed(() => {
|
||||
@@ -156,28 +156,33 @@ async function list_files() {
|
||||
}
|
||||
|
||||
// 删除项目
|
||||
async function deleteItem(item: FileItem) {
|
||||
const confirmed = await createConfirm({
|
||||
title: '确认',
|
||||
content: `是否确认删除${item.type === 'dir' ? '目录' : '文件'} ${item.name}?`,
|
||||
})
|
||||
|
||||
if (confirmed) {
|
||||
emit('loading', true)
|
||||
|
||||
const url = inProps.endpoints?.delete.url.replace(/{storage}/g, inProps.storage)
|
||||
const config: AxiosRequestConfig<FileItem> = {
|
||||
url,
|
||||
method: inProps.endpoints?.delete.method || 'post',
|
||||
data: item,
|
||||
}
|
||||
|
||||
await inProps.axios.request(config)
|
||||
emit('filedeleted')
|
||||
emit('loading', false)
|
||||
// 重新加载
|
||||
list_files()
|
||||
async function deleteItem(item: FileItem, confirm: boolean = true) {
|
||||
if (confirm) {
|
||||
const confirmed = await createConfirm({
|
||||
title: '确认',
|
||||
content: `是否确认删除${item.type === 'dir' ? '目录' : '文件'} ${item.name}?`,
|
||||
})
|
||||
if (!confirmed) return
|
||||
}
|
||||
|
||||
// 加载中
|
||||
emit('loading', true)
|
||||
|
||||
// 请求API
|
||||
const url = inProps.endpoints?.delete.url.replace(/{storage}/g, inProps.storage)
|
||||
const config: AxiosRequestConfig<FileItem> = {
|
||||
url,
|
||||
method: inProps.endpoints?.delete.method || 'post',
|
||||
data: item,
|
||||
}
|
||||
await inProps.axios.request(config)
|
||||
|
||||
// 删除完成
|
||||
emit('loading', false)
|
||||
emit('filedeleted')
|
||||
|
||||
// 重新加载
|
||||
list_files()
|
||||
}
|
||||
|
||||
// 批量删除
|
||||
@@ -187,33 +192,23 @@ async function batchDelete() {
|
||||
content: `是否确认删除选中的 ${selected.value.length} 个项目?`,
|
||||
})
|
||||
|
||||
if (confirmed) {
|
||||
emit('loading', true)
|
||||
if (!confirmed) return
|
||||
|
||||
// 显示进度条
|
||||
progressDialog.value = true
|
||||
progressValue.value = 0
|
||||
// 显示进度条
|
||||
progressDialog.value = true
|
||||
progressValue.value = 0
|
||||
|
||||
// 删除选中的项目
|
||||
selected.value.every(async item => {
|
||||
progressText.value = `正在删除 ${item.name} ...`
|
||||
const url = inProps.endpoints?.delete.url.replace(/{storage}/g, inProps.storage)
|
||||
const config: AxiosRequestConfig<FileItem> = {
|
||||
url,
|
||||
method: inProps.endpoints?.delete.method || 'post',
|
||||
data: item,
|
||||
}
|
||||
await inProps.axios.request(config)
|
||||
})
|
||||
// 删除选中的项目
|
||||
selected.value.every(async item => {
|
||||
progressText.value = `正在删除 ${item.name} ...`
|
||||
await deleteItem(item, false)
|
||||
})
|
||||
|
||||
// 关闭进度条
|
||||
progressDialog.value = false
|
||||
// 关闭进度条
|
||||
progressDialog.value = false
|
||||
|
||||
emit('filedeleted')
|
||||
emit('loading', false)
|
||||
// 重新加载
|
||||
list_files()
|
||||
}
|
||||
// 重新加载
|
||||
list_files()
|
||||
}
|
||||
|
||||
// 切换路径
|
||||
@@ -337,13 +332,13 @@ async function rename() {
|
||||
|
||||
// 显示整理对话框
|
||||
function showTransfer(item: FileItem) {
|
||||
transferPaths.value = [item.path || '']
|
||||
transferItems.value = [item]
|
||||
transferPopper.value = true
|
||||
}
|
||||
|
||||
// 显示批量整理对话框
|
||||
function showBatchTransfer() {
|
||||
transferPaths.value = selected.value.map(item => item.path || '')
|
||||
transferItems.value = selected.value
|
||||
transferPopper.value = true
|
||||
}
|
||||
|
||||
@@ -715,7 +710,7 @@ onMounted(() => {
|
||||
v-if="transferPopper"
|
||||
v-model="transferPopper"
|
||||
:storage="inProps.storage"
|
||||
:paths="transferPaths"
|
||||
:items="transferItems"
|
||||
@done="transferDone"
|
||||
@close="transferPopper = false"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user