From e449448d48b7809c3367c213bd3ae7d357979761 Mon Sep 17 00:00:00 2001 From: drafish Date: Mon, 29 Jul 2024 10:31:26 +0800 Subject: [PATCH] split homepage --- apps/remix-dapp/src/App.tsx | 11 +- .../remix-dapp/src/components/Home/mobile.tsx | 88 +++++++++++++ apps/remix-dapp/src/components/Home/pc.tsx | 47 +++++++ apps/remix-dapp/src/pages/Home/index.tsx | 124 ------------------ apps/remix-dapp/src/reducers/state.ts | 1 + apps/remix-dapp/src/router.tsx | 11 -- 6 files changed, 143 insertions(+), 139 deletions(-) create mode 100644 apps/remix-dapp/src/components/Home/mobile.tsx create mode 100644 apps/remix-dapp/src/components/Home/pc.tsx delete mode 100644 apps/remix-dapp/src/pages/Home/index.tsx delete mode 100644 apps/remix-dapp/src/router.tsx diff --git a/apps/remix-dapp/src/App.tsx b/apps/remix-dapp/src/App.tsx index ebe6722f39..79b770ae58 100644 --- a/apps/remix-dapp/src/App.tsx +++ b/apps/remix-dapp/src/App.tsx @@ -1,18 +1,19 @@ import React, { useEffect, useReducer } from 'react'; -import { RouterProvider } from 'react-router-dom'; -import router from './router'; import { IntlProvider } from 'react-intl'; import { ToastContainer } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css'; import { AppContext } from './contexts'; import { appInitialState, appReducer } from './reducers/state'; -import { initDispatch, updateState } from './actions'; +import { initDispatch, initInstance, updateState } from './actions'; import enJson from './locales/en'; import zhJson from './locales/zh'; import esJson from './locales/es'; import frJson from './locales/fr'; import itJson from './locales/it'; import './App.css'; +import { isMobile } from './utils/tools'; +import MobilePage from './components/Home/mobile'; +import PCPage from './components/Home/pc'; const localeMap: Record = { zh: zhJson, @@ -31,7 +32,9 @@ function App(): JSX.Element { useEffect(() => { initDispatch(dispatch); updateState(appState); + initInstance(); }, []); + return ( - + {isMobile() ? : } { + const { + appState: { instance }, + } = useContext(AppContext); + const [active, setActive] = useState('functions'); + + return
+
+
+
+ +
+ +
+ +
+ {!instance.noTerminal && ( +
+ +
+ )} +
+ +
+
    +
  • { + setActive('functions'); + }} + > + + Functions + +
  • + {!instance.noTerminal && ( +
  • { + setActive('transactions'); + }} + > + + Transactions + +
  • + )} +
  • { + setActive('settings'); + }} + > + + Settings + +
  • +
+
+}; + +export default MobilePage; diff --git a/apps/remix-dapp/src/components/Home/pc.tsx b/apps/remix-dapp/src/components/Home/pc.tsx new file mode 100644 index 0000000000..0cb31f3d02 --- /dev/null +++ b/apps/remix-dapp/src/components/Home/pc.tsx @@ -0,0 +1,47 @@ +import React, { useContext, useEffect } from 'react'; +import { UniversalDappUI } from '../../components/UniversalDappUI'; +import { SettingsUI } from '../../components/SettingsUI'; +import RemixUiTerminal from '../../components/UiTerminal'; +import DragBar from '../../components/DragBar'; +import DappTop from '../../components/DappTop'; +import { AppContext } from '../../contexts'; + +const PCPage: React.FC = () => { + const { + appState: { terminal, instance }, + } = useContext(AppContext); + const { height } = terminal; + + return
+
+
+
+
+ +
+ +
+ +
+
+ +
+
+ {!instance.noTerminal && ( + <> + + + + )} +
+}; + +export default PCPage; diff --git a/apps/remix-dapp/src/pages/Home/index.tsx b/apps/remix-dapp/src/pages/Home/index.tsx deleted file mode 100644 index 61b53be5b9..0000000000 --- a/apps/remix-dapp/src/pages/Home/index.tsx +++ /dev/null @@ -1,124 +0,0 @@ -import React, { useContext, useEffect, useState } from 'react'; -import { UniversalDappUI } from '../../components/UniversalDappUI'; -import { SettingsUI } from '../../components/SettingsUI'; -import RemixUiTerminal from '../../components/UiTerminal'; -import DragBar from '../../components/DragBar'; -import DappTop from '../../components/DappTop'; -import { AppContext } from '../../contexts'; -import { initInstance } from '../../actions'; -import { isMobile } from '../../utils/tools'; -import TxList from '../../components/UiTerminal/TxList'; - -const HomePage: React.FC = () => { - const { - appState: { terminal, instance }, - } = useContext(AppContext); - const [active, setActive] = useState('functions'); - const { height } = terminal; - useEffect(() => { - initInstance(); - }, []); - - return isMobile() ? ( -
-
- - -
- {!instance.noTerminal && ( -
- -
- )} -
- -
-
    -
  • { - setActive('functions'); - }} - > - - Functions - -
  • - {!instance.noTerminal && ( -
  • { - setActive('transactions'); - }} - > - - Transactions - -
  • - )} -
  • { - setActive('settings'); - }} - > - - Settings - -
  • -
-
- ) : ( -
-
-
-
-
- -
- -
- -
-
- -
-
- {!instance.noTerminal && ( - <> - - - - )} -
- ); -}; - -export default HomePage; diff --git a/apps/remix-dapp/src/reducers/state.ts b/apps/remix-dapp/src/reducers/state.ts index eee54d6b51..bcf01f4158 100644 --- a/apps/remix-dapp/src/reducers/state.ts +++ b/apps/remix-dapp/src/reducers/state.ts @@ -7,6 +7,7 @@ export const appInitialState: any = { decodedResponse: {}, abi: [], solcVersion: {}, + containers: [] }, settings: { sendValue: '0', diff --git a/apps/remix-dapp/src/router.tsx b/apps/remix-dapp/src/router.tsx deleted file mode 100644 index 370bfe4fc8..0000000000 --- a/apps/remix-dapp/src/router.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { createBrowserRouter } from 'react-router-dom'; -import HomePage from './pages/Home'; - -const router = createBrowserRouter([ - { - path: '/', - element: , - }, -]); - -export default router;