mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 17:44:03 +00:00
fix(miniapp): bundle telegram webapp sdk
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
|
||||
<script src="https://telegram.org/js/telegram-web-app.js"></script>
|
||||
<script src="/config.js"></script>
|
||||
<script src="/src/index.tsx" type="module"></script>
|
||||
</body>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"lint": "oxlint \"src\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@twa-dev/sdk": "8.0.2",
|
||||
"solid-js": "^1.9.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,31 +1,12 @@
|
||||
export interface TelegramWebAppUser {
|
||||
id: number
|
||||
first_name?: string
|
||||
username?: string
|
||||
language_code?: string
|
||||
}
|
||||
import WebApp from '@twa-dev/sdk'
|
||||
|
||||
export interface TelegramWebApp {
|
||||
initData: string
|
||||
initDataUnsafe?: {
|
||||
user?: TelegramWebAppUser
|
||||
}
|
||||
ready?: () => void
|
||||
expand?: () => void
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
Telegram?: {
|
||||
WebApp?: TelegramWebApp
|
||||
}
|
||||
}
|
||||
}
|
||||
export type TelegramWebApp = typeof WebApp
|
||||
export type TelegramWebAppUser = NonNullable<NonNullable<TelegramWebApp['initDataUnsafe']>['user']>
|
||||
|
||||
export function getTelegramWebApp(): TelegramWebApp | undefined {
|
||||
if (typeof window === 'undefined') {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return window.Telegram?.WebApp
|
||||
return WebApp
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user