任务记录也保存在前端,合并时后端优先,只有没任务时才自动创建
parent
f4776bc913
commit
84e9affa95
|
|
@ -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-692e9c45.js"></script>
|
||||
<link rel="stylesheet" href="/baidu_netdisk/fe-static/assets/index-24411239.css">
|
||||
<script type="module" crossorigin src="/baidu_netdisk/fe-static/assets/index-ad8a0986.js"></script>
|
||||
<link rel="stylesheet" href="/baidu_netdisk/fe-static/assets/index-f984d69e.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="zanllp_dev_gradio_fe"></div>
|
||||
|
|
|
|||
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-692e9c45.js"></script>
|
||||
<link rel="stylesheet" href="/baidu_netdisk/fe-static/assets/index-24411239.css">
|
||||
<script type="module" crossorigin src="/baidu_netdisk/fe-static/assets/index-ad8a0986.js"></script>
|
||||
<link rel="stylesheet" href="/baidu_netdisk/fe-static/assets/index-f984d69e.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="zanllp_dev_gradio_fe"></div>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import type { UploadTaskTickStatus } from '@/api'
|
||||
import type { UploadTaskSummary, UploadTaskTickStatus } from '@/api'
|
||||
import { defineStore } from 'pinia'
|
||||
import { reactive, ref } from 'vue'
|
||||
import { FetchQueue } from 'vue3-ts-util'
|
||||
import type { WithId } from 'vue3-ts-util'
|
||||
|
||||
export const useTaskListStore = defineStore('useTaskListStore', () => {
|
||||
const taskLogMap = ref(new Map<string, UploadTaskTickStatus[]>())
|
||||
|
|
@ -9,15 +10,17 @@ export const useTaskListStore = defineStore('useTaskListStore', () => {
|
|||
const currLogDetailId = ref('')
|
||||
const queue = reactive(new FetchQueue())
|
||||
const pollInterval = ref(3)
|
||||
const tasks = ref<WithId<UploadTaskSummary>[]>([])
|
||||
return {
|
||||
pollInterval,
|
||||
taskLogMap,
|
||||
splitView,
|
||||
currLogDetailId,
|
||||
queue
|
||||
queue,
|
||||
tasks
|
||||
}
|
||||
}, {
|
||||
persist: {
|
||||
paths: ['pollInterval', 'splitView']
|
||||
paths: ['pollInterval', 'splitView', 'tasks']
|
||||
}
|
||||
})
|
||||
|
|
@ -1,16 +1,18 @@
|
|||
<script setup lang="ts">
|
||||
import { key, pick } from '@/util'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { type WithId, typedID, Task } from 'vue3-ts-util'
|
||||
import { typedID, Task } from 'vue3-ts-util'
|
||||
import { PlusOutlined, SyncOutlined } from '@/icon'
|
||||
import { createBaiduYunTask, getGlobalSetting, getUploadTasks, getUploadTaskTickStatus, type UploadTaskSummary } from '@/api'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { useTaskListStore } from '@/store/useTaskListStore'
|
||||
import { getAutoCompletedTagList } from './autoComplete'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { uniqBy } from 'lodash-es'
|
||||
|
||||
const tasks = ref<WithId<UploadTaskSummary>[]>([])
|
||||
const ID = typedID<UploadTaskSummary>(true)
|
||||
const store = useTaskListStore()
|
||||
const { tasks } = storeToRefs(store)
|
||||
const autoCompletedDirList = ref([] as ReturnType<typeof getAutoCompletedTagList>)
|
||||
const showDirAutoCompletedIdx = ref(-1)
|
||||
|
||||
|
|
@ -19,13 +21,16 @@ onMounted(async () => {
|
|||
autoCompletedDirList.value = getAutoCompletedTagList(resp).filter(v => v.dir.trim())
|
||||
})
|
||||
const resp = await getUploadTasks()
|
||||
tasks.value = resp.tasks.map(ID)
|
||||
tasks.value = uniqBy([...resp.tasks, ...tasks.value].map(ID), v => v.id)
|
||||
.sort((a, b) => Date.parse(b.start_time) - Date.parse(a.start_time))
|
||||
.slice(0, 100)
|
||||
const runningTasks = tasks.value.filter(v => v.running)
|
||||
if (runningTasks.length) {
|
||||
runningTasks.forEach(v => {
|
||||
createPollTask(v.id).completedTask.then(() => message.success('上传完成'))
|
||||
})
|
||||
} else {
|
||||
}
|
||||
if (!tasks.value.length) {
|
||||
addEmptyTask()
|
||||
}
|
||||
})
|
||||
|
|
@ -139,12 +144,13 @@ const addDir2task = (idx: number, dir: string) => {
|
|||
</div>
|
||||
</a-form-item>
|
||||
<a-form-item label="百度云文件夹">
|
||||
<a-input v-model:value="task.recv_dir" :disabled="task.running" placeholder="用于接收的文件夹,支持使用占位符例如stable-diffusion-webui最常用表示日期的<#%Y-%m-%d#>"></a-input>
|
||||
<a-input v-model:value="task.recv_dir" :disabled="task.running"
|
||||
placeholder="用于接收的文件夹,支持使用占位符例如stable-diffusion-webui最常用表示日期的<#%Y-%m-%d#>"></a-input>
|
||||
</a-form-item>
|
||||
<!--a-form-item label="任务类型">
|
||||
<search-select v-model:value="task.type" :disabled="task.running" :options="['upload', 'download']"
|
||||
:conv="{ value: (v) => v, text: (v) => (v === 'upload' ? '上传' : '下载') }"></search-select>
|
||||
</a-form-item-->
|
||||
<search-select v-model:value="task.type" :disabled="task.running" :options="['upload', 'download']"
|
||||
:conv="{ value: (v) => v, text: (v) => (v === 'upload' ? '上传' : '下载') }"></search-select>
|
||||
</a-form-item-->
|
||||
</a-form>
|
||||
<div class="action-bar">
|
||||
<a-button @click="openLogDetail(idx)" v-if="store.taskLogMap.get(task.id)">查看详细日志</a-button>
|
||||
|
|
@ -161,7 +167,6 @@ const addDir2task = (idx: number, dir: string) => {
|
|||
</div>
|
||||
</template>
|
||||
<style scoped lang="scss">
|
||||
|
||||
.wrapper {
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
|
|
|
|||
Loading…
Reference in New Issue