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