From 8175efcb0405720a03e7b4c9bb68f59b94aa2a1f Mon Sep 17 00:00:00 2001 From: fearlessfe <505380967@qq.com> Date: Sun, 1 Sep 2024 16:51:51 +0800 Subject: [PATCH 1/2] fix: claim graph show error --- src/components/Charts/ClaimChart/index.tsx | 87 +++++++++++++--------- src/utils/tree.ts | 2 +- 2 files changed, 53 insertions(+), 36 deletions(-) diff --git a/src/components/Charts/ClaimChart/index.tsx b/src/components/Charts/ClaimChart/index.tsx index 4f18b37..d3005bf 100644 --- a/src/components/Charts/ClaimChart/index.tsx +++ b/src/components/Charts/ClaimChart/index.tsx @@ -3,7 +3,12 @@ import { ClaimData } from "@/types"; import { depth, shortenAddress } from "@/utils"; import { EChartOption } from "echarts"; import React, { FC, useState } from "react"; -import { Dialog, DialogBackdrop, DialogPanel, DialogTitle } from '@headlessui/react' +import { + Dialog, + DialogBackdrop, + DialogPanel, + DialogTitle, +} from "@headlessui/react"; import { ConnectButton } from "@rainbow-me/rainbowkit"; import { Button } from "@/components/Button"; import { Input } from "@/components/Input"; @@ -13,16 +18,16 @@ const yGap = 100; const yBase = 100; type Node = { - name: string, - claim: string, - position: string, - value: string, + name: string; + claim: string; + position: string; + value: string; itemStyle: { - color: string, - }, - x: number, - y: number, -} + color: string; + }; + x: number; + y: number; +}; const isAttack = (cur: bigint, parent: bigint): boolean => { if (parent * BigInt(2) === cur) { @@ -100,6 +105,7 @@ const genNodesAndLinks = (data: ClaimData[]): any => { levelMap.set(deep, deepCount + 1); } } + console.log(maxDepth); return { nodes, links, @@ -112,7 +118,7 @@ const ClaimChart: FC<{ claimData: ClaimData[] }> = ({ claimData }) => { const options: EChartOption = { tooltip: { trigger: "item", - triggerOn: 'click', + triggerOn: "click", formatter: (params: any) => { // if (params.dataType === "node") { // return `${params.data.claim}`; @@ -148,7 +154,7 @@ const ClaimChart: FC<{ claimData: ClaimData[] }> = ({ claimData }) => { label: { show: true, formatter: (params: any) => { - return params.data.value + return params.data.value; }, }, edgeSymbol: ["circle", "arrow"], @@ -160,17 +166,22 @@ const ClaimChart: FC<{ claimData: ClaimData[] }> = ({ claimData }) => { }, ], }; - const [showModal, setShowModal] = useState(false) - const [modalData, setModalData] = useState() - const [val, setVal] = useState('') + const [showModal, setShowModal] = useState(false); + const [modalData, setModalData] = useState(); + const [val, setVal] = useState(""); const handleClick = (e: any) => { - setShowModal(true) - setModalData(e.data) - console.log(e.data, 'e') - } + setShowModal(true); + setModalData(e.data); + console.log(e.data, "e"); + }; return ( <> - setShowModal(false)}> + setShowModal(false)} + > = ({ claimData }) => {

-
Claim
-
{modalData?.claim}
+
+ Claim +
+
+ {modalData?.claim} +
-
challenge claim
+
+ challenge claim +
= ({ claimData }) => { value={val} onChange={(e) => setVal(e.target.value)} className={"rounded-none rounded-l-md"} - placeholder={'challenge string'} + placeholder={"challenge string"} />

{" "} + + >
-
Fault Dispute Game Graph
- - } + title={ +
+
Fault Dispute Game Graph
+ +
+ } handleClick={handleClick} options={options} depth={maxDepth} /> - ); }; diff --git a/src/utils/tree.ts b/src/utils/tree.ts index 4ce6b82..8595af8 100644 --- a/src/utils/tree.ts +++ b/src/utils/tree.ts @@ -1,4 +1,4 @@ export const depth = (position: bigint): number => { const bitLength = position.toString(2).length; // 将 position 转为二进制字符串并获取其长度 - return 31 - (bitLength - 1); + return bitLength - 1; }; From f9023b3184bd4e402b463a7e1243b0f6a7a93a0e Mon Sep 17 00:00:00 2001 From: fearlessfe <505380967@qq.com> Date: Sun, 1 Sep 2024 16:52:42 +0800 Subject: [PATCH 2/2] feat: add GA --- src/pages/_app.tsx | 5 +---- src/pages/_document.tsx | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 2ba75d6..51b6500 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -24,10 +24,7 @@ const App = ({ Component, pageProps }: NextAppProps) => { > Super Proof - + diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index 08e1a28..5f671be 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -1,4 +1,5 @@ import NextDocument, { Head, Html, Main, NextScript } from "next/document"; +import Script from "next/script"; export default class Document extends NextDocument { render() { @@ -6,6 +7,15 @@ export default class Document extends NextDocument { + +