mirror of https://github.com/halo-dev/halo
feat: add support for refreshing search engine indexes (#3475)
#### What type of PR is this? /kind feature #### What this PR does / why we need it: 在 Console 端仪表盘的快捷访问中添加刷新搜索引擎索引的入口。  #### Special notes for your reviewer: 1. 测试仪表盘快捷访问中的刷新搜索引擎操作是否可以正常调用接口即可。 2. 分配一个不包含文章管理权限的角色给某个用户,检查是否可以看到这个刷新的入口。 #### Does this PR introduce a user-facing change? ```release-note Console 端仪表盘的快捷访问中添加刷新搜索引擎索引的入口。 ```pull/3441/head^2
parent
80a3fa803f
commit
4ba3cfb64d
|
@ -8,12 +8,16 @@ import {
|
||||||
IconUserSettings,
|
IconUserSettings,
|
||||||
IconPalette,
|
IconPalette,
|
||||||
IconWindowLine,
|
IconWindowLine,
|
||||||
|
IconSearch,
|
||||||
VCard,
|
VCard,
|
||||||
IconUserLine,
|
IconUserLine,
|
||||||
|
Dialog,
|
||||||
|
Toast,
|
||||||
} from "@halo-dev/components";
|
} from "@halo-dev/components";
|
||||||
import { markRaw, ref, type Component } from "vue";
|
import { markRaw, ref, type Component } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import ThemePreviewModal from "@/modules/interface/themes/components/preview/ThemePreviewModal.vue";
|
import ThemePreviewModal from "@/modules/interface/themes/components/preview/ThemePreviewModal.vue";
|
||||||
|
import { apiClient } from "@/utils/api-client";
|
||||||
|
|
||||||
interface Action {
|
interface Action {
|
||||||
icon: Component;
|
icon: Component;
|
||||||
|
@ -111,6 +115,21 @@ const actions: Action[] = [
|
||||||
},
|
},
|
||||||
permissions: ["system:users:manage"],
|
permissions: ["system:users:manage"],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
icon: markRaw(IconSearch),
|
||||||
|
title: "刷新搜索引擎",
|
||||||
|
action: () => {
|
||||||
|
Dialog.warning({
|
||||||
|
title: "确定要刷新搜索引擎索引吗?",
|
||||||
|
description: "此操作会对所有已发布的文章重新创建搜索引擎索引。",
|
||||||
|
onConfirm: async () => {
|
||||||
|
await apiClient.indices.buildPostIndices();
|
||||||
|
Toast.success("刷新成功");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
permissions: ["system:posts:manage"],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -8,6 +8,7 @@ import {
|
||||||
ApiConsoleHaloRunV1alpha1ReplyApi,
|
ApiConsoleHaloRunV1alpha1ReplyApi,
|
||||||
ApiConsoleHaloRunV1alpha1StatsApi,
|
ApiConsoleHaloRunV1alpha1StatsApi,
|
||||||
ApiConsoleHaloRunV1alpha1AttachmentApi,
|
ApiConsoleHaloRunV1alpha1AttachmentApi,
|
||||||
|
ApiConsoleHaloRunV1alpha1IndicesApi,
|
||||||
ContentHaloRunV1alpha1CategoryApi,
|
ContentHaloRunV1alpha1CategoryApi,
|
||||||
ContentHaloRunV1alpha1CommentApi,
|
ContentHaloRunV1alpha1CommentApi,
|
||||||
ContentHaloRunV1alpha1PostApi,
|
ContentHaloRunV1alpha1PostApi,
|
||||||
|
@ -183,6 +184,7 @@ function setupApiClient(axios: AxiosInstance) {
|
||||||
baseURL,
|
baseURL,
|
||||||
axios
|
axios
|
||||||
),
|
),
|
||||||
|
indices: new ApiConsoleHaloRunV1alpha1IndicesApi(undefined, baseURL, axios),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ rules:
|
||||||
resources: [ "posts" ]
|
resources: [ "posts" ]
|
||||||
verbs: [ "*" ]
|
verbs: [ "*" ]
|
||||||
- apiGroups: [ "api.console.halo.run" ]
|
- apiGroups: [ "api.console.halo.run" ]
|
||||||
resources: [ "posts", "posts/publish", "posts/unpublish", "posts/recycle", "posts/content" ]
|
resources: [ "posts", "posts/publish", "posts/unpublish", "posts/recycle", "posts/content", "indices/post" ]
|
||||||
verbs: [ "create", "patch", "update", "delete", "deletecollection" ]
|
verbs: [ "create", "patch", "update", "delete", "deletecollection" ]
|
||||||
---
|
---
|
||||||
apiVersion: v1alpha1
|
apiVersion: v1alpha1
|
||||||
|
|
Loading…
Reference in New Issue