移动端支持触发open-siyuan-url-plugin #15892 (#16465)

This commit is contained in:
养恐龙 2025-12-01 20:04:25 +08:00 committed by GitHub
parent 2fe3534ffd
commit 348950ab51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -53,6 +53,33 @@ export const openByMobile = (uri: string) => {
if (!uri) { if (!uri) {
return; return;
} }
//https://github.com/siyuan-note/siyuan/issues/15892
if (uri.startsWith("siyuan://")) {
let urlObj: URL;
try {
urlObj = new URL(uri);
if (urlObj.protocol !== "siyuan:") {
return;
}
} catch (error) {
return;
}
if (urlObj && urlObj.hostname === "plugins") {
const pluginNameType = urlObj.pathname.split("/")[1];
if (!pluginNameType) {
return;
}
window.siyuan.ws.app.plugins.find((plugin) => {
if (pluginNameType.startsWith(plugin.name)) {
// siyuan://plugins/plugin-name/foo?bar=baz
plugin.eventBus.emit("open-siyuan-url-plugin", {
url: uri
});
}
});
return;
}
}
if (isInIOS()) { if (isInIOS()) {
if (uri.startsWith("assets/")) { if (uri.startsWith("assets/")) {
// iOS 16.7 之前的版本uri 需要 encodeURIComponent // iOS 16.7 之前的版本uri 需要 encodeURIComponent