Skip to content

Commit 126552a

Browse files
committed
1 parent 8c9df5e commit 126552a

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

pages/browser/index.vue

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,29 @@
44
<template #title>
55
<h1 class="text-2xl font-bold">桶</h1>
66
</template>
7-
<template #actions>
8-
<n-button @click="() => (formVisible = true)">
9-
<Icon name="ri:add-line" class="mr-2" />
10-
<span>创建桶</span>
11-
</n-button>
12-
</template>
137
</page-header>
148
<page-content class="flex flex-col gap-4">
159
<div class="flex items-center justify-between">
1610
<div class="flex items-center justify-between">
17-
<n-input placeholder="搜索">
11+
<n-input v-model:value="searchTerm" placeholder="搜索">
1812
<template #prefix>
1913
<Icon name="ri:search-2-line" />
2014
</template>
2115
</n-input>
2216
</div>
17+
2318
<div class="flex items-center gap-4">
19+
<n-button @click="() => (formVisible = true)">
20+
<Icon name="ri:add-line" class="mr-2" />
21+
<span>创建桶</span>
22+
</n-button>
2423
<n-button @click="async () => refresh()">
2524
<Icon name="ri:refresh-line" class="mr-2" />
2625
<span>刷新</span>
2726
</n-button>
2827
</div>
2928
</div>
30-
<n-data-table class="border dark:border-neutral-700 rounded overflow-hidden" :columns="columns" :data="data" :pagination="false" :bordered="false" />
29+
<n-data-table class="border dark:border-neutral-700 rounded overflow-hidden" :columns="columns" :data="filteredData" :pagination="false" :bordered="false" />
3130
</page-content>
3231

3332
<buckets-new-form :show="formVisible" @update:show="handleFormClosed"></buckets-new-form>
@@ -41,6 +40,7 @@ import { useRouter } from 'vue-router'
4140
4241
const { listBuckets } = useBucket({});
4342
const formVisible = ref(false);
43+
const searchTerm = ref('');
4444
4545
interface RowData {
4646
Name: string;
@@ -110,6 +110,17 @@ const { data, refresh } = await useAsyncData(
110110
{ default: () => [] }
111111
);
112112
113+
const filteredData = computed(() => {
114+
if (!searchTerm.value) {
115+
return data.value;
116+
}
117+
118+
const term = searchTerm.value.toLowerCase();
119+
return data.value.filter(bucket =>
120+
bucket.Name?.toLowerCase().includes(term)
121+
);
122+
});
123+
113124
const router = useRouter();
114125
const handleRowClick = (row: RowData) => {
115126
router.push({

0 commit comments

Comments
 (0)