Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f56dbab

Browse files
committed
feat: add backtop
1 parent 63846e7 commit f56dbab

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎src/composables/crud.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useGet, usePost, usePut, useDelete } from './index'
33
import {
44
appMessage,
55
appConfirm,
6+
backtop,
67
replaceId,
78
RequestPageKey,
89
RequestLimitkey,
@@ -246,6 +247,7 @@ export function useList<Item = StringObject, Serach = Item>({
246247
await execute()
247248

248249
if (data.value) {
250+
backtop()
249251
list.value = data.value.list
250252
total.value = data.value.total
251253
}

‎src/utils/public.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isClient } from '@vueuse/core'
12
import { ElMessage, ElMessageBox } from 'element-plus'
23
import type {
34
MessageOptions,
@@ -97,3 +98,14 @@ export function createDownload(blob: Blob, name?: string): void {
9798
document.body.removeChild(tempLink)
9899
window.URL.revokeObjectURL(blobURL)
99100
}
101+
102+
/** 返回顶部 */
103+
export function backtop() {
104+
if (isClient) {
105+
window.scrollTo({
106+
left: 0,
107+
top: 0,
108+
behavior: 'smooth',
109+
})
110+
}
111+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /