update to v0.1.5
This commit is contained in:
parent
881a479241
commit
d4f9ffa687
5 changed files with 24 additions and 12 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
[中文版](./README_zh_CN.md)
|
||||
|
||||
> 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).
|
||||
> 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).
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
[English](./README.md)
|
||||
|
||||
|
||||
> 本例和 [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.1.4](https://github.com/siyuan-note/plugin-sample/tree/v0.1.4).
|
||||
> 本例和 [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.1.5](https://github.com/siyuan-note/plugin-sample/tree/v0.1.5)
|
||||
|
||||
1. 使用 vite 打包
|
||||
2. 使用符号链接、而不是把项目放到插件目录下的模式进行开发
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "plugin-sample-vite-svelte",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.5",
|
||||
"type": "module",
|
||||
"description": "",
|
||||
"repository": "",
|
||||
|
@ -22,7 +22,7 @@
|
|||
"minimist": "^1.2.8",
|
||||
"rollup-plugin-livereload": "^2.0.5",
|
||||
"sass": "^1.62.1",
|
||||
"siyuan": "0.7.3",
|
||||
"siyuan": "0.7.4",
|
||||
"svelte": "^3.57.0",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^5.0.4",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "plugin-sample-vite-svelte",
|
||||
"author": "frostime",
|
||||
"url": "https://github.com/siyuan-note/plugin-sample-vite-svelte",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.5",
|
||||
"minAppVersion": "2.9.0",
|
||||
"backends": ["all"],
|
||||
"frontends": ["all"],
|
||||
|
|
26
src/index.ts
26
src/index.ts
|
@ -45,12 +45,19 @@ export default class PluginSample extends Plugin {
|
|||
title: this.i18n.addTopBarIcon,
|
||||
position: "right",
|
||||
callback: () => {
|
||||
let rect = topBarElement.getBoundingClientRect();
|
||||
// 如果被隐藏,则使用更多按钮
|
||||
if (rect.width === 0) {
|
||||
rect = document.querySelector("#barPlugins").getBoundingClientRect();
|
||||
if (this.isMobile) {
|
||||
this.addMenu();
|
||||
} else {
|
||||
let rect = topBarElement.getBoundingClientRect();
|
||||
// 如果被隐藏,则使用更多按钮
|
||||
if (rect.width === 0) {
|
||||
rect = document.querySelector("#barMore").getBoundingClientRect();
|
||||
}
|
||||
if (rect.width === 0) {
|
||||
rect = document.querySelector("#barPlugins").getBoundingClientRect();
|
||||
}
|
||||
this.addMenu(rect);
|
||||
}
|
||||
this.addMenu(rect);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -86,6 +93,9 @@ export default class PluginSample extends Plugin {
|
|||
this.element.appendChild(tabDiv);
|
||||
console.log(this.element);
|
||||
},
|
||||
beforeDestroy() {
|
||||
console.log("before destroy tab:", TAB_TYPE);
|
||||
},
|
||||
destroy() {
|
||||
console.log("destroy tab:", TAB_TYPE);
|
||||
}
|
||||
|
@ -224,7 +234,7 @@ export default class PluginSample extends Plugin {
|
|||
});
|
||||
}
|
||||
|
||||
private addMenu(rect: DOMRect) {
|
||||
private addMenu(rect?: DOMRect) {
|
||||
const menu = new Menu("topBarSample", () => {
|
||||
console.log(this.i18n.byeMenu);
|
||||
});
|
||||
|
@ -232,7 +242,9 @@ export default class PluginSample extends Plugin {
|
|||
icon: "iconInfo",
|
||||
label: "Dialog",
|
||||
accelerator: this.commands[0].customHotkey,
|
||||
click: () => this.showDialog()
|
||||
click: () => {
|
||||
this.showDialog()
|
||||
}
|
||||
});
|
||||
if (!this.isMobile) {
|
||||
menu.addItem({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue