-
Notifications
You must be signed in to change notification settings - Fork 8.8k
feat: enable filename search in admin dashboard #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,7 +99,7 @@ | |
| </el-table-column> | ||
| <el-table-column align="right"> | ||
| <template slot="header" slot-scope="scope"> | ||
| <el-input v-model="search" size="mini" placeholder="输入关键字搜索" /> | ||
| <el-input v-model="search" @input="handleSearch" size="mini" placeholder="输入关键字搜索" /> | ||
| </template> | ||
| <template slot-scope="scope"> | ||
| <el-button size="mini" type="primary" @click="handleCopy(scope.$index,scope.row.name)">复制地址</el-button> | ||
|
|
@@ -138,7 +138,8 @@ | |
| id: '' | ||
| }, | ||
| search: '', | ||
| password: '123456' | ||
| password: '123456', | ||
| searchTimer: null | ||
| }, | ||
| methods: { | ||
| handleBlock(index, key) { | ||
|
|
@@ -233,11 +234,33 @@ | |
| type: 'success' | ||
| }); | ||
| }, | ||
| handleSearch() { | ||
| clearTimeout(this.searchTimer); | ||
| this.searchTimer = setTimeout(() => { | ||
| this.tableData = []; | ||
|
||
| this.nextCursor = null; | ||
| const opts = { method: 'GET', redirect: 'follow', credentials: 'include' }; | ||
| const base = this.search | ||
| ? `./api/manage/list?limit=100&prefix=${encodeURIComponent(this.search)}` | ||
| : `./api/manage/list?limit=100`; | ||
| fetch(base, opts) | ||
| .then(r => r.json()) | ||
| .then(result => { | ||
| this.tableData = result.keys || []; | ||
| this.nextCursor = result.list_complete ? null : result.cursor; | ||
| this.Number = this.tableData.length; | ||
| }) | ||
| .catch(() => alert("搜索失败,请检查网络")); | ||
| }, 300); | ||
|
||
| }, | ||
| loadMore() { | ||
| const opts = { method: 'GET', redirect: 'follow', credentials: 'include' }; | ||
| const url = this.nextCursor | ||
| ? `./api/manage/list?cursor=${encodeURIComponent(this.nextCursor)}` | ||
| const base = this.search | ||
| ? `./api/manage/list?limit=100&prefix=${encodeURIComponent(this.search)}` | ||
| : `./api/manage/list?limit=100`; | ||
| const url = this.nextCursor | ||
| ? `${base}&cursor=${encodeURIComponent(this.nextCursor)}` | ||
| : base; | ||
|
|
||
| fetch(url, opts) | ||
| .then(r => r.json()) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The search handler triggers on every input change without debouncing, which could cause excessive API calls while the user is typing. Consider adding a debounce mechanism to delay the search until the user stops typing.