This commit is contained in:
ZaneYork 2024-09-13 08:28:41 +08:00
parent aefcaf4311
commit 3fa5d3c637
3 changed files with 21 additions and 8 deletions

View File

@ -21,11 +21,13 @@ def get_user_menu() -> tuple[str, str]:
row = cursor.fetchone()
if row:
return row[0], row[1]
# else:
# cursor.execute("select menu from user_menu where user = ? order by datestr desc limit 1", (user,))
# row = cursor.fetchone()
# if row:
# return row[0]
else:
cursor.execute(
"select menu, nickname from user_menu where user = ? and nickname is not null order by datestr desc limit 1",
(user,))
row = cursor.fetchone()
if row:
return '{}', row[1]
return '', ''
finally:
cursor.close()

View File

@ -166,6 +166,7 @@ def dinner():
predict_result = roll_logic(check=True)
else:
predict_result = None
recent_results = list(fetch_roll_result_list(-1, 7))
return render_template('dinner.html',
all_choice=all_choice,
menu=menu,
@ -177,4 +178,5 @@ def dinner():
result=result,
predict_result=predict_result,
can_roll=can_roll,
last_results=last_results)
last_results=last_results,
recent_results=recent_results)

View File

@ -12,7 +12,7 @@
{% for last_result in last_results %}
<p>今日{{ last_result }}最终得票数降低{{ 2 + loop.index0 }}0%</p>
{% endfor %}
<form id="inputForm" class="form-inline">
<form id="inputForm" class="form-inline" onsubmit="return false;">
<div class="form-group">
<div class="input-group mb-3">
<label class="input-group-text" for="inputName" id="basic-addon1">姓名</label>
@ -58,7 +58,7 @@
</div>
{% if (users|length) > 3 %}
<div class="pt-1 mb-3">
<label>参与投票人员</label>
<label class="mb-2">参与投票人员</label>
<ul class="list-group list-group-horizontal">
{% for user in users %}
<li class="list-group-item">{{ user }}</li>
@ -66,6 +66,14 @@
</ul>
</div>
{% endif %}
<div class="pt-1 mb-3">
<label class="mb-2">最近点餐结果</label>
<ul class="list-group list-group-horizontal">
{% for recent_result in recent_results %}
<li class="list-group-item">{{ recent_result }}</li>
{% endfor %}
</ul>
</div>
<footer class="footer mt-auto py-3 bg-light">
<div class="container">
<div class="row">
@ -92,6 +100,7 @@
document.addEventListener('keydown', function (event) {
if (event.key === 'Enter' || event.keyCode === 13) {
update();
return false;
}
});
$("input[type=range]").change(function () {