diff --git a/app/run.py b/app/run.py index 26f9de8..e53e9a6 100644 --- a/app/run.py +++ b/app/run.py @@ -18,8 +18,13 @@ import subprocess import hashlib import logging import json +import sys import os +parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +sys.path.insert(0, parent_dir) +from quark_auto_save import Quark + def get_app_ver(): BUILD_SHA = os.environ.get("BUILD_SHA", "") @@ -195,6 +200,18 @@ def run_script_now(): ) +@app.route("/get_share_files") +def get_share_files(): + if not is_login(): + return jsonify({"error": "未登录"}) + shareurl = request.args.get("shareurl", "") + account = Quark("", 0) + pwd_id, pdir_fid = account.get_id_from_url(shareurl) + _, stoken = account.get_stoken(pwd_id) + share_file_list = account.get_detail(pwd_id, stoken, pdir_fid) + return jsonify(share_file_list) + + # 定时任务执行的函数 def run_python(args): logging.info(f">>> 定时运行任务") diff --git a/app/templates/index.html b/app/templates/index.html index 9258d61..567cb1e 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -207,6 +207,17 @@ +
+ +
+
+ +
+ +
+
+
+
@@ -277,6 +288,45 @@
+ + @@ -319,7 +369,23 @@ taskDirs: [""], taskDirSelected: "", taskNameFilter: "", - modalLoading: false + modalLoading: false, + shareFiles: [], + forceTaskIndex: null + }, + filters: { + ts2date: function (value) { + const date = new Date(value); + return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} ${date.getHours()}:${date.getMinutes().toString().padStart(2, '0')}`; + }, + size: function (value) { + if (!value) return "0B"; + const unitArr = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; + const srcsize = parseFloat(value); + const index = srcsize ? Math.floor(Math.log(srcsize) / Math.log(1024)) : 0; + const size = (srcsize / Math.pow(1024, index)).toFixed(2).replace(/\.?0+$/, ""); + return size + unitArr[index]; + } }, watch: { 'formData.push_config': { @@ -434,6 +500,25 @@ clearData(target) { this[target] = ""; }, + selectStartFid(fid) { + Vue.set(this.formData.tasklist[this.forceTaskIndex], 'startfid', fid); + $('#shareDetailModal').modal('toggle') + }, + showShareFiles(index) { + + this.shareFiles = [] + $('#shareDetailModal').modal('toggle') + this.modalLoading = true + axios.get('/get_share_files', { params: { shareurl: this.formData.tasklist[index].shareurl } }) + .then(response => { + this.forceTaskIndex = index + this.shareFiles = response.data; + this.modalLoading = false + }) + .catch(error => { + console.error('Error get_share_files:', error); + }); + }, runScriptNow(task_index = "") { $('#logModal').modal('toggle') this.modalLoading = true diff --git a/quark_auto_save.py b/quark_auto_save.py index 1d88ae1..44cf288 100644 --- a/quark_auto_save.py +++ b/quark_auto_save.py @@ -583,6 +583,9 @@ class Quark: parent=pdir_fid, ) tree.merge(share_file["fid"], subdir_tree, deep=False) + # 指定文件开始订阅/到达指定文件(含)结束历遍 + if share_file["fid"] == task.get("startfid", ""): + break fid_list = [item["fid"] for item in need_save_list] fid_token_list = [item["share_fid_token"] for item in need_save_list]