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() row = cursor.fetchone()
if row: if row:
return row[0], row[1] return row[0], row[1]
# else: else:
# cursor.execute("select menu from user_menu where user = ? order by datestr desc limit 1", (user,)) cursor.execute(
# row = cursor.fetchone() "select menu, nickname from user_menu where user = ? and nickname is not null order by datestr desc limit 1",
# if row: (user,))
# return row[0] row = cursor.fetchone()
if row:
return '{}', row[1]
return '', '' return '', ''
finally: finally:
cursor.close() cursor.close()

View File

@ -166,6 +166,7 @@ def dinner():
predict_result = roll_logic(check=True) predict_result = roll_logic(check=True)
else: else:
predict_result = None predict_result = None
recent_results = list(fetch_roll_result_list(-1, 7))
return render_template('dinner.html', return render_template('dinner.html',
all_choice=all_choice, all_choice=all_choice,
menu=menu, menu=menu,
@ -177,4 +178,5 @@ def dinner():
result=result, result=result,
predict_result=predict_result, predict_result=predict_result,
can_roll=can_roll, 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 %} {% for last_result in last_results %}
<p>今日{{ last_result }}最终得票数降低{{ 2 + loop.index0 }}0%</p> <p>今日{{ last_result }}最终得票数降低{{ 2 + loop.index0 }}0%</p>
{% endfor %} {% endfor %}
<form id="inputForm" class="form-inline"> <form id="inputForm" class="form-inline" onsubmit="return false;">
<div class="form-group"> <div class="form-group">
<div class="input-group mb-3"> <div class="input-group mb-3">
<label class="input-group-text" for="inputName" id="basic-addon1">姓名</label> <label class="input-group-text" for="inputName" id="basic-addon1">姓名</label>
@ -58,7 +58,7 @@
</div> </div>
{% if (users|length) > 3 %} {% if (users|length) > 3 %}
<div class="pt-1 mb-3"> <div class="pt-1 mb-3">
<label>参与投票人员</label> <label class="mb-2">参与投票人员</label>
<ul class="list-group list-group-horizontal"> <ul class="list-group list-group-horizontal">
{% for user in users %} {% for user in users %}
<li class="list-group-item">{{ user }}</li> <li class="list-group-item">{{ user }}</li>
@ -66,6 +66,14 @@
</ul> </ul>
</div> </div>
{% endif %} {% 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"> <footer class="footer mt-auto py-3 bg-light">
<div class="container"> <div class="container">
<div class="row"> <div class="row">
@ -92,6 +100,7 @@
document.addEventListener('keydown', function (event) { document.addEventListener('keydown', function (event) {
if (event.key === 'Enter' || event.keyCode === 13) { if (event.key === 'Enter' || event.keyCode === 13) {
update(); update();
return false;
} }
}); });
$("input[type=range]").change(function () { $("input[type=range]").change(function () {