mirror of
https://github.com/yeban8090/note-to-red.git
synced 2026-07-22 05:42:34 +00:00
commit
5a68d36341
2 changed files with 63 additions and 55 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "note-to-red",
|
||||
"name": "Note to RED",
|
||||
"version": "1.0.18",
|
||||
"version": "1.0.19",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Convert Markdown notes to RED (Xiaohongshu) style images",
|
||||
"author": "Yeban",
|
||||
|
|
|
|||
32
src/main.ts
32
src/main.ts
|
|
@ -30,17 +30,20 @@ export default class RedPlugin extends Plugin {
|
|||
);
|
||||
|
||||
// 添加首次加载自动打开视图的逻辑
|
||||
this.app.workspace.onLayoutReady(() => {
|
||||
if (this.app.workspace.getLeavesOfType(VIEW_TYPE_RED).length === 0) {
|
||||
const leaf = this.app.workspace.getRightLeaf(false);
|
||||
if (leaf) {
|
||||
leaf.setViewState({
|
||||
type: VIEW_TYPE_RED,
|
||||
active: false // 设置为 false 表示不聚焦
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
// this.app.workspace.onLayoutReady(() => {
|
||||
// this.app.workspace.on("layout-change", () => {
|
||||
// const leaves = this.app.workspace.getLeavesOfType(VIEW_TYPE_RED);
|
||||
// if (leaves.length === 0) {
|
||||
// const rightLeaf = this.app.workspace.getRightLeaf(false);
|
||||
// if (rightLeaf) {
|
||||
// rightLeaf.setViewState({
|
||||
// type: VIEW_TYPE_RED,
|
||||
// active: false,
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
// 添加命令到命令面板
|
||||
this.addCommand({
|
||||
|
|
@ -48,7 +51,12 @@ export default class RedPlugin extends Plugin {
|
|||
name: '打开小红书图片预览',
|
||||
callback: async () => {
|
||||
await this.activateView();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// 添加一个功能按钮用于打开所有面板
|
||||
this.addRibbonIcon("image", "打开小红书图片预览", () => {
|
||||
this.activateView();
|
||||
});
|
||||
|
||||
// 在插件的 onload 方法中添加:
|
||||
|
|
|
|||
Loading…
Reference in a new issue