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) => { window.openFileByURL = (openURL) => {
if (openURL && isSYProtocol(openURL)) { if (openURL && isSYProtocol(openURL)) {
const isZoomIn = getSearch("focus", openURL) === "1" const isZoomIn = getSearch("focus", openURL) === "1";
openFileById({ openFileById({
id: getIdFromSYProtocol(openURL), id: getIdFromSYProtocol(openURL),
action: isZoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT], 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 {pdfResize} from "../asset/renderAssets";
import {Backlink} from "./dock/Backlink"; import {Backlink} from "./dock/Backlink";
import {openFileById} from "../editor/util"; import {openFileById} from "../editor/util";
import {getSearch, isWindow} from "../util/functions"; import {isWindow} from "../util/functions";
/// #if !BROWSER /// #if !BROWSER
import {setTabPosition} from "../window/setHeader"; import {setTabPosition} from "../window/setHeader";
/// #endif /// #endif

View file

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

View file

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

View file

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