mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-09 07:25:19 +02:00
Add window type
This commit is contained in:
parent
254de893d6
commit
9e6d90ca2e
1 changed files with 7 additions and 4 deletions
|
@ -1,5 +1,11 @@
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
__appenv: any;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function isBrowser() {
|
function isBrowser() {
|
||||||
return Boolean(typeof window !== "undefined" && (window.__env || window.__appenv));
|
return Boolean(typeof window !== "undefined" && window.__appenv);
|
||||||
}
|
}
|
||||||
|
|
||||||
function env(key: string) {
|
function env(key: string) {
|
||||||
|
@ -8,10 +14,7 @@ function env(key: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isBrowser()) {
|
if (isBrowser()) {
|
||||||
if (key in window.__appenv)
|
|
||||||
return window.__appenv[key];
|
return window.__appenv[key];
|
||||||
|
|
||||||
return window.__env[key];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return process.env[key];
|
return process.env[key];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue