From ecb980114d6df9f8f9e7642015f850dacddaede3 Mon Sep 17 00:00:00 2001 From: tonytc13579 Date: Tue, 2 Jan 2024 14:40:45 +0700 Subject: [PATCH 1/4] Modify path bvm-website-sats --- next.config.js | 4 ++-- src/app/blockchains/page.tsx | 17 +++++++++-------- src/app/tc/page.tsx | 32 -------------------------------- src/layouts/Header/menuConfig.ts | 2 +- src/modules/iframe-tc/index.tsx | 27 ++++++++++++++++++++++++--- 5 files changed, 36 insertions(+), 46 deletions(-) delete mode 100644 src/app/tc/page.tsx diff --git a/next.config.js b/next.config.js index b469c1ed5..a97523982 100644 --- a/next.config.js +++ b/next.config.js @@ -48,8 +48,8 @@ const nextConfig = { permanent: false, }, { - source: '/blockchains/dashboard', - destination: '/blockchains/computers', + source: '/blockchains/computers', + destination: '/blockchains', permanent: false, }, ]; diff --git a/src/app/blockchains/page.tsx b/src/app/blockchains/page.tsx index 5331a2960..b674ef24f 100644 --- a/src/app/blockchains/page.tsx +++ b/src/app/blockchains/page.tsx @@ -4,14 +4,17 @@ import { isProduction } from '@/config'; import MainLayout from '@/layouts/MainLayout'; import IframeTC from '@/modules/iframe-tc'; -const pathUrl = '/trustless-computers-iframe/'; -// const IframeURLExtend = DOMAIN_URL + MAIN_PATH; +const pathUrl = '/bvm-website-sats-iframe/computers'; const IframeURLExtend = - 'https://dev.newbitcoincity.com/trustless-computers-iframe/'; + 'http://localhost:6009/trustless-computers-iframe/dashboard'; + +// const iframeDomain = isProduction +// ? 'http://localhost:6009' +// : 'http://localhost:6009'; const iframeDomain = isProduction - ? 'https://newbitcoincity.com' - : 'https://dev.newbitcoincity.com'; + ? 'https://bvm.network' + : 'https://dev.bvm.network'; const TCPage = () => { return ( @@ -22,9 +25,7 @@ const TCPage = () => { bgColor: 'white', }} > - {typeof document !== 'undefined' ? ( - - ) : null} + ); }; diff --git a/src/app/tc/page.tsx b/src/app/tc/page.tsx deleted file mode 100644 index 5331a2960..000000000 --- a/src/app/tc/page.tsx +++ /dev/null @@ -1,32 +0,0 @@ -'use client'; - -import { isProduction } from '@/config'; -import MainLayout from '@/layouts/MainLayout'; -import IframeTC from '@/modules/iframe-tc'; - -const pathUrl = '/trustless-computers-iframe/'; -// const IframeURLExtend = DOMAIN_URL + MAIN_PATH; -const IframeURLExtend = - 'https://dev.newbitcoincity.com/trustless-computers-iframe/'; - -const iframeDomain = isProduction - ? 'https://newbitcoincity.com' - : 'https://dev.newbitcoincity.com'; - -const TCPage = () => { - return ( - - {typeof document !== 'undefined' ? ( - - ) : null} - - ); -}; - -export default TCPage; diff --git a/src/layouts/Header/menuConfig.ts b/src/layouts/Header/menuConfig.ts index 6675643b1..b9aefade0 100644 --- a/src/layouts/Header/menuConfig.ts +++ b/src/layouts/Header/menuConfig.ts @@ -10,7 +10,7 @@ export interface NavItem { export const NAV_ITEMS: Array = [ { label: 'Blockchains', - href: '/blockchains', + href: '/blockchains/computers', isNewWindow: false, isHide: false, }, diff --git a/src/modules/iframe-tc/index.tsx b/src/modules/iframe-tc/index.tsx index 55c837768..ea4bbcffb 100644 --- a/src/modules/iframe-tc/index.tsx +++ b/src/modules/iframe-tc/index.tsx @@ -1,14 +1,16 @@ 'use client'; import useWindowSize from '@/hooks/useWindowSize'; +import { Flex, Spinner } from '@chakra-ui/react'; +import { useEffect, useState } from 'react'; import s from './styles.module.scss'; -import { useEffect } from 'react'; interface IProps { iframeURL: string; } const IframeTC = (props: IProps) => { + const [iframeLoading, setIframeLoading] = useState(true); const { heightWidth } = useWindowSize(); const elmHeader = document?.getElementById('header'); @@ -20,11 +22,26 @@ const IframeTC = (props: IProps) => { elmHeader.click(); } } - window.addEventListener('blur', blur); + setIframeLoading(false); return () => window.removeEventListener('blur', blur); }, [document]); - if (!document) return <>; + if (!document) { + return <>; + } + if (iframeLoading) { + return ( + + + + ); + } return (
{ src={props.iframeURL} width="100%" style={{ border: 'none' }} + onLoadedData={() => {}} + onLoad={() => { + setIframeLoading(false); + }} />
); From 62e90a2c0b731833ac4d47765f69e7a528402137 Mon Sep 17 00:00:00 2001 From: tonytc13579 Date: Tue, 2 Jan 2024 15:02:16 +0700 Subject: [PATCH 2/4] Fix: import dynamic when build ssr --- src/app/blockchains/page.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/blockchains/page.tsx b/src/app/blockchains/page.tsx index b674ef24f..14184b665 100644 --- a/src/app/blockchains/page.tsx +++ b/src/app/blockchains/page.tsx @@ -3,6 +3,7 @@ import { isProduction } from '@/config'; import MainLayout from '@/layouts/MainLayout'; import IframeTC from '@/modules/iframe-tc'; +import dynamic from 'next/dynamic'; const pathUrl = '/bvm-website-sats-iframe/computers'; const IframeURLExtend = @@ -16,6 +17,13 @@ const iframeDomain = isProduction ? 'https://bvm.network' : 'https://dev.bvm.network'; +const IframeTCDynamic = dynamic( + () => import('@/modules/iframe-tc').then((m) => m.default), + { + ssr: false, + }, +); + const TCPage = () => { return ( { bgColor: 'white', }} > - + ); }; From bdeca808e881cd95449b938ac7922e3273c9efc2 Mon Sep 17 00:00:00 2001 From: tonytc13579 Date: Tue, 2 Jan 2024 15:15:06 +0700 Subject: [PATCH 3/4] config redirect --- next.config.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/next.config.js b/next.config.js index a97523982..aa41d296c 100644 --- a/next.config.js +++ b/next.config.js @@ -47,6 +47,11 @@ const nextConfig = { destination: '/blockchains', permanent: false, }, + { + source: '/bvm-website-sats', + destination: '/blockchains', + permanent: false, + }, { source: '/blockchains/computers', destination: '/blockchains', From 73424f6f9f58051d0ca864d2122c5220d8beea96 Mon Sep 17 00:00:00 2001 From: tonytc13579 Date: Tue, 2 Jan 2024 15:21:43 +0700 Subject: [PATCH 4/4] Modify code --- next.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/next.config.js b/next.config.js index aa41d296c..9c4f4056d 100644 --- a/next.config.js +++ b/next.config.js @@ -44,12 +44,12 @@ const nextConfig = { return [ { source: '/trustless-computers', - destination: '/blockchains', + destination: '/blockchains/computers', permanent: false, }, { source: '/bvm-website-sats', - destination: '/blockchains', + destination: '/blockchains/computers', permanent: false, }, {