This commit is contained in:
parent
35864176ed
commit
b189b282d3
15
app.py
15
app.py
|
|
@ -147,3 +147,18 @@ def set_customer_data(data):
|
||||||
customer_data = data
|
customer_data = data
|
||||||
else:
|
else:
|
||||||
raise ValueError("Data must be a list of dictionaries.")
|
raise ValueError("Data must be a list of dictionaries.")
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/customer/top')
|
||||||
|
def view_top_customer():
|
||||||
|
# 跳转到数据库的第一条记录
|
||||||
|
return redirect(url_for('view_customer', index=0))
|
||||||
|
|
||||||
|
@app.route('/customer/bottom')
|
||||||
|
def view_bottom_customer():
|
||||||
|
# 跳转到数据库的最后一条记录
|
||||||
|
if not customer_data:
|
||||||
|
return "No customer data available.", 400
|
||||||
|
|
||||||
|
last_index = len(customer_data) - 1 # 计算最后一条记录的索引
|
||||||
|
return redirect(url_for('view_customer', index=last_index))
|
||||||
|
|
@ -36,11 +36,11 @@
|
||||||
|
|
||||||
<!-- 新增导航按钮 -->
|
<!-- 新增导航按钮 -->
|
||||||
<div>
|
<div>
|
||||||
<!-- 跳转到顶部按钮 -->
|
<!-- 跳转到数据库的第一条记录按钮 -->
|
||||||
<button onclick="scrollToTop()">Go to Top</button>
|
<button onclick="goToTop()">Go to Top</button>
|
||||||
|
|
||||||
<!-- 跳转到底部按钮 -->
|
<!-- 跳转到数据库的最后一条记录按钮 -->
|
||||||
<button onclick="scrollToBottom()">Go to Bottom</button>
|
<button onclick="goToBottom()">Go to Bottom</button>
|
||||||
|
|
||||||
<!-- 跳转到指定页面的输入框和按钮 -->
|
<!-- 跳转到指定页面的输入框和按钮 -->
|
||||||
<input type="number" id="pageIndex" placeholder="Enter page number">
|
<input type="number" id="pageIndex" placeholder="Enter page number">
|
||||||
|
|
@ -61,14 +61,14 @@
|
||||||
|
|
||||||
<!-- JavaScript 脚本 -->
|
<!-- JavaScript 脚本 -->
|
||||||
<script>
|
<script>
|
||||||
// 跳转到顶部
|
// 跳转到数据库的第一条记录
|
||||||
function scrollToTop() {
|
function goToTop() {
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
window.location.href = "/customer/top"; // 跳转到后端“Top”路由
|
||||||
}
|
}
|
||||||
|
|
||||||
// 跳转到底部
|
// 跳转到数据库的最后一条记录
|
||||||
function scrollToBottom() {
|
function goToBottom() {
|
||||||
window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' });
|
window.location.href = "/customer/bottom"; // 跳转到后端“Bottom”路由
|
||||||
}
|
}
|
||||||
|
|
||||||
// 跳转到指定页面
|
// 跳转到指定页面
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue