Skip to content

Commit d4f9ffa

Browse files
committed
update to v0.1.5
1 parent 881a479 commit d4f9ffa

File tree

5 files changed

+24
-12
lines changed

5 files changed

+24
-12
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[中文版](./README_zh_CN.md)
55

6-
> Consistent with [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.1.4](https://github.com/siyuan-note/plugin-sample/tree/v0.1.4).
6+
> Consistent with [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.1.5](https://github.com/siyuan-note/plugin-sample/tree/v0.1.5).
77
88

99

README_zh_CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[English](./README.md)
55

66

7-
> 本例和 [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.1.4](https://github.com/siyuan-note/plugin-sample/tree/v0.1.4).
7+
> 本例和 [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.1.5](https://github.com/siyuan-note/plugin-sample/tree/v0.1.5)
88
99
1. 使用 vite 打包
1010
2. 使用符号链接、而不是把项目放到插件目录下的模式进行开发

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "plugin-sample-vite-svelte",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"type": "module",
55
"description": "",
66
"repository": "",
@@ -22,7 +22,7 @@
2222
"minimist": "^1.2.8",
2323
"rollup-plugin-livereload": "^2.0.5",
2424
"sass": "^1.62.1",
25-
"siyuan": "0.7.3",
25+
"siyuan": "0.7.4",
2626
"svelte": "^3.57.0",
2727
"ts-node": "^10.9.1",
2828
"typescript": "^5.0.4",

plugin.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "plugin-sample-vite-svelte",
33
"author": "frostime",
44
"url": "https://github.com/siyuan-note/plugin-sample-vite-svelte",
5-
"version": "0.1.4",
5+
"version": "0.1.5",
66
"minAppVersion": "2.9.0",
77
"backends": ["all"],
88
"frontends": ["all"],

src/index.ts

+19-7
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,19 @@ export default class PluginSample extends Plugin {
4545
title: this.i18n.addTopBarIcon,
4646
position: "right",
4747
callback: () => {
48-
let rect = topBarElement.getBoundingClientRect();
49-
// 如果被隐藏,则使用更多按钮
50-
if (rect.width === 0) {
51-
rect = document.querySelector("#barPlugins").getBoundingClientRect();
48+
if (this.isMobile) {
49+
this.addMenu();
50+
} else {
51+
let rect = topBarElement.getBoundingClientRect();
52+
// 如果被隐藏,则使用更多按钮
53+
if (rect.width === 0) {
54+
rect = document.querySelector("#barMore").getBoundingClientRect();
55+
}
56+
if (rect.width === 0) {
57+
rect = document.querySelector("#barPlugins").getBoundingClientRect();
58+
}
59+
this.addMenu(rect);
5260
}
53-
this.addMenu(rect);
5461
}
5562
});
5663

@@ -86,6 +93,9 @@ export default class PluginSample extends Plugin {
8693
this.element.appendChild(tabDiv);
8794
console.log(this.element);
8895
},
96+
beforeDestroy() {
97+
console.log("before destroy tab:", TAB_TYPE);
98+
},
8999
destroy() {
90100
console.log("destroy tab:", TAB_TYPE);
91101
}
@@ -224,15 +234,17 @@ export default class PluginSample extends Plugin {
224234
});
225235
}
226236

227-
private addMenu(rect: DOMRect) {
237+
private addMenu(rect?: DOMRect) {
228238
const menu = new Menu("topBarSample", () => {
229239
console.log(this.i18n.byeMenu);
230240
});
231241
menu.addItem({
232242
icon: "iconInfo",
233243
label: "Dialog",
234244
accelerator: this.commands[0].customHotkey,
235-
click: () => this.showDialog()
245+
click: () => {
246+
this.showDialog()
247+
}
236248
});
237249
if (!this.isMobile) {
238250
menu.addItem({

0 commit comments

Comments
 (0)