diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..b1f0488 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,26 @@ +{ + "env": { + "es6": true, + "node": true, + "browser": true + }, + "extends": "eslint:recommended", + "rules": { + "indent": [ + "error", + 4 + ], + "linebreak-style": [ + "error", + "windows" + ], + "quotes": [ + "warn", + "double" + ], + "semi": [ + "warn", + "never" + ] + } +} \ No newline at end of file diff --git a/README.md b/README.md index dbc1f36..fd0f9dd 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,12 @@ * 集成aria2c * 多线程下载 -* 未完成任务退出自动保存 +* 未完成任务退出自动保存 * 支持PT/BT * 下载完成消息通知 * 多语言支持 * 支持配置多个 aria2 RPC -* 支持直接从远程aria2服务器上下载文件 +* 支持打开下载文件夹, 在文件管理器中显示已下载的文件 (仅限使用内置的Aria2 RPC) * 使用响应式布局, 支持各种计算机或移动设备 * 友好的界面交互 @@ -43,7 +43,7 @@ * Download finished notification * Multi-languages support * Multi aria2 RPC host support -* Support for downloading files from a remote aria2 server directly +* Support for opening download folder, and displaying downloaded files in file manager (the built-in Aria2 RPC only) * Responsive design, supporting desktop and mobile devices * User-friendly interface diff --git a/app/app.js b/app/app.js index 218606c..e90e470 100644 --- a/app/app.js +++ b/app/app.js @@ -71,7 +71,7 @@ app.on('ready', function () { const aria2_dir = path.join(__dirname, "aria2", platform, aria2_bin) const conf_path = path.join(__dirname, "aria2", "aria2.conf") - edit_conf() // 根据用户的操作系统动态编辑aria2的配置文件 + edit_conf(conf_path) // 根据用户的操作系统动态编辑aria2的配置文件 //打开主程序 fs.chmodSync(aria2_dir, 0o777) diff --git a/app/aria2/aria2.conf b/app/aria2/aria2.conf index 1a07494..6bafc4d 100644 --- a/app/aria2/aria2.conf +++ b/app/aria2/aria2.conf @@ -41,11 +41,11 @@ check-certificate=false ## 进度保存相关 ## # 从会话文件中读取下载任务 -input-file=./resources/app/aria2/aria2.session +input-file= # 在Aria2退出时保存错误的、未完成的下载任务到会话文件 -save-session=./resources/app/aria2/aria2.session +save-session= # 定时保存会话, 0为退出时才保存, 需1.16.1以上版本, 默认:0 -save-session-interval=60 +save-session-interval=5 ## RPC相关设置 ## @@ -58,7 +58,7 @@ rpc-listen-all=true # RPC端口, 仅当默认端口被占用时修改 # rpc-listen-port=6900 # 设置的RPC授权令牌, v1.18.4新增功能, 取代 --rpc-user 和 --rpc-passwd 选项 -#rpc-secret=xmader +#rpc-secret= # 是否启用 RPC 服务的 SSL/TLS 加密, # 启用加密后 RPC 服务需要使用 https 或者 wss 协议连接 rpc-secure=false diff --git a/app/edit_conf.js b/app/edit_conf.js index 9fedab1..fef5bd8 100644 --- a/app/edit_conf.js +++ b/app/edit_conf.js @@ -15,23 +15,16 @@ const fs = require('fs') const path = require('path') const { app } = require('electron') -const edit_conf = (conf_path = `${__dirname}/aria2/aria2.conf`) => { - const download_dir = app.getPath("downloads") || path.join(os.homedir(), "Downloads") +const download_dir = app.getPath("downloads") || path.join(os.homedir(), "Downloads") - let old_conf = fs.readFileSync(conf_path).toString() - - let old_conf_list = old_conf.split("\r\n") - if (old_conf_list.length == 1) { - old_conf_list = old_conf.split("\n") - } +const edit_conf = (conf_path) => { + const session_path = path.join(path.dirname(conf_path), "aria2.session") - let new_conf_list = old_conf_list.map(x => { - if (x.startsWith("input-file=") || x.startsWith("save-session=")) return "# " + x - else if (x.startsWith("dir=")) return "dir=" + download_dir - else return x - }) + let old_conf = fs.readFileSync(conf_path).toString() - let new_conf = new_conf_list.join("\n") + let new_conf = old_conf + .replace(/dir=.+/, "dir=" + download_dir) + .replace(/(input-file=|save-session=).*/g, "$1" + session_path) fs.writeFileSync(conf_path, new_conf) } diff --git a/app/package.json b/app/package.json index e59856e..40a67f7 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "ariang-gui", - "version": "1.4.1", + "version": "1.4.2", "private": true, "description": "AriaNg GUI", "main": "app.js",