mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
first commit 根据url里的id打开特定块 (#7086)
This commit is contained in:
parent
1befd3fc47
commit
77560d6601
1 changed files with 22 additions and 1 deletions
|
|
@ -105,7 +105,16 @@ export const setProxy = () => {
|
||||||
});
|
});
|
||||||
/// #endif
|
/// #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<vars.length;i++) {
|
||||||
|
var pair = vars[i].split("=");
|
||||||
|
if(pair[0] == arg_name){return pair[1];}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
export const onGetConfig = (isStart: boolean) => {
|
export const onGetConfig = (isStart: boolean) => {
|
||||||
const matchKeymap1 = matchKeymap(Constants.SIYUAN_KEYMAP.general, "general");
|
const matchKeymap1 = matchKeymap(Constants.SIYUAN_KEYMAP.general, "general");
|
||||||
const matchKeymap2 = matchKeymap(Constants.SIYUAN_KEYMAP.editor.general, "editor", "general");
|
const matchKeymap2 = matchKeymap(Constants.SIYUAN_KEYMAP.editor.general, "editor", "general");
|
||||||
|
|
@ -179,6 +188,18 @@ export const onGetConfig = (isStart: boolean) => {
|
||||||
mountHelp();
|
mountHelp();
|
||||||
}
|
}
|
||||||
addGA();
|
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 = () => {
|
const initBar = () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue