From 3dd7aa361c318e544d0e4703be4d4ae278842336 Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Fri, 29 Mar 2024 02:35:41 +0800 Subject: [PATCH] =?UTF-8?q?WebUI=20=E6=94=AF=E6=8C=81=E6=98=9F=E6=9C=9F?= =?UTF-8?q?=E6=8C=87=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/run.py | 7 +- app/templates/index.html | 558 ++++++++++++++++++++------------------- 2 files changed, 293 insertions(+), 272 deletions(-) diff --git a/app/run.py b/app/run.py index 02b9888..891fc2d 100644 --- a/app/run.py +++ b/app/run.py @@ -25,10 +25,12 @@ script_path = os.environ.get("SCRIPT_PATH", "./quark_auto_save.py") config_path = os.environ.get("CONFIG_PATH", "./config/quark_config.json") app = Flask(__name__) -app.config["APP_VERSION"] = "0.2.4.1" +app.config["APP_VERSION"] = "0.2.5" app.secret_key = "ca943f6db6dd34823d36ab08d8d6f65d" app.json.ensure_ascii = False app.json.sort_keys = False +app.jinja_env.variable_start_string = '[[' +app.jinja_env.variable_end_string = ']]' def gen_md5(string): @@ -172,7 +174,8 @@ def reload_tasks(): ) if scheduler.state == 2: scheduler.resume() # 恢复调度器 - + else: + print(">>> no crontab") def init(): # 检查配置文件是否存在 diff --git a/app/templates/index.html b/app/templates/index.html index 0c47539..7f4f28e 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -2,290 +2,308 @@ - - - 夸克自动转存 - - - + .bottom-buttons { + position: fixed; + left: 0; + bottom: 0; + width: 100%; + background-color: #f1f1f1; + padding: 10px 0; + text-align: center; + } + -
-

夸克自动转存配置

-
+
+

夸克自动转存配置

+ -
-
-

Cookie

-
-
- -
-
-

所有账号执行签到,仅第一个账号执行转存,请自行确认顺序。

-
- -
- -
-
- -
-
-

通知

-
-
- -
-
-
-
- -
- -
- -
-
- -

Emby

-
- -
- -
-
-
- -
- -
-
- -

定时规则

-
- -
- -
-
- -

任务列表

-
-
-
-

任务#

-
-
- -
-
- -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- - 运行 - 退出 -
- -
-

- @Cp0204/quark_auto_save v{{ version }} -

+
+
+

Cookie

- - - +

所有账号执行签到,仅第一个账号执行转存,请自行确认顺序。

+
+ +
+ +
+
+
+
+

通知

+
+
+ +
+
+
+
+ +
+ +
+ +
+
+ +

Emby

+
+ +
+ +
+
+
+ +
+ +
+
+ +

定时规则

+
+ +
+ +
+
+ +

任务列表

+
+
+
+

任务#

+
+
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+ + 运行 + 退出 +
+ +
+

+ @Cp0204/quark_auto_save v[[ version ]] +

- - - - + + - - - +
- + + + + + + + + + }, + deep: true + } + }, + mounted() { + this.fetchData(); + }, + methods: { + fetchData() { + axios.get('/data') + .then(response => { + // cookie兼容 + if (typeof response.data.cookie === 'string') + response.data.cookie = [response.data.cookie]; + // 星期运行兼容 + response.data.tasklist = response.data.tasklist.map(task => { + if (!task.hasOwnProperty('runweek')) { + task.runweek = [1, 2, 3, 4, 5, 6, 7]; + } + return task; + }); + this.formData = response.data; + }) + .catch(error => { + console.error('Error fetching data:', error); + }); + }, + saveConfig() { + axios.post('/update', this.formData) + .then(response => { + alert(response.data); + console.log('Config saved successfully:', response.data); + }) + .catch(error => { + console.error('Error saving config:', error); + }); + }, + addCookie() { + this.formData.cookie.push(""); + }, + removeCookie(index) { + if (confirm("确认删除吗?")) + this.formData.cookie.splice(index, 1); + }, + addPush() { + key = prompt("增加的键名", ""); + if (key != "" && key != null) + this.$set(this.formData.push_config, key, ""); + }, + removePush(key) { + if (confirm("确认删除吗?")) + this.$delete(this.formData.push_config, key); + }, + addTask() { + this.formData.tasklist.push({ + taskname: "", + shareurl: "", + savepath: "", + pattern: "", + replace: "", + enddate: "", + emby_id: "", + runweek: [1, 2, 3, 4, 5, 6, 7] + }); + }, + removeTask(index) { + if (confirm("确认删除吗?")) + this.formData.tasklist.splice(index, 1); + }, + clearShareurlBan(task) { + delete task.shareurl_ban; + }, + runScriptNow() { + $('#logModal').modal('toggle') + this.run_log = "请耐心等待脚本全部执行完毕..." + axios.post('/run_script_now') + .then(response => { + this.run_log = response.data; + }) + .catch(error => { + this.run_log = "错误:\n" + error + console.error('Error:', error); + }); + } + } + }); + \ No newline at end of file