summaryrefslogtreecommitdiff
path: root/packages/frontend/lib/vite-plugin-create-search-index.ts
diff options
context:
space:
mode:
authorsyuilo <4439005+syuilo@users.noreply.github.com>2025-08-03 11:02:20 +0900
committerGitHub <noreply@github.com>2025-08-03 11:02:20 +0900
commit6f3cc2cdf7e47a2dd4dd6d7478579746e2af652c (patch)
treeb6820cddaf963fe0489c7f1c44fd9324022c10e4 /packages/frontend/lib/vite-plugin-create-search-index.ts
parentperf(frontend): tweak css performance (diff)
downloadmisskey-6f3cc2cdf7e47a2dd4dd6d7478579746e2af652c.tar.gz
misskey-6f3cc2cdf7e47a2dd4dd6d7478579746e2af652c.tar.bz2
misskey-6f3cc2cdf7e47a2dd4dd6d7478579746e2af652c.zip
コントロールパネルの検索 (#16343)
* Update settings.vue * Update settings.vue * Update settings.vue * Update settings.vue * Update settings.vue * Update performance.vue * Update performance.vue * Update performance.vue * Update external-services.vue * wip * wip * Update security.vue * Update settings.vue * Update CHANGELOG.md * wip * Update moderation.vue * wip * Update branding.vue * wip * Update email-settings.vue * Update system-webhook.vue * Update MkSuperMenu.vue * Update index.vue
Diffstat (limited to 'packages/frontend/lib/vite-plugin-create-search-index.ts')
-rw-r--r--packages/frontend/lib/vite-plugin-create-search-index.ts36
1 files changed, 20 insertions, 16 deletions
diff --git a/packages/frontend/lib/vite-plugin-create-search-index.ts b/packages/frontend/lib/vite-plugin-create-search-index.ts
index 97f4e589a3..4e20828909 100644
--- a/packages/frontend/lib/vite-plugin-create-search-index.ts
+++ b/packages/frontend/lib/vite-plugin-create-search-index.ts
@@ -39,6 +39,7 @@ export interface SearchIndexItem {
path?: string;
label: string;
keywords: string[];
+ texts: string[];
icon?: string;
inlining?: string[];
}
@@ -227,14 +228,14 @@ function extractElementText2Inner(node: TemplateChildNode, processingNodeName: s
// region extractUsageInfoFromTemplateAst
/**
- * SearchLabel/SearchKeyword/SearchIconを探して抽出する関数
+ * SearchLabel/SearchText/SearchIconを探して抽出する関数
*/
-function extractSugarTags(nodes: TemplateChildNode[], id: string): { label: string | null, keywords: string[], icon: string | null } {
+function extractSugarTags(nodes: TemplateChildNode[], id: string): { label: string | null; texts: string[]; icon: string | null; } {
let label: string | null | undefined = undefined;
let icon: string | null | undefined = undefined;
- const keywords: string[] = [];
+ const texts: string[] = [];
- logger.info(`Extracting labels and keywords from ${nodes.length} nodes`);
+ logger.info(`Extracting labels and texts from ${nodes.length} nodes`);
walkVueElements(nodes, null, (node) => {
switch (node.tag) {
@@ -248,10 +249,10 @@ function extractSugarTags(nodes: TemplateChildNode[], id: string): { label: stri
label = extractElementText(node, id);
return;
- case 'SearchKeyword':
+ case 'SearchText':
const content = extractElementText(node, id);
if (content) {
- keywords.push(content);
+ texts.push(content);
}
return;
case 'SearchIcon':
@@ -278,8 +279,8 @@ function extractSugarTags(nodes: TemplateChildNode[], id: string): { label: stri
});
// デバッグ情報
- logger.info(`Extraction completed: label=${label}, keywords=[${keywords.join(', ')}, icon=${icon}]`);
- return { label: label ?? null, keywords, icon: icon ?? null };
+ logger.info(`Extraction completed: label=${label}, text=[${texts.join(', ')}, icon=${icon}]`);
+ return { label: label ?? null, texts, icon: icon ?? null };
}
function getStringProp(attr: AttributeNode | DirectiveNode | null, id: string): string | null {
@@ -351,33 +352,36 @@ function extractUsageInfoFromTemplateAst(
parentId: parentId ?? undefined,
label: '', // デフォルト値
keywords: [],
+ texts: [],
};
// バインドプロパティを取得
- const path = getStringProp(findAttribute(node.props, 'path'), id)
- const icon = getStringProp(findAttribute(node.props, 'icon'), id)
- const label = getStringProp(findAttribute(node.props, 'label'), id)
- const inlining = getStringArrayProp(findAttribute(node.props, 'inlining'), id)
- const keywords = getStringArrayProp(findAttribute(node.props, 'keywords'), id)
+ const path = getStringProp(findAttribute(node.props, 'path'), id);
+ const icon = getStringProp(findAttribute(node.props, 'icon'), id);
+ const label = getStringProp(findAttribute(node.props, 'label'), id);
+ const inlining = getStringArrayProp(findAttribute(node.props, 'inlining'), id);
+ const keywords = getStringArrayProp(findAttribute(node.props, 'keywords'), id);
+ const texts = getStringArrayProp(findAttribute(node.props, 'texts'), id);
if (path) markerInfo.path = path;
if (icon) markerInfo.icon = icon;
if (label) markerInfo.label = label;
if (inlining) markerInfo.inlining = inlining;
if (keywords) markerInfo.keywords = keywords;
+ if (texts) markerInfo.texts = texts;
- //pathがない場合はファイルパスを設定
+ // pathがない場合はファイルパスを設定
if (markerInfo.path == null && parentId == null) {
markerInfo.path = id.match(/.*(\/(admin|settings)\/[^\/]+)\.vue$/)?.[1];
}
- // SearchLabelとSearchKeywordを抽出 (AST全体を探索)
+ // SearchLabelとSearchTextを抽出 (AST全体を探索)
{
const extracted = extractSugarTags(node.children, id);
if (extracted.label && markerInfo.label) logger.warn(`Duplicate label found for ${markerId} at ${id}:${node.loc.start.line}`);
if (extracted.icon && markerInfo.icon) logger.warn(`Duplicate icon found for ${markerId} at ${id}:${node.loc.start.line}`);
markerInfo.label = extracted.label ?? markerInfo.label ?? '';
- markerInfo.keywords = [...extracted.keywords, ...markerInfo.keywords];
+ markerInfo.texts = [...extracted.texts, ...markerInfo.texts];
markerInfo.icon = extracted.icon ?? markerInfo.icon ?? undefined;
}