feat(app): 添加自动启动和日志滚动功能并优化上传逻辑
- 增加了运行时自动启动上传配置选项 - 实现了日志输出的滚动控制功能 - 优化了上传进度显示和状态同步机制 - 提升了HTTP客户端连接池配置至500 - 改进了文件上传完成后的清理逻辑 - 添加了上下文取消检查避免资源泄露 - 完善了上传开始时的日志信息输出
This commit is contained in:
+21
-9
@@ -12,11 +12,13 @@ const token = ref('')
|
||||
const checkDir = ref('')
|
||||
const concurrentFiles = ref(1)
|
||||
const uploadThreads = ref(1)
|
||||
const autoStart = ref(false)
|
||||
|
||||
const progress = ref(0)
|
||||
const isRunning = ref(false)
|
||||
const logOutput = ref<string[]>([])
|
||||
const logContentRef = ref<HTMLElement>()
|
||||
const logRoll = ref(true)
|
||||
|
||||
interface FileProgress {
|
||||
name: string
|
||||
@@ -32,7 +34,7 @@ const progressList = ref<FileProgress[]>([
|
||||
const addLog = (msg: string) => {
|
||||
logOutput.value.push(`[${new Date().toLocaleString()}]` + msg)
|
||||
nextTick(() => {
|
||||
if (logContentRef.value) {
|
||||
if (logContentRef.value && logRoll.value){
|
||||
logContentRef.value.scrollTop = logContentRef.value.scrollHeight
|
||||
}
|
||||
})
|
||||
@@ -60,13 +62,6 @@ const startRun = () => {
|
||||
}
|
||||
isRunning.value = true
|
||||
progress.value = 0
|
||||
addLog("===============================================")
|
||||
// addLog(`开始运行...`)
|
||||
addLog(`服务器: ${serverUrl.value}`)
|
||||
addLog(`检测目录: ${checkDir.value}`)
|
||||
addLog(`同时处理文件数: ${concurrentFiles.value}`)
|
||||
addLog(`单文件上传线程: ${uploadThreads.value}`)
|
||||
addLog("===============================================")
|
||||
StartUpload()
|
||||
}
|
||||
|
||||
@@ -100,6 +95,7 @@ try {
|
||||
checkDir.value = config.check_dir
|
||||
concurrentFiles.value = config.handle_file_count
|
||||
uploadThreads.value = config.thread_count
|
||||
autoStart.value = config.is_run_on_start
|
||||
|
||||
LogPrint(`[${new Date().toLocaleString()}] 配置已加载`)
|
||||
})
|
||||
@@ -122,6 +118,9 @@ watch(concurrentFiles, () => {
|
||||
watch(uploadThreads, () => {
|
||||
WriteConfig("thread-count", uploadThreads.value)
|
||||
})
|
||||
watch(autoStart, () => {
|
||||
WriteConfig("is-run-on-start", autoStart.value)
|
||||
})
|
||||
|
||||
EventsOn("log", (msg) => {
|
||||
addLog(msg)
|
||||
@@ -129,6 +128,9 @@ EventsOn("log", (msg) => {
|
||||
EventsOn("progress", (progress) => {
|
||||
progressList.value = progress
|
||||
})
|
||||
EventsOn("is-run", (run) => {
|
||||
isRunning.value = run
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -162,6 +164,10 @@ EventsOn("progress", (progress) => {
|
||||
<el-input-number v-model="uploadThreads" :min="1" :max="100" :disabled="isRunning"/>
|
||||
</div>
|
||||
|
||||
<div class="form-item">
|
||||
<el-checkbox v-model="autoStart" label="运行时自动启动上传" size="large" :disabled="isRunning"/>
|
||||
</div>
|
||||
|
||||
<div class="form-item">
|
||||
<label>上传进度</label>
|
||||
<div class="progress-list">
|
||||
@@ -181,7 +187,10 @@ EventsOn("progress", (progress) => {
|
||||
</div>
|
||||
|
||||
<div class="right-panel">
|
||||
<div class="log-header">日志输出</div>
|
||||
<div class="log-header">
|
||||
日志输出
|
||||
<el-checkbox v-model="logRoll" label="开启日志滚动"/>
|
||||
</div>
|
||||
<div class="log-content" ref="logContentRef">
|
||||
<div v-for="(log, index) in logOutput" :key="index" class="log-line">{{ log }}</div>
|
||||
</div>
|
||||
@@ -286,6 +295,9 @@ EventsOn("progress", (progress) => {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #303133;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.log-content {
|
||||
|
||||
Reference in New Issue
Block a user