mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-12 07:10:44 +08:00
✨ 添加从指定文件开始订阅的功能
This commit is contained in:
parent
8a17eff4e3
commit
d2ea724ba2
17
app/run.py
17
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">>> 定时运行任务")
|
||||
|
||||
@ -207,6 +207,17 @@
|
||||
</datalist>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2 col-form-label">文件开始</label>
|
||||
<div class="col-sm-10">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="可选" name="startfid[]" v-model="task.startfid">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-outline-secondary" type="button" @click="showShareFiles(index)">选择</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2 col-form-label">更子目录</label>
|
||||
<div class="col-sm-10">
|
||||
@ -277,6 +288,45 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 模态框 分享文件列表 -->
|
||||
<div class="modal" tabindex="-1" id="shareDetailModal">
|
||||
<div class="modal-dialog modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><b>分享文件列表</b>
|
||||
<div v-if="modalLoading" class="spinner-border spinner-border-sm m-1" role="status"></div>
|
||||
</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<table class="table table-hover table-sm" v-if="!modalLoading" title="请选择转存起始文件,将只转存修改日期>选中文件的文件">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- <th scope="col">fid</th> -->
|
||||
<th scope="col">文件名</th>
|
||||
<th scope="col">大小</th>
|
||||
<th scope="col">修改日期 ↓</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="4"><i class="bi bi-folder-plus"></i> 后续更新的文件...</td>
|
||||
</tr>
|
||||
<tr v-for="(file, key) in shareFiles" :key="key" @click="selectStartFid(file.fid)" style="cursor: pointer;">
|
||||
<!-- <td>{{file.fid}}</td> -->
|
||||
<td><i v-if="file.dir==true" class="bi bi-folder2"></i><i v-if="file.dir==false" class="bi bi-file-earmark"></i> {{file.file_name}}</td>
|
||||
<td>{{file.size | size}}</td>
|
||||
<td>{{file.last_update_at | ts2date}}</td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 引入 Bootstrap JS -->
|
||||
@ -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
|
||||
|
||||
@ -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]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user