diff --git a/packages/client/src/pages/admin/database.vue b/packages/client/src/pages/admin/database.vue index f665d3813..4154e9090 100644 --- a/packages/client/src/pages/admin/database.vue +++ b/packages/client/src/pages/admin/database.vue @@ -43,29 +43,7 @@ import bytes from "@/filters/bytes"; import number from "@/filters/number"; import { i18n } from "@/i18n"; import { definePageMetadata } from "@/scripts/page-metadata"; - -async function indexPosts() { - const { canceled, result: index } = await os.inputText({ - title: i18n.ts.indexFrom, - }); - if (canceled) return; - - if (index == null || index === "") { - await os.api("admin/search/index-all"); - await os.alert({ - type: "info", - text: i18n.ts.indexNotice, - }); - } else { - await os.api("admin/search/index-all", { - cursor: index, - }); - await os.alert({ - type: "info", - text: i18n.ts.indexNotice, - }); - } -} +import { indexPosts } from "@/scripts/index-posts"; const databasePromiseFactory = () => os diff --git a/packages/client/src/pages/admin/index.vue b/packages/client/src/pages/admin/index.vue index 7e88b64ab..63e4e178f 100644 --- a/packages/client/src/pages/admin/index.vue +++ b/packages/client/src/pages/admin/index.vue @@ -81,6 +81,7 @@ import * as os from "@/os"; import { lookupUser } from "@/scripts/lookup-user"; import { lookupFile } from "@/scripts/lookup-file"; import { lookupInstance } from "@/scripts/lookup-instance"; +import { indexPosts } from "@/scripts/index-posts"; import { defaultStore } from "@/store"; import { useRouter } from "@/router"; import { @@ -160,6 +161,12 @@ const menuDef = $computed(() => [ }, ] : []), + { + type: "button", + icon: "ph-list-magnifying-glass ph-bold ph-lg", + text: i18n.ts.indexPosts, + action: indexPosts, + }, ], }, { diff --git a/packages/client/src/scripts/index-posts.ts b/packages/client/src/scripts/index-posts.ts new file mode 100644 index 000000000..9817a8328 --- /dev/null +++ b/packages/client/src/scripts/index-posts.ts @@ -0,0 +1,25 @@ +import { i18n } from "@/i18n"; +import * as os from "@/os"; + +export async function indexPosts() { + const { canceled, result: index } = await os.inputText({ + title: i18n.ts.indexFrom, + }); + if (canceled) return; + + if (index == null || index === "") { + await os.api("admin/search/index-all"); + await os.alert({ + type: "info", + text: i18n.ts.indexNotice, + }); + } else { + await os.api("admin/search/index-all", { + cursor: index, + }); + await os.alert({ + type: "info", + text: i18n.ts.indexNotice, + }); + } +}