WebUI 支持星期指定

This commit is contained in:
Cp0204 2024-03-29 02:35:41 +08:00
parent a5729f8eef
commit 3dd7aa361c
2 changed files with 293 additions and 272 deletions

View File

@ -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") config_path = os.environ.get("CONFIG_PATH", "./config/quark_config.json")
app = Flask(__name__) app = Flask(__name__)
app.config["APP_VERSION"] = "0.2.4.1" app.config["APP_VERSION"] = "0.2.5"
app.secret_key = "ca943f6db6dd34823d36ab08d8d6f65d" app.secret_key = "ca943f6db6dd34823d36ab08d8d6f65d"
app.json.ensure_ascii = False app.json.ensure_ascii = False
app.json.sort_keys = False app.json.sort_keys = False
app.jinja_env.variable_start_string = '[['
app.jinja_env.variable_end_string = ']]'
def gen_md5(string): def gen_md5(string):
@ -172,7 +174,8 @@ def reload_tasks():
) )
if scheduler.state == 2: if scheduler.state == 2:
scheduler.resume() # 恢复调度器 scheduler.resume() # 恢复调度器
else:
print(">>> no crontab")
def init(): def init():
# 检查配置文件是否存在 # 检查配置文件是否存在

View File

@ -132,6 +132,15 @@
<input type="date" name="enddate[]" class="form-control mb-2" v-model="task.enddate" placeholder="可选"> <input type="date" name="enddate[]" class="form-control mb-2" v-model="task.enddate" placeholder="可选">
</div> </div>
</div> </div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">运行星期</label>
<div class="col-sm-10">
<div class="form-check form-check-inline" v-for="(day, index) in weekdays" :key="index">
<input class="form-check-input" type="checkbox" v-model="task.runweek" :value="index+1">
<label class="form-check-label" v-html="day"></label>
</div>
</div>
</div>
<div class="form-group row"> <div class="form-group row">
<label class="col-sm-2 col-form-label">Emby ID</label> <label class="col-sm-2 col-form-label">Emby ID</label>
<div class="col-sm-10"> <div class="col-sm-10">
@ -148,7 +157,7 @@
</form> </form>
<div class="text-center"> <div class="text-center">
<p> <p>
<a target="_blank" href="https://github.com/Cp0204/quark-auto-save">@Cp0204/quark_auto_save</a> v{{ version }} <a target="_blank" href="https://github.com/Cp0204/quark-auto-save">@Cp0204/quark_auto_save</a> v[[ version ]]
</p> </p>
</div> </div>
@ -184,6 +193,7 @@
var app = new Vue({ var app = new Vue({
el: '#app', el: '#app',
data: { data: {
weekdays: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
formData: { formData: {
cookie: [], cookie: [],
push_config: {}, push_config: {},
@ -196,18 +206,17 @@
run_log: "" run_log: ""
}, },
watch: { watch: {
'task.shareurl': function () {
this.task.shareurl_ban = '';
},
'formData.push_config': { 'formData.push_config': {
handler: function (newVal, oldVal) { handler: function (newVal, oldVal) {
for (key in newVal) { for (key in newVal) {
if (newVal[key] === 'string') {
if (newVal[key].toLowerCase() === 'false') { if (newVal[key].toLowerCase() === 'false') {
this.$set(this.formData.push_config, key, false); this.$set(this.formData.push_config, key, false);
} else if (newVal[key].toLowerCase() === 'true') { } else if (newVal[key].toLowerCase() === 'true') {
this.$set(this.formData.push_config, key, true); this.$set(this.formData.push_config, key, true);
} }
} }
}
}, },
deep: true deep: true
} }
@ -219,8 +228,16 @@
fetchData() { fetchData() {
axios.get('/data') axios.get('/data')
.then(response => { .then(response => {
// cookie兼容
if (typeof response.data.cookie === 'string') if (typeof response.data.cookie === 'string')
response.data.cookie = [response.data.cookie]; 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; this.formData = response.data;
}) })
.catch(error => { .catch(error => {
@ -261,7 +278,8 @@
pattern: "", pattern: "",
replace: "", replace: "",
enddate: "", enddate: "",
emby_id: "" emby_id: "",
runweek: [1, 2, 3, 4, 5, 6, 7]
}); });
}, },
removeTask(index) { removeTask(index) {