feat: 支持设置创建下载任务后是否自动开始

This commit is contained in:
lanyeeee
2026-02-01 08:45:46 +08:00
parent f09e8cfc49
commit fa5be81fb8
6 changed files with 22 additions and 6 deletions
+2
View File
@@ -43,6 +43,7 @@ pub struct Config {
pub chunk_download_interval_sec: u64,
pub danmaku_config: CanvasConfig,
pub file_exist_action: FileExistAction,
pub auto_start_download_task: bool,
}
impl Config {
@@ -153,6 +154,7 @@ impl Config {
chunk_download_interval_sec: 0,
danmaku_config: CanvasConfig::default(),
file_exist_action: FileExistAction::Overwrite,
auto_start_download_task: true,
}
}
}
+8 -1
View File
@@ -98,7 +98,14 @@ impl DownloadTask {
tracing::error!(err_title, message = string_chain);
}
let (state_sender, _) = watch::channel(DownloadTaskState::Pending);
let auto_start = app.get_config().read().auto_start_download_task;
let init_state = if auto_start {
DownloadTaskState::Pending
} else {
DownloadTaskState::Paused
};
let (state_sender, _) = watch::channel(init_state);
let (restart_sender, _) = watch::channel(());
let (cancel_sender, _) = watch::channel(());
let (delete_sender, _) = watch::channel(());
+1 -1
View File
@@ -267,7 +267,7 @@ export type CntInfo = { collect: number; play: number; thumb_up: number; share:
export type CntInfoInMedia = { collect: number; play: number; danmaku: number; vt: number; play_switch: number; reply: number; view_text_1: string }
export type CodecType = "Unknown" | "Audio" | "AVC" | "HEVC" | "AV1"
export type CommandError = { err_title: string; err_message: string }
export type Config = { download_dir: string; enable_file_logger: boolean; sessdata: string; video_quality_priority: VideoQuality[]; codec_type_priority: CodecType[]; audio_quality_priority: AudioQuality[]; download_video: boolean; download_audio: boolean; auto_merge: boolean; embed_chapter: boolean; embed_skip: boolean; download_xml_danmaku: boolean; download_ass_danmaku: boolean; download_json_danmaku: boolean; download_subtitle: boolean; download_cover: boolean; download_nfo: boolean; download_json: boolean; dir_fmt: string; dir_fmt_for_part: string; time_fmt: string; proxy_mode: ProxyMode; proxy_host: string; proxy_port: number; task_concurrency: number; task_download_interval_sec: number; chunk_concurrency: number; chunk_download_interval_sec: number; danmaku_config: CanvasConfig; file_exist_action: FileExistAction }
export type Config = { download_dir: string; enable_file_logger: boolean; sessdata: string; video_quality_priority: VideoQuality[]; codec_type_priority: CodecType[]; audio_quality_priority: AudioQuality[]; download_video: boolean; download_audio: boolean; auto_merge: boolean; embed_chapter: boolean; embed_skip: boolean; download_xml_danmaku: boolean; download_ass_danmaku: boolean; download_json_danmaku: boolean; download_subtitle: boolean; download_cover: boolean; download_nfo: boolean; download_json: boolean; dir_fmt: string; dir_fmt_for_part: string; time_fmt: string; proxy_mode: ProxyMode; proxy_host: string; proxy_port: number; task_concurrency: number; task_download_interval_sec: number; chunk_concurrency: number; chunk_download_interval_sec: number; danmaku_config: CanvasConfig; file_exist_action: FileExistAction; auto_start_download_task: boolean }
export type Consulting = { consulting_flag: boolean; consulting_url: string }
export type ContentAttr = { text: string; bg_color: string; bg_color_night: string; img: string; multi_img: MultiImg }
export type ContentList = { bold: boolean; content: string; number: string }
@@ -52,7 +52,7 @@ async function showConfigInFileManager() {
<template>
<n-modal v-if="store.config !== undefined" v-model:show="showing">
<n-dialog :showIcon="false" title="配置" content-style="" @close="showing = false">
<n-dialog :showIcon="false" content-style="" @close="showing = false">
<div class="flex flex-col gap-row-2">
<n-tabs class="h-full" v-model:value="currentTabName" type="line" size="small" animated>
<n-tab-pane name="download_settings" tab="下载内容">
@@ -8,7 +8,7 @@ const store = useStore()
</script>
<template>
<div v-if="store.config !== undefined" class="flex flex-col gap-row-2">
<div v-if="store.config !== undefined" class="flex flex-col gap-row-1">
<div class="flex gap-2">
<span class="w-15 font-bold">主要内容</span>
<n-checkbox class="w-22" v-model:checked="store.config.download_video">下载视频</n-checkbox>
@@ -131,6 +131,13 @@ const store = useStore()
<n-radio-button value="Skip">跳过下载</n-radio-button>
</n-radio-group>
</div>
<div class="flex flex-col">
<span class="font-bold">其他</span>
<n-checkbox class="w-fit" v-model:checked="store.config.auto_start_download_task">
创建下载任务后自动开始
</n-checkbox>
</div>
</div>
</template>
@@ -138,7 +138,7 @@ function toVideoFormatSelectValue(videoQuality: VideoQuality, codecType: CodecTy
</script>
<template>
<div class="flex flex-col gap-row-2">
<div class="flex flex-col gap-row-1">
<div class="flex gap-2">
<span class="w-15 font-bold">主要内容</span>
<n-checkbox class="w-22" v-model:checked="progressData.video_task.selected">下载视频</n-checkbox>
@@ -209,7 +209,7 @@ function toVideoFormatSelectValue(videoQuality: VideoQuality, codecType: CodecTy
:theme-overrides="{
peers: {
InternalSelectMenu: {
height: '175px',
height: '180px',
},
},
}"