feat(halo): 新增文章搜索和导出功能

- 添加文章搜索命令,支持按关键词筛选和发布状态过滤
- 新增文章导出功能,支持导出为 Markdown 和 JSON 格式
- 扩展国际化配置,添加相关翻译文本
- 更新功能增强计划文档,标记已完成功能
- 移除不再需要的下载信息和插件清单文件
This commit is contained in:
2026-04-26 17:35:37 +08:00
parent 5c4a16dc3a
commit b72f36926a
16 changed files with 565 additions and 666 deletions
+40
View File
@@ -6,6 +6,8 @@ import { openPostSelectionModal } from "./post-selection-model";
import { importFromMarkdownFile } from "./commands/import-markdown";
import { deletePost } from "./commands/delete-post";
import { manageTags, manageCategories } from "./commands/manage-taxonomy";
import { exportPostAsMarkdown, exportPostAsJson } from "./commands/export-post";
import { searchPosts } from "./commands/search-posts";
import { DEFAULT_SETTINGS, type HaloSetting, HaloSettingTab, type HaloSite } from "./settings";
import HaloService from "./service";
import { openSiteSelectionModal } from "./site-selection-modal";
@@ -141,6 +143,44 @@ export default class HaloPlugin extends Plugin {
},
});
this.addCommand({
id: "search-posts",
name: i18next.t("command.search_posts.name"),
callback: async () => {
await searchPosts(this);
},
});
this.addCommand({
id: "export-post-as-markdown",
name: i18next.t("command.export_markdown.name"),
editorCallback: async () => {
const { activeEditor } = this.app.workspace;
if (!activeEditor || !activeEditor.file) return;
const matterData = this.app.metadataCache.getFileCache(activeEditor.file)?.frontmatter;
if (!matterData?.halo?.name) {
new Notice(i18next.t("command.export_markdown.error_not_published"));
return;
}
await exportPostAsMarkdown(this, matterData.halo.name, matterData.title || activeEditor.file.basename);
},
});
this.addCommand({
id: "export-post-as-json",
name: i18next.t("command.export_json.name"),
editorCallback: async () => {
const { activeEditor } = this.app.workspace;
if (!activeEditor || !activeEditor.file) return;
const matterData = this.app.metadataCache.getFileCache(activeEditor.file)?.frontmatter;
if (!matterData?.halo?.name) {
new Notice(i18next.t("command.export_json.error_not_published"));
return;
}
await exportPostAsJson(this, matterData.halo.name, matterData.title || activeEditor.file.basename);
},
});
this.addSettingTab(new HaloSettingTab(this));
}