mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 07:28:37 +08:00
feat 手动整理进度显示
This commit is contained in:
@@ -50,6 +50,18 @@ const renamePopper = ref(false)
|
|||||||
// 整理弹窗
|
// 整理弹窗
|
||||||
const transferPopper = ref(false)
|
const transferPopper = ref(false)
|
||||||
|
|
||||||
|
// 整理进度条
|
||||||
|
const progressDialog = ref(false)
|
||||||
|
|
||||||
|
// 整理进度文本
|
||||||
|
const progressText = ref('请稍候 ...')
|
||||||
|
|
||||||
|
// 整理进度
|
||||||
|
const progressValue = ref(0)
|
||||||
|
|
||||||
|
// 加载进度SSE
|
||||||
|
const progressEventSource = ref<EventSource>()
|
||||||
|
|
||||||
// 新名称
|
// 新名称
|
||||||
const newName = ref('')
|
const newName = ref('')
|
||||||
|
|
||||||
@@ -223,21 +235,33 @@ function showTransfer(item: FileItem) {
|
|||||||
|
|
||||||
// 整理文件
|
// 整理文件
|
||||||
async function transfer() {
|
async function transfer() {
|
||||||
transferForm.path = currentItem.value?.path || ''
|
transferForm.path = currentItem.value?.path ?? ''
|
||||||
// 开始整理文件
|
// 开始整理文件
|
||||||
try {
|
try {
|
||||||
|
// 关闭弹窗
|
||||||
transferPopper.value = false
|
transferPopper.value = false
|
||||||
const result: { [key: string]: any } = await api.post('transfer/manual', {}, {
|
// 显示进度条
|
||||||
|
progressDialog.value = true
|
||||||
|
// 开始监听进度
|
||||||
|
startLoadingProgress()
|
||||||
|
// 异步调API,结束后关闭进度条
|
||||||
|
api.post('transfer/manual', {}, {
|
||||||
params: transferForm,
|
params: transferForm,
|
||||||
|
}).then((res: any) => {
|
||||||
|
// 关闭进度条
|
||||||
|
progressDialog.value = false
|
||||||
|
// 停止监听进度
|
||||||
|
stopLoadingProgress()
|
||||||
|
// 显示结果
|
||||||
|
if (res.success) {
|
||||||
|
$toast.success(`${currentItem.value?.name} 整理成功!`)
|
||||||
|
// 重新加载
|
||||||
|
load()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$toast.error(`${currentItem.value?.name} 整理失败:${res.message}!`)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (result.success) {
|
|
||||||
$toast.success(`${currentItem.value?.name} 整理成功!`)
|
|
||||||
// 重新加载
|
|
||||||
load()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$toast.error(`${currentItem.value?.name} 整理失败:${result.message}!`)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
@@ -264,6 +288,29 @@ watch(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 使用SSE监听加载进度
|
||||||
|
function startLoadingProgress() {
|
||||||
|
progressText.value = '请稍候 ...'
|
||||||
|
|
||||||
|
const token = store.state.auth.token
|
||||||
|
|
||||||
|
progressEventSource.value = new EventSource(
|
||||||
|
`${import.meta.env.VITE_API_BASE_URL}system/progress/filetransfer?token=${token}`,
|
||||||
|
)
|
||||||
|
progressEventSource.value.onmessage = (event) => {
|
||||||
|
const progress = JSON.parse(event.data)
|
||||||
|
if (progress) {
|
||||||
|
progressText.value = progress.text
|
||||||
|
progressValue.value = progress.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 停止监听加载进度
|
||||||
|
function stopLoadingProgress() {
|
||||||
|
progressEventSource.value?.close()
|
||||||
|
}
|
||||||
|
|
||||||
// 弹出菜单
|
// 弹出菜单
|
||||||
const dropdownItems = ref([
|
const dropdownItems = ref([
|
||||||
{
|
{
|
||||||
@@ -623,6 +670,25 @@ onMounted(() => {
|
|||||||
</VCardActions>
|
</VCardActions>
|
||||||
</VCard>
|
</VCard>
|
||||||
</VDialog>
|
</VDialog>
|
||||||
|
<!-- 手动整理进度框 -->
|
||||||
|
<vDialog
|
||||||
|
v-model="progressDialog"
|
||||||
|
:scrim="false"
|
||||||
|
width="400"
|
||||||
|
>
|
||||||
|
<vCard
|
||||||
|
color="primary"
|
||||||
|
>
|
||||||
|
<vCardText class="text-center">
|
||||||
|
{{ progressText }}
|
||||||
|
<vProgressLinear
|
||||||
|
color="white"
|
||||||
|
class="mb-0 mt-1"
|
||||||
|
:value="progressValue"
|
||||||
|
/>
|
||||||
|
</vCardText>
|
||||||
|
</vCard>
|
||||||
|
</vDialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ async function fetchData(): Promise<Array<Context>> {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
startLoadingProgress()
|
startLoadingProgress()
|
||||||
const qualify = props.keyword?.startsWith('tmdb:') || props.keyword?.startsWith('douban:')
|
const qualify = props.keyword?.startsWith('tmdb:') ?? props.keyword?.startsWith('douban:')
|
||||||
// 优先按TMDBID精确查询
|
// 优先按TMDBID精确查询
|
||||||
if (qualify) {
|
if (qualify) {
|
||||||
searchData = await api.get(`search/media/${props.keyword}`, {
|
searchData = await api.get(`search/media/${props.keyword}`, {
|
||||||
|
|||||||
Reference in New Issue
Block a user