From 77560d6601b53f657a470daf45569b71b1ac8a9f Mon Sep 17 00:00:00 2001 From: iamqiz <48077521+iamqiz@users.noreply.github.com> Date: Mon, 16 Jan 2023 20:42:28 +0800 Subject: [PATCH] =?UTF-8?q?first=20commit=20=E6=A0=B9=E6=8D=AEurl=E9=87=8C?= =?UTF-8?q?=E7=9A=84id=E6=89=93=E5=BC=80=E7=89=B9=E5=AE=9A=E5=9D=97=20(#70?= =?UTF-8?q?86)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/util/onGetConfig.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/app/src/util/onGetConfig.ts b/app/src/util/onGetConfig.ts index 1071bbfe4..46be67a64 100644 --- a/app/src/util/onGetConfig.ts +++ b/app/src/util/onGetConfig.ts @@ -105,7 +105,16 @@ export const setProxy = () => { }); /// #endif }; - +// 获取 location.search 里特定参数,失败返回false +function getUrlArg(arg_name: string) { + var query = window.location.search.substring(1); + var vars = query.split("&"); + for (var i=0;i { const matchKeymap1 = matchKeymap(Constants.SIYUAN_KEYMAP.general, "general"); const matchKeymap2 = matchKeymap(Constants.SIYUAN_KEYMAP.editor.general, "editor", "general"); @@ -179,6 +188,18 @@ export const onGetConfig = (isStart: boolean) => { mountHelp(); } addGA(); + //根据url里的id参数打开相应的块,用于浏览器访问 + let url_doc_id=getUrlArg("id") + if (url_doc_id) { + fetchPost("/api/block/getBlockInfo", {id: url_doc_id}, response => { + if (response.code === 0 && typeof url_doc_id === "string") { + openFileById({ + id: url_doc_id, + action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT,] + }) + } + }) + } }; const initBar = () => {