Skip to content

Commit 60a2e85

Browse files
优化
1 parent 37591ea commit 60a2e85

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

p/index.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
</div>
2929
<div id="bottons">
3030
<label for="auto">自动:</label><input id="auto" type="button" value="关闭"/>
31-
<input id="prev" type="button" value="上一张" style="margin-left:105px"/>
31+
<input id="save" type="button" value="保存"/>
32+
<input id="load" type="button" value="加载"/>
33+
<input id="prev" type="button" value="上一张" style="margin-left:50px"/>
3234
<input id="next" type="button" value="下一张"/>
3335
</div>
3436
</div>

p/index.js

+17
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const count = document.getElementById("count"); // 图片数
77
const loading = document.getElementById("loading"); // loading效果
88

99
const auto = document.getElementById("auto"); // 自动
10+
const save = document.getElementById("save"); // 保存
11+
const load = document.getElementById("load"); // 加载
1012
const prev = document.getElementById("prev"); // 上一张
1113
const next = document.getElementById("next"); // 下一张
1214

@@ -57,6 +59,21 @@ let inFocus = false; // 输入框是否获取到了焦点
5759
}
5860
});
5961

62+
// “保存” 按钮点击事件
63+
save.addEventListener("click", function () {
64+
if (input.value > 0) {
65+
localStorage.setItem("savePid", input.value);
66+
}
67+
});
68+
// “加载” 按钮点击事件
69+
load.addEventListener("click", function () {
70+
const savePid = localStorage.getItem("savePid") - 0;
71+
if (savePid > 0) {
72+
input.value = savePid;
73+
doEnter(savePid, false);
74+
}
75+
});
76+
6077
// “上一张” 按钮点击事件
6178
prev.addEventListener("click", doPrev);
6279

0 commit comments

Comments
 (0)