Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/15453

Vanessae103b5c2f046
diff --git a/app/src/plugin/index.ts b/app/src/plugin/index.ts
index a892184a16..6036a5daf7 100644
--- a/app/src/plugin/index.ts
+++ b/app/src/plugin/index.ts
@@ -155,8 +155,19 @@ export class Plugin {
}
public addIcons(svg: string) {
- document.body.insertAdjacentHTML("afterbegin", `<svg data-name="${this.name}" style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
+ const svgElement = document.querySelector(`svg[data-name="${this.name}"] defs`);
+ if (svgElement) {
+ svgElement.innerHTML = svg;
+ } else {
+ const lastSvgElement = document.querySelector("body > svg:last-of-type");
+ if (lastSvgElement) {
+ lastSvgElement.insertAdjacentHTML("afterend", `<svg data-name="${this.name}" style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
+<defs>${svg}</defs></svg>`);
+ } else {
+ document.body.insertAdjacentHTML("afterbegin", `<svg data-name="${this.name}" style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
<defs>${svg}</defs></svg>`);
+ }
+ }
}
public addTopBar(options: {
diff --git a/app/src/plugin/uninstall.ts b/app/src/plugin/uninstall.ts
index 7fba77cf33..19cfb52e18 100644
--- a/app/src/plugin/uninstall.ts
+++ b/app/src/plugin/uninstall.ts
@@ -62,6 +62,8 @@ export const uninstall = (app: App, name: string, isUninstall = false) => {
});
// rm plugin
app.plugins.splice(index, 1);
+ // rm icons
+ document.querySelector(`svg[data-name="${plugin.name}"]`)?.remove();
// rm protyle toolbar
getAllEditor().forEach(editor => {
editor.protyle.toolbar.update(editor.protyle);