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
cc94927b67
commit
864e2a2978
19
app/run.py
19
app/run.py
@ -212,6 +212,25 @@ def get_share_files():
|
|||||||
return jsonify(share_file_list)
|
return jsonify(share_file_list)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/get_savepath")
|
||||||
|
def get_savepath():
|
||||||
|
if not is_login():
|
||||||
|
return jsonify({"error": "未登录"})
|
||||||
|
data = read_json()
|
||||||
|
account = Quark(data["cookie"][0], 0)
|
||||||
|
if path := request.args.get("path"):
|
||||||
|
if path == "/":
|
||||||
|
fid = 0
|
||||||
|
elif get_fids := account.get_fids([path]):
|
||||||
|
fid = get_fids[0]["fid"]
|
||||||
|
else:
|
||||||
|
return jsonify([])
|
||||||
|
else:
|
||||||
|
fid = request.args.get("fid", 0)
|
||||||
|
file_list = account.ls_dir(fid)
|
||||||
|
return jsonify(file_list)
|
||||||
|
|
||||||
|
|
||||||
# 定时任务执行的函数
|
# 定时任务执行的函数
|
||||||
def run_python(args):
|
def run_python(args):
|
||||||
logging.info(f">>> 定时运行任务")
|
logging.info(f">>> 定时运行任务")
|
||||||
|
|||||||
@ -184,7 +184,20 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-sm-2 col-form-label">保存路径</label>
|
<label class="col-sm-2 col-form-label">保存路径</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input type="text" name="savepath[]" class="form-control" v-model="task.savepath" placeholder="必填">
|
<div class="input-group">
|
||||||
|
<input type="text" name="savepath[]" class="form-control" v-model="task.savepath" placeholder="必填">
|
||||||
|
<div class="input-group-append">
|
||||||
|
<button class="btn btn-outline-secondary dropdown-toggle" type="button" @click="getSavepathDirs(task.savepath)" data-toggle="dropdown" aria-expanded="false">选择</button>
|
||||||
|
<div class="dropdown-menu">
|
||||||
|
<a v-for="(item, key) in savepaths" v-if="item.dir" :class="{'disabled': item.fid === 0}" class="dropdown-item" @click.stop.prevent="selectSavepath(index,item.fid,item.file_name)">
|
||||||
|
<i class="bi bi-folder2"></i> {{ item.file_name }}
|
||||||
|
</a>
|
||||||
|
<span v-if="!savepaths.some(item => item.dir)" class="dropdown-item disabled">
|
||||||
|
无子目录
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
@ -369,6 +382,7 @@
|
|||||||
taskDirs: [""],
|
taskDirs: [""],
|
||||||
taskDirSelected: "",
|
taskDirSelected: "",
|
||||||
taskNameFilter: "",
|
taskNameFilter: "",
|
||||||
|
savepaths: [],
|
||||||
modalLoading: false,
|
modalLoading: false,
|
||||||
shareFiles: [],
|
shareFiles: [],
|
||||||
forceTaskIndex: null
|
forceTaskIndex: null
|
||||||
@ -500,12 +514,33 @@
|
|||||||
clearData(target) {
|
clearData(target) {
|
||||||
this[target] = "";
|
this[target] = "";
|
||||||
},
|
},
|
||||||
|
selectSavepath(index, fid, name) {
|
||||||
|
const savepath = `/${this.formData.tasklist[index].savepath}/${name}`.replace(/\/{2,}/g, '/')
|
||||||
|
Vue.set(this.formData.tasklist[index], 'savepath', savepath);
|
||||||
|
this.getSavepathDirs(fid);
|
||||||
|
},
|
||||||
|
getSavepathDirs(fid = 0) {
|
||||||
|
if (fid.includes('/')) {
|
||||||
|
params = { path: fid }
|
||||||
|
} else {
|
||||||
|
params = { fid: fid }
|
||||||
|
}
|
||||||
|
this.savepaths = [{ fid: 0, dir: true, file_name: "加载中..." }]
|
||||||
|
console.log(this.savepaths)
|
||||||
|
axios.get('/get_savepath', { params: params })
|
||||||
|
.then(response => {
|
||||||
|
this.savepaths = response.data
|
||||||
|
console.log(this.savepaths)
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error get_share_files:', error);
|
||||||
|
});
|
||||||
|
},
|
||||||
selectStartFid(fid) {
|
selectStartFid(fid) {
|
||||||
Vue.set(this.formData.tasklist[this.forceTaskIndex], 'startfid', fid);
|
Vue.set(this.formData.tasklist[this.forceTaskIndex], 'startfid', fid);
|
||||||
$('#shareDetailModal').modal('toggle')
|
$('#shareDetailModal').modal('toggle')
|
||||||
},
|
},
|
||||||
showShareFiles(index) {
|
showShareFiles(index) {
|
||||||
|
|
||||||
this.shareFiles = []
|
this.shareFiles = []
|
||||||
$('#shareDetailModal').modal('toggle')
|
$('#shareDetailModal').modal('toggle')
|
||||||
this.modalLoading = true
|
this.modalLoading = true
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user