mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
✨ enable plugin
This commit is contained in:
parent
f3d1acd166
commit
85496345ef
4 changed files with 105 additions and 41 deletions
|
|
@ -16,6 +16,7 @@ import {Plugin} from "../plugin";
|
|||
import {App} from "../index";
|
||||
import {escapeAttr} from "../util/escape";
|
||||
import {uninstall} from "../plugin/uninstall";
|
||||
import {loadPlugin} from "../plugin/loader";
|
||||
|
||||
export const bazaar = {
|
||||
element: undefined as Element,
|
||||
|
|
@ -635,19 +636,16 @@ export const bazaar = {
|
|||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "plugin-enable") {
|
||||
const itemElement = hasClosestByClassName(target, "b3-card");
|
||||
if (itemElement) {
|
||||
if (!target.getAttribute("disabled")) {
|
||||
target.setAttribute("disabled", "disabled");
|
||||
const enabled = (target as HTMLInputElement).checked;
|
||||
fetchPost("/api/petal/setPetalEnabled", {
|
||||
packageName: dataObj.name,
|
||||
enabled,
|
||||
}, () => {
|
||||
}, (response) => {
|
||||
target.removeAttribute("disabled");
|
||||
if (enabled) {
|
||||
exportLayout({
|
||||
reload: true,
|
||||
onlyData: false,
|
||||
errorExit: false,
|
||||
});
|
||||
loadPlugin(app, response.data);
|
||||
} else {
|
||||
uninstall(app, dataObj.name);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue