mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-09 14:12:34 +01:00
This commit is contained in:
parent
7c653d3689
commit
a18e3a585c
9 changed files with 44 additions and 46 deletions
|
|
@ -46,27 +46,3 @@ export const isFileAnnotation = (text: string) => {
|
|||
export const looseJsonParse = (text: string) => {
|
||||
return Function(`"use strict";return (${text})`)();
|
||||
};
|
||||
|
||||
/* redirect to auth page */
|
||||
export const redirectToCheckAuth = (to: string = window.location.href) => {
|
||||
const url = new URL(window.location.origin);
|
||||
url.pathname = '/check-auth';
|
||||
url.searchParams.set('to', to);
|
||||
window.location.href = url.href;
|
||||
}
|
||||
|
||||
export const isSiyuanUrl = (url: string) => {
|
||||
return /^siyuan:\/\/blocks\/\d{14}-\w{7}/.test(url);
|
||||
}
|
||||
|
||||
export const isWebSiyuanUrl = (url: string) => {
|
||||
return /^web\+siyuan:\/\/blocks\/\d{14}-\w{7}/.test(url);
|
||||
}
|
||||
|
||||
export const getIdFromSiyuanUrl = (url: string) => {
|
||||
return url.substring(16, 16 + 22);
|
||||
}
|
||||
|
||||
export const getIdFromWebSiyuanUrl = (url: string) => {
|
||||
return url.substring(20, 20 + 22);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,22 @@ import {unicode2Emoji} from "../emoji";
|
|||
import {Constants} from "../constants";
|
||||
import {showMessage} from "../dialog/message";
|
||||
|
||||
export const isSYProtocol = (url: string) => {
|
||||
return /^siyuan:\/\/blocks\/\d{14}-\w{7}/.test(url);
|
||||
}
|
||||
|
||||
export const getIdFromSYProtocol = (url: string) => {
|
||||
return url.substring(16, 16 + 22);
|
||||
}
|
||||
|
||||
/* redirect to auth page */
|
||||
export const redirectToCheckAuth = (to: string = window.location.href) => {
|
||||
const url = new URL(window.location.origin);
|
||||
url.pathname = '/check-auth';
|
||||
url.searchParams.set('to', to);
|
||||
window.location.href = url.href;
|
||||
}
|
||||
|
||||
export const addBaseURL = () => {
|
||||
let baseURLElement = document.getElementById("baseURL");
|
||||
if (!baseURLElement) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue