WebUI跟进多账号配置

This commit is contained in:
Cp0204 2024-02-28 02:39:55 +08:00
parent 867e6d4a6c
commit e545722b9d
2 changed files with 34 additions and 11 deletions

View File

@ -20,6 +20,8 @@ config_path = os.environ.get("CONFIG_PATH", "./config/quark_config.json")
app = Flask(__name__)
app.secret_key = "ca943f6db6dd34823d36ab08d8d6f65d"
app.config["JSON_AS_ASCII"] = False
app.config["JSON_SORT_KEYS"] = False
app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False
# 设置icon
@ -42,7 +44,7 @@ def read_json():
# 将数据写入 JSON 文件
def write_json(data):
with open(config_path, "w", encoding="utf-8") as f:
json.dump(data, f, indent=4, ensure_ascii=False)
json.dump(data, f, indent=4, ensure_ascii=False, sort_keys=False)
# 登录页面
@ -77,8 +79,7 @@ def logout():
def index():
if not session.get("username"):
return redirect(url_for("login"))
data = read_json()
return render_template("index.html", data=data)
return render_template("index.html")
# 获取配置数据

View File

@ -14,15 +14,28 @@
<h1 class="mb-4">夸克自动转存配置</h1>
<form @submit.prevent="saveConfig">
<h2>Cookie</h2>
<input type="text" v-model="formData.cookie" class="form-control" placeholder="打开 pan.quark.com 抓取"><br>
<div class="row">
<div class="col">
<h2>Cookie</h2>
</div>
<div class="col text-right">
<button type="button" class="btn btn-outline-primary mb-3" @click="addCookie()">+</button>
</div>
</div>
<p>所有账号执行签到,仅第一个账号执行转存,请自行确认顺序。</p>
<div v-for="(value, index) in formData.cookie" :key="index" class="input-group mb-2">
<input type="text" v-model="formData.cookie[index]" class="form-control" placeholder="打开 pan.quark.com 抓取">
<div class="input-group-append">
<button type="button" class="btn btn-outline-danger" @click="removeCookie(index)">-</button>
</div>
</div>
<div class="row">
<div class="col">
<h2>通知</h2>
</div>
<div class="col text-right">
<button type="button" class="btn btn-outline-primary mb-3" @click="addItem()">+</button>
<button type="button" class="btn btn-outline-primary mb-3" @click="addPush()">+</button>
</div>
</div>
<div v-for="(value, key) in formData.push_config" :key="key" class="input-group mb-2">
@ -31,7 +44,7 @@
</div>
<input type="text" v-model="formData.push_config[key]" class="form-control">
<div class="input-group-append">
<button type="button" class="btn btn-outline-danger" @click="removeItem(key)">-</button>
<button type="button" class="btn btn-outline-danger" @click="removePush(key)">-</button>
</div>
</div>
@ -135,7 +148,7 @@
el: '#app',
data: {
formData: {
cookie: "",
cookie: [],
push_config: {},
emby: {
url: "",
@ -143,7 +156,8 @@
},
tasklist: []
}
}, watch: {
},
watch: {
'task.shareurl': function (newVal, oldVal) {
this.task.shareurl_ban = '';
}
@ -155,6 +169,8 @@
fetchData() {
axios.get('/data')
.then(response => {
if (typeof response.data.cookie === 'string')
response.data.cookie = [response.data.cookie];
this.formData = response.data;
})
.catch(error => {
@ -171,12 +187,18 @@
console.error('Error saving config:', error);
});
},
addItem() {
addCookie() {
this.formData.cookie.push("");
},
removeCookie(index) {
this.formData.cookie.splice(index, 1);
},
addPush() {
key = prompt("增加的键名", "");
if (key != "" && key != null)
this.$set(this.formData.push_config, key, "");
},
removeItem(key) {
removePush(key) {
this.$delete(this.formData.push_config, key);
},
addTask() {