Skip to content

Commit e77c06d

Browse files
perf: Optimize the sorting by creation time on the API Key page
1 parent 1190bc3 commit e77c06d

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

backend/apps/system/api/apikey.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from common.utils.time import get_timestamp
99
import secrets
1010

11-
router = APIRouter(tags=["system_apikey"], prefix="/system/apikey")
11+
router = APIRouter(tags=["system_apikey"], prefix="/system/apikey", include_in_schema=False)
1212

1313
@router.get("")
1414
async def grid(session: SessionDep, current_user: CurrentUser) -> list[ApikeyGridItem]:

frontend/src/components/layout/Apikey.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ const deleteHandler = (row: any) => {
8080
},
8181
})
8282
}
83+
const sortChange = (param: any) => {
84+
if (param?.order === 'ascending') {
85+
state.tableData.sort((a: any, b: any) => a.create_time - b.create_time)
86+
} else {
87+
state.tableData.sort((a: any, b: any) => b.create_time - a.create_time)
88+
}
89+
}
8390
const loadGridData = () => {
8491
request.get('/system/apikey').then((res: any) => {
8592
state.tableData = res || []
@@ -133,7 +140,12 @@ onMounted(() => {
133140
</el-button>
134141
</div>
135142
<div class="api-key-grid">
136-
<el-table ref="multipleTableRef" :data="state.tableData" style="width: 100%">
143+
<el-table
144+
ref="multipleTableRef"
145+
:data="state.tableData"
146+
style="width: 100%"
147+
@sort-change="sortChange"
148+
>
137149
<el-table-column prop="access_key" label="Access Key" width="256">
138150
<template #default="scope">
139151
<div class="user-status-container">

0 commit comments

Comments
 (0)