send_dirs改用数组,优化上传提示
parent
641193b23e
commit
fd3b5225b2
|
|
@ -6,8 +6,8 @@
|
|||
<link rel="icon" href="/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Vite App</title>
|
||||
<script type="module" crossorigin src="/baidu_netdisk/fe-static/assets/index-53cd0579.js"></script>
|
||||
<link rel="stylesheet" href="/baidu_netdisk/fe-static/assets/index-1d7f41d3.css">
|
||||
<script type="module" crossorigin src="/baidu_netdisk/fe-static/assets/index-a8fb8db6.js"></script>
|
||||
<link rel="stylesheet" href="/baidu_netdisk/fe-static/assets/index-56cef25f.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="zanllp_dev_gradio_fe"></div>
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ def baidu_netdisk_api(_: Any, app: FastAPI):
|
|||
|
||||
class BaiduyunUploadDownloadReq(BaseModel):
|
||||
type: Literal["upload", "download"]
|
||||
send_dirs: str
|
||||
send_dirs: List[str]
|
||||
recv_dir: str
|
||||
|
||||
@app.post(f"{pre}/task")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import asyncio
|
||||
import datetime
|
||||
import os
|
||||
from typing import Dict, Literal
|
||||
from typing import Dict, List, Literal
|
||||
import uuid
|
||||
import re
|
||||
import subprocess
|
||||
|
|
@ -17,7 +17,7 @@ class BaiduyunTask:
|
|||
self,
|
||||
subprocess: asyncio.subprocess.Process,
|
||||
type: Literal["upload", "download"],
|
||||
send_dirs: str,
|
||||
send_dirs: List[str],
|
||||
recv_dir: str,
|
||||
):
|
||||
self.subprocess = subprocess
|
||||
|
|
@ -105,13 +105,13 @@ class BaiduyunTask:
|
|||
|
||||
@staticmethod
|
||||
async def create(
|
||||
type: Literal["upload", "download"], send_dirs: str, recv_dir: str
|
||||
type: Literal["upload", "download"], send_dirs: List[str], recv_dir: str
|
||||
):
|
||||
if type == "upload" :
|
||||
process = await asyncio.create_subprocess_exec(
|
||||
bin_file_path,
|
||||
type,
|
||||
*process_path_arr(str(send_dirs).split(",")),
|
||||
*process_path_arr(send_dirs),
|
||||
parse_and_replace_time(recv_dir),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
|
|
@ -120,7 +120,7 @@ class BaiduyunTask:
|
|||
process = await asyncio.create_subprocess_exec(
|
||||
bin_file_path,
|
||||
type,
|
||||
*process_path_arr(str(send_dirs).split(",")),
|
||||
*process_path_arr(send_dirs),
|
||||
"--saveto",
|
||||
parse_and_replace_time(recv_dir),
|
||||
"-p",
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -5,8 +5,8 @@
|
|||
<link rel="icon" href="/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Vite App</title>
|
||||
<script type="module" crossorigin src="/baidu_netdisk/fe-static/assets/index-53cd0579.js"></script>
|
||||
<link rel="stylesheet" href="/baidu_netdisk/fe-static/assets/index-1d7f41d3.css">
|
||||
<script type="module" crossorigin src="/baidu_netdisk/fe-static/assets/index-a8fb8db6.js"></script>
|
||||
<link rel="stylesheet" href="/baidu_netdisk/fe-static/assets/index-56cef25f.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="zanllp_dev_gradio_fe"></div>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export const greeting = async () => {
|
|||
}
|
||||
interface BaiduYunTaskCreateReq {
|
||||
type: 'upload' | 'download'
|
||||
send_dirs: string
|
||||
send_dirs: string[]
|
||||
recv_dir: string
|
||||
}
|
||||
export const createBaiduYunTask = async (req: BaiduYunTaskCreateReq) => {
|
||||
|
|
@ -99,7 +99,7 @@ export interface UploadTaskSummary {
|
|||
id: string
|
||||
running: boolean
|
||||
start_time: string
|
||||
send_dirs: string
|
||||
send_dirs: string[]
|
||||
recv_dir: string
|
||||
type: 'upload' | 'download'
|
||||
n_files: number
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import { getTargetFolderFiles, type FileNodeInfo } from '@/api/files'
|
||||
import { cloneDeep, last, range, uniq } from 'lodash'
|
||||
import { ref, computed, onMounted, watch } from 'vue'
|
||||
import { ref, computed, onMounted, watch, h } from 'vue'
|
||||
import { FileOutlined, FolderOpenOutlined, DownOutlined } from '@/icon'
|
||||
import { sortMethodMap, sortFiles, SortMethod } from './fileSort'
|
||||
import path from 'path-browserify'
|
||||
|
|
@ -124,13 +124,17 @@ const onDrop = async (e: DragEvent) => {
|
|||
const type = data.from === 'local' ? 'upload' : 'download'
|
||||
const typeZH = type === 'upload' ? '上传' : '下载'
|
||||
const toPath = path.join(...getBasePath())
|
||||
const content = h('div', [
|
||||
h('div', `从 ${props.target !== 'local' ? '本地' : '云盘'} `),
|
||||
h('ol', data.path.map(v => v.split(/[/\\]/).pop()).map(v => h('li', v))),
|
||||
h('div', `${typeZH} ${props.target === 'local' ? '本地' : '云盘'} ${toPath}`)
|
||||
])
|
||||
Modal.confirm({
|
||||
title: `确定创建${typeZH}任务${data.includeDir ? ', 这是文件夹或者包含文件夹!' : ''}`,
|
||||
content: `从 ${props.target !== 'local' ? '本地' : '云盘'} ${data.path.join('\n')} ${typeZH} ${props.target === 'local' ? '本地' : '云盘'
|
||||
} ${toPath}`,
|
||||
content,
|
||||
maskClosable: true,
|
||||
async onOk () {
|
||||
global.eventEmitter.emit('createNewTask', { send_dirs: data.path.join(), recv_dir: toPath, type })
|
||||
global.eventEmitter.emit('createNewTask', { send_dirs: data.path, recv_dir: toPath, type })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ export const useTaskListStore = defineStore('useTaskListStore', () => {
|
|||
}
|
||||
}, {
|
||||
persist: {
|
||||
paths: ['pollInterval', 'splitView', 'tasks']
|
||||
paths: ['pollInterval', 'splitView', 'tasks'],
|
||||
key: 'useTaskListStore-v0.0.1'
|
||||
}
|
||||
})
|
||||
|
|
@ -16,12 +16,7 @@ const addDir2task = (dir: string) => {
|
|||
task.value.recv_dir = dir
|
||||
return
|
||||
}
|
||||
const spReg = /[,,\n]$/
|
||||
if (spReg.test(task.value.send_dirs) || !task.value.send_dirs.trim()) {
|
||||
task.value.send_dirs += dir
|
||||
} else {
|
||||
task.value.send_dirs += ` , ${dir}`
|
||||
}
|
||||
task.value.send_dirs.push(dir)
|
||||
}
|
||||
const colors = ['#f5222d', '#1890ff', '#ff3125', '#d46b08', '#007bff', '#52c41a', '#13c2c2', '#fa541c', '#eb2f96', '#2f54eb']
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ globalStore.useEventListen('createNewTask', async task => {
|
|||
|
||||
const getEmptyTask = () => ID({
|
||||
type: 'upload',
|
||||
send_dirs: '',
|
||||
send_dirs: [],
|
||||
recv_dir: '',
|
||||
id: '',
|
||||
running: false,
|
||||
|
|
@ -65,9 +65,9 @@ const addEmptyTask = () => {
|
|||
|
||||
const createNewTask = async (idx: number) => {
|
||||
const task = tasks.value[idx]
|
||||
task.send_dirs = task.send_dirs.split(/,,\n/).map(v => v.trim()).filter(v => v).join()
|
||||
task.send_dirs = task.send_dirs.map(v => v.trim()).filter(v => v)
|
||||
task.recv_dir = task.recv_dir.trim()
|
||||
if (!(task.type === 'upload' ? task.recv_dir.startsWith('/') : task.send_dirs.split(',').every(v => v.startsWith('/')))) {
|
||||
if (!(task.type === 'upload' ? task.recv_dir.startsWith('/') : task.send_dirs.every(v => v.startsWith('/')))) {
|
||||
return message.error('百度云的位置必须以 “/” 开头')
|
||||
}
|
||||
task.running = true
|
||||
|
|
@ -163,7 +163,7 @@ const remove = async (idx: number) => {
|
|||
</a-form-item>
|
||||
<a-form-item :label="`发送的文件夹 (${task.type === 'upload' ? '本地' : '百度云'})`"
|
||||
@click.stop="task.type === 'upload' && (showDirAutoCompletedIdx = idx)">
|
||||
<a-textarea auto-size :disabled="isDisable(task)" v-model:value="task.send_dirs" allow-clear
|
||||
<a-textarea auto-size :disabled="isDisable(task)" :value="task.send_dirs.join()" @update:value="v => task.send_dirs = v.split(',')" allow-clear
|
||||
placeholder="发送文件的文件夹,多个文件夹使用逗号或者换行分隔。支持使用占位符例如stable-diffusion-webui最常用表示日期的<#%Y-%m-%d#>"></a-textarea>
|
||||
<local-path-shortcut v-if="task.type === 'upload'" :task="task" @update:task="v => tasks[idx] = v" :idx="idx" />
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue