From 2f1754ff0b476c66ce7385088129d19e17477fa5 Mon Sep 17 00:00:00 2001 From: R2m1liA <15258427350@163.com> Date: Thu, 23 Oct 2025 08:45:21 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E9=87=8D=E5=BB=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/meilisearch_module/meili-index.vue | 55 ++++++++++++++++++-------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/src/meilisearch_module/meili-index.vue b/src/meilisearch_module/meili-index.vue index 6ef6628..de57d05 100644 --- a/src/meilisearch_module/meili-index.vue +++ b/src/meilisearch_module/meili-index.vue @@ -15,12 +15,22 @@ + +
请选择希望被 MeiliSearch 索引的集合。 - + " + +
@@ -32,31 +42,44 @@ import { ref, onMounted } from 'vue'; import { useApi } from '@directus/extensions-sdk'; const api = useApi(); -const collections = ref([]); +const configs = ref([]); const headers = [ - { text: '集合名称', value: 'collection' }, - { text: '说明', value: 'note' }, + { text: '集合名称', value: 'collection_name' }, + { text: '索引名称', value: 'index_name' }, { text: '启用索引', value: 'enabled' }, + { text: '操作', value: 'actions', sortable: false }, ]; -// const fetchConfigs = async () => { -// const resp = await api.get('/items/meili_index_configs', { params: { limit: -1 } }); -// configs.value = resp.data.data; -// } +const fetchConfigs = async () => { + const resp = await api.get('/items/meili_index_configs', { params: { limit: -1 } }); + configs.value = resp.data.data; +} + +const handleReindexAll = async () => { + try { + await api.post('/meilisearch/reindex'); + console.log('Reindexing all started successfully'); + } catch (error) { + console.error('Reindexing all failed:', error); + } +} + +const handleReindex = async (item: any) => { + if (!item.enabled) return; + const configId = item.id; + try { + await api.post(`/meilisearch/reindex/${configId}`); + console.log('Reindexing started successfully'); + } catch (error) { + console.error('Reindexing failed:', error); + } -const fetchCollections = async () => { - const resp = await api.get('/meilisearch/collections'); - collections.value = resp.data.map((col: any) => ({ - ...col, - enabled: false, - })); }; const selected = ref(null); onMounted(() => { - fetchCollections(); - // fetchConfigs(); + fetchConfigs(); })