下载非内核
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,11 @@
|
||||
import type { ModuleConfig } from '@/types/module'
|
||||
import type { SearchIndexItem } from '@/stores/searchIndex'
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
|
||||
const searchItems: SearchIndexItem[] = [
|
||||
{
|
||||
title: '下载任务',
|
||||
description: '查看与管理下载任务',
|
||||
keywords: ['下载', 'download', '任务', 'task', 'aria2']
|
||||
keywords: ['下载', 'download', '任务', 'task']
|
||||
},
|
||||
{
|
||||
title: '添加下载',
|
||||
@@ -15,8 +14,8 @@ const searchItems: SearchIndexItem[] = [
|
||||
},
|
||||
{
|
||||
title: '下载设置',
|
||||
description: '配置下载目录、速度限制与 RPC',
|
||||
keywords: ['设置', 'setting', 'rpc', '速度', '端口', '目录']
|
||||
description: '配置下载目录、并发数与速度限制',
|
||||
keywords: ['设置', 'setting', '速度', '目录', '并发']
|
||||
},
|
||||
{
|
||||
title: '浏览器扩展',
|
||||
@@ -29,39 +28,18 @@ export const moduleConfig: ModuleConfig = {
|
||||
id: 'downloader',
|
||||
name: '下载器',
|
||||
icon: 'downloader',
|
||||
description: '基于 aria2 的多线程 HTTP 下载管理',
|
||||
description: '多线程 HTTP 下载管理',
|
||||
category: 'network',
|
||||
defaultEnabled: true,
|
||||
loader: () => import('./DownloaderModule.vue'),
|
||||
searchItems,
|
||||
// 进程由 Aria2Manager 通过 ProcessManager 统一管理(id='downloader'),
|
||||
// executable/args 在运行时由后端确定,此处仅声明 hasProcess 以便禁用时自动停止。
|
||||
process: {
|
||||
name: 'aria2c',
|
||||
executable: '',
|
||||
autoStart: false,
|
||||
restartOnCrash: true,
|
||||
maxRestarts: 3
|
||||
},
|
||||
// 下载引擎在进程内运行,无需外部进程管理
|
||||
lifecycle: {
|
||||
// 启用模块时若用户开启了"自动启动",则随模块启用而运行 aria2
|
||||
onEnable: async () => {
|
||||
try {
|
||||
const s = await invoke<{ autoStart?: boolean }>('downloader_get_settings')
|
||||
if (s.autoStart) {
|
||||
await invoke('downloader_start')
|
||||
}
|
||||
} catch {
|
||||
/* 忽略:可能内核未安装 */
|
||||
}
|
||||
// 引擎在应用启动时已自动运行,模块启用时无需额外操作
|
||||
},
|
||||
// 禁用模块时停止 aria2 进程(cleanup_on_exit 会在应用退出时调用)
|
||||
onDisable: async () => {
|
||||
try {
|
||||
await invoke('downloader_stop')
|
||||
} catch {
|
||||
/* 忽略:可能进程未运行 */
|
||||
}
|
||||
// 模块禁用时不停止引擎(引擎在应用退出时统一清理)
|
||||
}
|
||||
},
|
||||
order: 50
|
||||
|
||||
Reference in New Issue
Block a user