This commit is contained in:
Vanessa 2023-04-19 18:55:50 +08:00
parent d76180796c
commit 26e77a3529
5 changed files with 9 additions and 10 deletions

View file

@ -181,7 +181,7 @@ new App();
window.openFileByURL = (openURL) => {
if (openURL && isSYProtocol(openURL)) {
const isZoomIn = getSearch("focus", openURL) === "1"
const isZoomIn = getSearch("focus", openURL) === "1";
openFileById({
id: getIdFromSYProtocol(openURL),
action: isZoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],

View file

@ -27,7 +27,7 @@ import {saveScroll} from "../protyle/scroll/saveScroll";
import {pdfResize} from "../asset/renderAssets";
import {Backlink} from "./dock/Backlink";
import {openFileById} from "../editor/util";
import {getSearch, isWindow} from "../util/functions";
import {isWindow} from "../util/functions";
/// #if !BROWSER
import {setTabPosition} from "../window/setHeader";
/// #endif

View file

@ -16,7 +16,6 @@ import {MobileBacklinks} from "./MobileBacklinks";
import {MobileBookmarks} from "./MobileBookmarks";
import {MobileTags} from "./MobileTags";
import {activeBlur, hideKeyboardToolbar, initKeyboardToolbar} from "./keyboardToolbar";
import {getSearch} from "../../util/functions";
import {syncGuide} from "../../sync/syncGuide";
export const initFramework = () => {

View file

@ -15,13 +15,13 @@ export const getIdZoomInByPath = () => {
let isZoomIn = false;
if (/^web\+siyuan:\/\/blocks\/\d{14}-\w{7}/.test(PWAURL)) {
// PWA 捕获 web+siyuan://blocks/20221031001313-rk7sd0e?focus=1
id = PWAURL.substring(20, 20 + 22)
id = PWAURL.substring(20, 20 + 22);
isZoomIn = getSearch("focus", PWAURL) === "1";
} else if (window.JSAndroid) {
// PAD 通过思源协议打开
const SYURL = window.JSAndroid.getBlockURL();
id = getIdFromSYProtocol(SYURL);
isZoomIn = getSearch("focus", SYURL) === "1"
isZoomIn = getSearch("focus", SYURL) === "1";
} else {
// 支持通过 URL 查询字符串参数 `id` 和 `focus` 跳转到 Web 端指定块 https://github.com/siyuan-note/siyuan/pull/7086
id = searchParams.get("id");
@ -29,8 +29,8 @@ export const getIdZoomInByPath = () => {
}
return {
id, isZoomIn
}
}
};
};
export const isSYProtocol = (url: string) => {
return /^siyuan:\/\/blocks\/\d{14}-\w{7}/.test(url);
};

View file

@ -1,8 +1,8 @@
// https://github.com/siyuan-note/siyuan/pull/8012
export const registerServiceWorker = (scriptURL: string) => {
if (!'serviceWorker' in navigator || typeof (navigator.serviceWorker) === 'undefined' ||
!'caches' in window || !'fetch' in window) {
return
if (!"serviceWorker" in navigator || typeof (navigator.serviceWorker) === "undefined" ||
!"caches" in window || !"fetch" in window) {
return;
}
// REF https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration
window.navigator.serviceWorker