settings window

This commit is contained in:
2023-03-16 13:02:24 +08:00
parent 7747bfa1ac
commit e81044c4b5
3 changed files with 197 additions and 80 deletions

18
src/getDefaultParam.ts Normal file
View File

@@ -0,0 +1,18 @@
function getDefaultParams(param: string, val: string): string;
function getDefaultParams(param: string, val: number): number;
function getDefaultParams(param: string, val: boolean): boolean;
function getDefaultParams(param: any, val: any) {
const queryParameters = new URLSearchParams(window.location.search);
const get = queryParameters.get(param);
if (typeof val === "string") {
return get ?? val;
} else if (typeof val === "number") {
return parseInt(get ?? `${val}`);
} else if (typeof val === "boolean") {
if (get === "stream") return true;
if (get === "fetch") return false;
return val;
}
}
export default getDefaultParams;