From 298cb4a8efa5bf75c781affbe6bb9de39f5dcadc Mon Sep 17 00:00:00 2001 From: TaoGao Date: Sat, 14 Oct 2023 00:46:19 +0800 Subject: [PATCH] eth-space first commit --- packages/nextjs/components/Header.tsx | 35 +++--- packages/nextjs/pages/eth-space.tsx | 111 +++++++++++++++++ packages/nextjs/pages/index copy.tsx | 73 +++++++++++ packages/nextjs/pages/index.tsx | 170 ++++++++++++++++---------- 4 files changed, 308 insertions(+), 81 deletions(-) create mode 100644 packages/nextjs/pages/eth-space.tsx create mode 100644 packages/nextjs/pages/index copy.tsx diff --git a/packages/nextjs/components/Header.tsx b/packages/nextjs/components/Header.tsx index 34153cc..6019f7f 100644 --- a/packages/nextjs/components/Header.tsx +++ b/packages/nextjs/components/Header.tsx @@ -13,25 +13,30 @@ interface HeaderMenuLink { } export const menuLinks: HeaderMenuLink[] = [ + // { + // label: "Home", + // href: "/", + // }, + // { + // label: "Debug Contracts", + // href: "/debug", + // icon: , + // }, + // { + // label: "Example UI", + // href: "/example-ui", + // icon: , + // }, { - label: "Home", + label: "ETH-SPACE", href: "/", - }, - { - label: "Debug Contracts", - href: "/debug", - icon: , - }, - { - label: "Example UI", - href: "/example-ui", icon: , }, - { - label: "Block Explorer", - href: "/blockexplorer", - icon: , - }, + // { + // label: "Block Explorer", + // href: "/blockexplorer", + // icon: , + // }, ]; export const HeaderMenuLinks = () => { diff --git a/packages/nextjs/pages/eth-space.tsx b/packages/nextjs/pages/eth-space.tsx new file mode 100644 index 0000000..d9a9543 --- /dev/null +++ b/packages/nextjs/pages/eth-space.tsx @@ -0,0 +1,111 @@ +import { NextPage } from "next"; +import { useEffect, useState } from "react"; + +const ETHSpace: NextPage = () => { + //在对后端发起请求后,将response的内容保存在results中 + const [result, setResult] = useState("The search results will be shown here"); + //设置默认是在我们提供的数据集而不是公共数据集中查询 + const [qinPublic, setQinPublic] = useState(false); + //获取目前提供的数据集选项 + const [options, setOptions] = useState([]); + //获取用户选择的数据集 + const [dataset, setDataset] = useState(""); + //获取用户搜索的prompt + const [seaPrompt, setSeaPrompt] = useState(""); + //仅在组件挂载时执行一次获取数据集列表 + useEffect(() => { + const data = fetchOptions(); + setOptions(data); + }); + + //从后端获取数据集列表 + const fetchOptions = () => { + return ['eth-whitepaper', 'eth-contracts']; + }; + //获取search prompt与dataset名字后向后端发request + const handleonClick =()=>{ + + }; + return ( +
+
+
+
+

ETH-SPACE

+

AI-based Smart Contract Explorer

+
+ +
+
+
+
+ { + setSeaPrompt(e.target.value); + }} + placeholder="Enter your prompt to search" /> +
+
+
+
+ {!qinPublic ? ( + + ) : ( + { + setDataset(e.target.value); + }} + placeholder="Pls input the public dataset name" /> + )} +
+
+
+ +
+
+ + A search question example: Give me the examples about struct. The "type" in metadata should be "struct". + +
+
+
+
+
+

Search Results

+ + {result} + +
+ +
+
+ ) +}; + +export default ETHSpace; \ No newline at end of file diff --git a/packages/nextjs/pages/index copy.tsx b/packages/nextjs/pages/index copy.tsx new file mode 100644 index 0000000..4cac710 --- /dev/null +++ b/packages/nextjs/pages/index copy.tsx @@ -0,0 +1,73 @@ +import Link from "next/link"; +import type { NextPage } from "next"; +import { BugAntIcon, MagnifyingGlassIcon, SparklesIcon } from "@heroicons/react/24/outline"; +import { MetaHeader } from "~~/components/MetaHeader"; +//se-2原先的home界面留存 +const Home: NextPage = () => { + return ( + <> + +
+
+

+ Welcome to + Scaffold-ETH 2 +

+

+ Get started by editing{" "} + + packages/nextjs/pages/index.tsx + +

+

+ Edit your smart contract{" "} + + YourContract.sol + {" "} + in{" "} + + packages/hardhat/contracts + +

+
+ +
+
+
+ +

+ Tinker with your smart contract using the{" "} + + Debug Contract + {" "} + tab. +

+
+
+ +

+ Experiment with{" "} + + Example UI + {" "} + to build your own UI. +

+
+
+ +

+ Explore your local transactions with the{" "} + + Block Explorer + {" "} + tab. +

+
+
+
+
+ + ); +}; + +export default Home; diff --git a/packages/nextjs/pages/index.tsx b/packages/nextjs/pages/index.tsx index 0a5c06a..d9a9543 100644 --- a/packages/nextjs/pages/index.tsx +++ b/packages/nextjs/pages/index.tsx @@ -1,73 +1,111 @@ -import Link from "next/link"; -import type { NextPage } from "next"; -import { BugAntIcon, MagnifyingGlassIcon, SparklesIcon } from "@heroicons/react/24/outline"; -import { MetaHeader } from "~~/components/MetaHeader"; +import { NextPage } from "next"; +import { useEffect, useState } from "react"; -const Home: NextPage = () => { - return ( - <> - -
-
-

- Welcome to - Scaffold-ETH 2 -

-

- Get started by editing{" "} - - packages/nextjs/pages/index.tsx - -

-

- Edit your smart contract{" "} - - YourContract.sol - {" "} - in{" "} - - packages/hardhat/contracts - -

-
+const ETHSpace: NextPage = () => { + //在对后端发起请求后,将response的内容保存在results中 + const [result, setResult] = useState("The search results will be shown here"); + //设置默认是在我们提供的数据集而不是公共数据集中查询 + const [qinPublic, setQinPublic] = useState(false); + //获取目前提供的数据集选项 + const [options, setOptions] = useState([]); + //获取用户选择的数据集 + const [dataset, setDataset] = useState(""); + //获取用户搜索的prompt + const [seaPrompt, setSeaPrompt] = useState(""); + //仅在组件挂载时执行一次获取数据集列表 + useEffect(() => { + const data = fetchOptions(); + setOptions(data); + }); -
-
-
- -

- Tinker with your smart contract using the{" "} - - Debug Contract - {" "} - tab. -

-
-
- -

- Experiment with{" "} - - Example UI - {" "} - to build your own UI. -

+ //从后端获取数据集列表 + const fetchOptions = () => { + return ['eth-whitepaper', 'eth-contracts']; + }; + //获取search prompt与dataset名字后向后端发request + const handleonClick =()=>{ + + }; + return ( +
+
+
+
+

ETH-SPACE

+

AI-based Smart Contract Explorer

+
+ +
+
+
+
+ { + setSeaPrompt(e.target.value); + }} + placeholder="Enter your prompt to search" /> +
+
+
+
+ {!qinPublic ? ( + + ) : ( + { + setDataset(e.target.value); + }} + placeholder="Pls input the public dataset name" /> + )} +
+
+
+ +
+
+ + A search question example: Give me the examples about struct. The "type" in metadata should be "struct". + +
+
-
- -

- Explore your local transactions with the{" "} - - Block Explorer - {" "} - tab. -

+
+
+

Search Results

+ + {result} + +
+
-
-
- - ); + ) }; -export default Home; +export default ETHSpace; \ No newline at end of file