fix: paje refresh crush
All checks were successful
Deploy to VPS (dist) / deploy (push) Successful in 1m35s
All checks were successful
Deploy to VPS (dist) / deploy (push) Successful in 1m35s
This commit is contained in:
@@ -5,13 +5,10 @@ export const STORAGE_KEYS = {
|
|||||||
} as const;
|
} as const;
|
||||||
export type StorageKey = (typeof STORAGE_KEYS)[keyof typeof STORAGE_KEYS];
|
export type StorageKey = (typeof STORAGE_KEYS)[keyof typeof STORAGE_KEYS];
|
||||||
|
|
||||||
const isRealTelegram = () => {
|
// @ts-expect-error Just for an initial check
|
||||||
if (typeof window === "undefined") return false;
|
const IS_REAL_TG = Boolean(window?.Telegram?.WebApp);
|
||||||
const search = location.hash.slice(1) || location.search.slice(1);
|
|
||||||
return search.includes("tgWebAppData");
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!isRealTelegram()) {
|
if (!IS_REAL_TG) {
|
||||||
tg.mockTelegramEnv({
|
tg.mockTelegramEnv({
|
||||||
launchParams: {
|
launchParams: {
|
||||||
tgWebAppData: new URLSearchParams({
|
tgWebAppData: new URLSearchParams({
|
||||||
@@ -61,7 +58,7 @@ const fallbackImplementation = <
|
|||||||
cb: T,
|
cb: T,
|
||||||
onErr: F,
|
onErr: F,
|
||||||
): Async extends true ? Promise<Result> : Awaited<Result> => {
|
): Async extends true ? Promise<Result> : Awaited<Result> => {
|
||||||
if (isRealTelegram()) {
|
if (IS_REAL_TG) {
|
||||||
const res = cb.ifAvailable.apply(null, args);
|
const res = cb.ifAvailable.apply(null, args);
|
||||||
const returnValue = (res.ok ? res.data : onErr.apply(null, args)) as Result;
|
const returnValue = (res.ok ? res.data : onErr.apply(null, args)) as Result;
|
||||||
if (!async) return returnValue as Async extends true ? Promise<Result> : Awaited<Result>;
|
if (!async) return returnValue as Async extends true ? Promise<Result> : Awaited<Result>;
|
||||||
@@ -84,9 +81,7 @@ export default {
|
|||||||
tg.swipeBehavior.disableVertical.ifAvailable();
|
tg.swipeBehavior.disableVertical.ifAvailable();
|
||||||
tg.viewport.expand.ifAvailable();
|
tg.viewport.expand.ifAvailable();
|
||||||
tg.miniApp.setHeaderColor.ifAvailable("#000000");
|
tg.miniApp.setHeaderColor.ifAvailable("#000000");
|
||||||
console.log(
|
console.log(IS_REAL_TG ? "Telegram Mini App initialized" : "TMA Debug mode in Web initialized");
|
||||||
isRealTelegram() ? "Telegram Mini App initialized" : "TMA Debug mode in Web initialized",
|
|
||||||
);
|
|
||||||
console.log(tg.retrieveLaunchParams());
|
console.log(tg.retrieveLaunchParams());
|
||||||
},
|
},
|
||||||
openLink(url: string | URL, options?: tg.OpenLinkOptions) {
|
openLink(url: string | URL, options?: tg.OpenLinkOptions) {
|
||||||
|
|||||||
Reference in New Issue
Block a user