Skip to content

Commit

Permalink
WebUI跟进多账号配置
Browse files Browse the repository at this point in the history
  • Loading branch information
Cp0204 committed Feb 27, 2024
1 parent e1ca2a5 commit d6b23bb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
7 changes: 4 additions & 3 deletions app/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
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
Expand All @@ -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)


# 登录页面
Expand Down Expand Up @@ -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")


# 获取配置数据
Expand Down
38 changes: 30 additions & 8 deletions app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -31,7 +44,7 @@ <h2>通知</h2>
</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>

Expand Down Expand Up @@ -135,15 +148,16 @@ <h3>任务#<span v-html="index+1"></span></h3>
el: '#app',
data: {
formData: {
cookie: "",
cookie: [],
push_config: {},
emby: {
url: "",
apikey: ""
},
tasklist: []
}
}, watch: {
},
watch: {
'task.shareurl': function (newVal, oldVal) {
this.task.shareurl_ban = '';
}
Expand All @@ -155,6 +169,8 @@ <h3>任务#<span v-html="index+1"></span></h3>
fetchData() {
axios.get('/data')
.then(response => {
if (typeof response.data.cookie === 'string')
response.data.cookie = [response.data.cookie];
this.formData = response.data;
})
.catch(error => {
Expand All @@ -171,12 +187,18 @@ <h3>任务#<span v-html="index+1"></span></h3>
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() {
Expand Down

0 comments on commit d6b23bb

Please sign in to comment.