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