聪明的页面滚动

This commit is contained in:
Cp0204 2024-04-03 17:43:48 +08:00
parent 86f83e900c
commit d3d60e48d9
4 changed files with 18 additions and 18 deletions

7
app/static/js/bootstrap.bundle.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -198,7 +198,7 @@
<div class="bottom-buttons"> <div class="bottom-buttons">
<button class="btn btn-success"><i class="bi bi-save"></i> 保存</button> <button class="btn btn-success"><i class="bi bi-save"></i> 保存</button>
<a class="btn btn-primary" @click="runScriptNow"><i class="bi bi-play-fill"></i> 运行</a> <a class="btn btn-primary" @click="runScriptNow"><i class="bi bi-play-fill"></i> 运行</a>
<a class="btn btn-info" @click="scrollToTop" ><i class="bi bi-chevron-bar-up"></i> 回顶</a> <a class="btn btn-info" @click="scrollToX(0)" @dblclick="scrollToX()" data-toggle="tooltip" data-placement="top" title="单击回顶,双击到底"><i class="bi bi-chevron-bar-up"></i> 回顶</a>
<a class="btn btn-danger" href="/logout"><i class="bi bi-box-arrow-right"></i> 退出</a> <a class="btn btn-danger" href="/logout"><i class="bi bi-box-arrow-right"></i> 退出</a>
</div> </div>
</form> </form>
@ -224,8 +224,7 @@
<!-- 引入 Bootstrap JS --> <!-- 引入 Bootstrap JS -->
<script src="./static/js/jquery-3.5.1.slim.min.js"></script> <script src="./static/js/jquery-3.5.1.slim.min.js"></script>
<script src="./static/js/popper.min.js"></script> <script src="./static/js/bootstrap.bundle.min.js"></script>
<script src="./static/js/bootstrap.min.js"></script>
<!-- 引入 Vue.js --> <!-- 引入 Vue.js -->
<script src="./static/js/vue@2.js"></script> <script src="./static/js/vue@2.js"></script>
@ -278,6 +277,7 @@
}, },
mounted() { mounted() {
this.fetchData(); this.fetchData();
$('[data-toggle="tooltip"]').tooltip()
}, },
methods: { methods: {
fetchData() { fetchData() {
@ -336,6 +336,10 @@
newTask.taskname = this.taskNameFilter newTask.taskname = this.taskNameFilter
newTask.savepath = this.taskDirSelected + "/" + newTask.taskname newTask.savepath = this.taskDirSelected + "/" + newTask.taskname
this.formData.tasklist.push(newTask); this.formData.tasklist.push(newTask);
// 滚到最下
setTimeout(() => {
this.scrollToX();
}, 1);
}, },
removeTask(index) { removeTask(index) {
if (confirm("确认删除吗?")) if (confirm("确认删除吗?"))
@ -362,9 +366,11 @@
parentDir = "/" parentDir = "/"
return parentDir; return parentDir;
}, },
scrollToTop() { scrollToX(top = undefined) {
if (top == undefined)
top = document.documentElement.scrollHeight
window.scrollTo({ window.scrollTo({
top: 0, top: top,
behavior: "smooth" behavior: "smooth"
}); });
} }