feat: index posts action
This commit is contained in:
parent
0979ba6b8f
commit
b6d2b15948
3 changed files with 33 additions and 23 deletions
|
@ -43,29 +43,7 @@ import bytes from "@/filters/bytes";
|
||||||
import number from "@/filters/number";
|
import number from "@/filters/number";
|
||||||
import { i18n } from "@/i18n";
|
import { i18n } from "@/i18n";
|
||||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||||
|
import { indexPosts } from "@/scripts/index-posts";
|
||||||
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,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const databasePromiseFactory = () =>
|
const databasePromiseFactory = () =>
|
||||||
os
|
os
|
||||||
|
|
|
@ -81,6 +81,7 @@ import * as os from "@/os";
|
||||||
import { lookupUser } from "@/scripts/lookup-user";
|
import { lookupUser } from "@/scripts/lookup-user";
|
||||||
import { lookupFile } from "@/scripts/lookup-file";
|
import { lookupFile } from "@/scripts/lookup-file";
|
||||||
import { lookupInstance } from "@/scripts/lookup-instance";
|
import { lookupInstance } from "@/scripts/lookup-instance";
|
||||||
|
import { indexPosts } from "@/scripts/index-posts";
|
||||||
import { defaultStore } from "@/store";
|
import { defaultStore } from "@/store";
|
||||||
import { useRouter } from "@/router";
|
import { useRouter } from "@/router";
|
||||||
import {
|
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,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
25
packages/client/src/scripts/index-posts.ts
Normal file
25
packages/client/src/scripts/index-posts.ts
Normal file
|
@ -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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue