Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -138,7 +138,8 @@
id: ''
},
search: '',
password: '123456'
password: '123456',
searchTimer: null
},
methods: {
handleBlock(index, key) {
Expand Down Expand Up @@ -233,11 +234,33 @@
type: 'success'
});
},
handleSearch() {
Copy link

Copilot AI Aug 15, 2025

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.

Copilot uses AI. Check for mistakes.
clearTimeout(this.searchTimer);
this.searchTimer = setTimeout(() => {
this.tableData = [];
Copy link

Copilot AI Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearing tableData on every search creates a jarring UX where the table flickers empty before results load. Consider showing a loading state instead of clearing the data immediately.

Copilot uses AI. Check for mistakes.
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);
Copy link

Copilot AI Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The debounce delay of 300ms is a magic number. Consider defining it as a constant at the top of the data section for better maintainability.

Copilot uses AI. Check for mistakes.
},
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())
Expand Down
3 changes: 2 additions & 1 deletion functions/api/manage/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export async function onRequest(context) {
if (limit > 1000) limit = 1000;

const cursor = url.searchParams.get("cursor") || undefined;
const value = await env.img_url.list({ limit, cursor });
const prefix = url.searchParams.get("prefix") || undefined;
const value = await env.img_url.list({ limit, cursor, prefix });

return new Response(JSON.stringify(value), {
headers: { "Content-Type": "application/json" }
Expand Down