This commit is contained in:
degradin 2025-03-16 12:31:11 +03:00
parent 4a910fc576
commit 8c152a47bd
9 changed files with 37 additions and 9 deletions

View File

@ -1,16 +1,16 @@
{
"pages": {
"/page": [
"static/chunks/webpack.js",
"static/chunks/main-app.js",
"static/chunks/app/page.js"
],
"/layout": [
"static/chunks/webpack.js",
"static/chunks/main-app.js",
"static/css/app/layout.css",
"static/chunks/app/layout.js"
],
"/page": [
"static/chunks/webpack.js",
"static/chunks/main-app.js",
"static/chunks/app/page.js"
],
"/not-found": [
"static/chunks/webpack.js",
"static/chunks/main-app.js",

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,17 @@
'use client';
import { useEffect, useState } from 'react';
export default function ClientOnly({ children }: { children: React.ReactNode }) {
const [hasMounted, setHasMounted] = useState(false);
useEffect(() => {
setHasMounted(true);
}, []);
if (!hasMounted) {
return null;
}
return <>{children}</>;
}

View File

@ -9,6 +9,7 @@ import { auth, getProfile, getShopItems, purchaseItem, transferBalance } from '.
import { IUser } from '../../backend/models/User';
import { IShopItem } from '../../backend/models/ShopItem';
import { isDemoMode, getDemoWebApp } from '../utils/demo';
import WebApp from '@twa-dev/sdk';
type SafeUser = Omit<IUser, keyof Document>;
@ -25,9 +26,10 @@ export default function MainApp() {
let webApp;
if (isDemoMode()) {
webApp = getDemoWebApp();
} else {
const WebApp = (await import('@twa-dev/sdk')).default;
} else if (typeof window !== 'undefined') {
webApp = WebApp;
} else {
throw new Error('Приложение должно быть открыто в браузере');
}
// Авторизация пользователя

View File

@ -1,5 +1,14 @@
import MainApp from './components/MainApp';
import dynamic from 'next/dynamic';
import ClientOnly from './components/ClientOnly';
const MainApp = dynamic(() => import('./components/MainApp'), {
ssr: false,
});
export default function Home() {
return <MainApp />;
return (
<ClientOnly>
<MainApp />
</ClientOnly>
);
}