mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-27 11:58:49 +01:00
This commit is contained in:
parent
550195b603
commit
f49ebee0e8
1 changed files with 14 additions and 4 deletions
|
|
@ -14,10 +14,20 @@ export const getRandom = (min: number, max: number) => {
|
|||
return Math.floor(Math.random() * (max - min + 1)) + min; //含最大值,含最小值
|
||||
};
|
||||
|
||||
export const getSearch: (key: string, link?: string) => string | null = (key: string, link = window.location.search) => {
|
||||
// REF https://developer.mozilla.org/zh-CN/docs/Web/API/URLSearchParams
|
||||
const urlSearchParams = new URLSearchParams(link);
|
||||
return urlSearchParams.get(key);
|
||||
export const getSearch = (key: string, link = window.location.search) => {
|
||||
if (link.indexOf("?") === -1) {
|
||||
return "";
|
||||
}
|
||||
let value = "";
|
||||
const data = link.split("?")[1].split("&");
|
||||
data.find(item => {
|
||||
const keyValue = item.split("=");
|
||||
if (keyValue[0] === key) {
|
||||
value = keyValue[1];
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return value;
|
||||
};
|
||||
|
||||
export const isBrowser = () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue