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();
})