Skip to content

Commit

Permalink
🎨 fix #8927
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Aug 12, 2023
1 parent 75ad2a2 commit ab7c0ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
32 changes: 13 additions & 19 deletions app/src/boot/onGetConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,21 +249,17 @@ export const initWindow = (app: App) => {
currentWindow.on("blur", winOnBlur);
if (!isWindow()) {
ipcRenderer.on(Constants.SIYUAN_OPENURL, (event, url) => {
app.plugins.forEach(plugin => {
plugin.eventBus.emit("open-siyuan-url", { url });
});
if (url.startsWith("siyuan://plugins/")) {
const urlObj = new URL(url);
const pluginId = urlObj.pathname.split("/")[3];
if (pluginId) {
app.plugins.find(plugin => {
const pluginId = url.replace("siyuan://plugins/", "").split("?")[0];
if (!pluginId) {
return;
}
app.plugins.find(plugin => {
if (pluginId.startsWith(plugin.name)) {
// siyuan://plugins/plugin-name/foo?bar=baz
if (pluginId.startsWith(plugin.name)) {
plugin.eventBus.emit("open-siyuan-url-plugins", { url });
}

plugin.eventBus.emit("open-siyuan-url-plugin", {url});
// siyuan://plugins/plugin-samplecustom_tab?title=自定义页签&icon=iconFace&data={"text": "This is the custom plugin tab I opened via protocol."}
const match = Object.keys(plugin.models).find(key => {
Object.keys(plugin.models).find(key => {
if (key === pluginId) {
let data = getSearch("data", url);
try {
Expand All @@ -283,12 +279,10 @@ export const initWindow = (app: App) => {
return true;
}
});
if (match) {
return true;
}
});
return;
}
return true;
}
});
return;
}
if (isSYProtocol(url)) {
const id = getIdFromSYProtocol(url);
Expand All @@ -304,7 +298,7 @@ export const initWindow = (app: App) => {
ipcRenderer.send(Constants.SIYUAN_SHOW, getCurrentWindow().id);
}
app.plugins.forEach(plugin => {
plugin.eventBus.emit("open-siyuan-url-blocks", {
plugin.eventBus.emit("open-siyuan-url-block", {
url,
id,
focus,
Expand Down
2 changes: 1 addition & 1 deletion app/src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type TEventBus = "ws-main" |
"open-noneditableblock" |
"open-menu-blockref" | "open-menu-fileannotationref" | "open-menu-tag" | "open-menu-link" | "open-menu-image" |
"open-menu-av" | "open-menu-content" | "open-menu-breadcrumbmore" |
"open-siyuan-url" | "open-siyuan-url-blocks" | "open-siyuan-url-plugins" |
"open-siyuan-url-plugin" | "open-siyuan-url-block" |
"input-search" |
"loaded-protyle"
type TAVCol =
Expand Down

0 comments on commit ab7c0ca

Please sign in to comment.