diff --git a/config/config.ts b/config/config.ts index 12bddb3..f03db87 100644 --- a/config/config.ts +++ b/config/config.ts @@ -1,6 +1,6 @@ // https://umijs.org/config/ import { defineConfig } from '@umijs/max'; -import defaultSettings, { DefTheme } from './defaultSettings'; +import defaultSettings, { DefTheme, historyType } from './defaultSettings'; import proxy from './proxy'; import routes from './routes'; @@ -8,6 +8,7 @@ const { REACT_APP_ENV = 'dev' } = process.env; export default defineConfig({ esbuildMinifyIIFE: true, + codeSplitting: { jsStrategy: 'granularChunks' }, /** * @name 开启 hash 模式 * @description 让 build 之后的产物包含 hash 后缀。通常用于增量发布和避免浏览器加载缓存。 @@ -18,8 +19,8 @@ export default defineConfig({ /** * @name 使用 Router */ - history: { type: 'browser' }, - exportStatic: {}, + history: { type: historyType }, + // exportStatic: {}, /** * @name 兼容性设置 * @description 设置 ie11 不一定完美兼容,需要检查自己使用的所有依赖 diff --git a/config/defaultSettings.ts b/config/defaultSettings.ts index 1cb6a53..7b12417 100644 --- a/config/defaultSettings.ts +++ b/config/defaultSettings.ts @@ -1,6 +1,8 @@ import { ProLayoutProps } from '@ant-design/pro-components'; import { ThemeConfig } from 'antd'; +export const historyType: 'hash' | 'browser' | 'memory' = 'hash'; + export const HEADER_HEIGHT = 56; export const DefTheme: ThemeConfig = { token: { diff --git a/src/components/common/table.tsx b/src/components/common/table.tsx index 25c2f74..a22498d 100644 --- a/src/components/common/table.tsx +++ b/src/components/common/table.tsx @@ -1,5 +1,6 @@ import { Loading } from '@/components/common/loading'; import { SIZE } from '@/components/const'; +import { Tooltip } from 'antd'; import classNames from 'classnames'; import { FC, useEffect, useRef, useState } from 'react'; import { FiChevronRight, FiFilter } from 'react-icons/fi'; @@ -132,11 +133,9 @@ export const Table: FC = ({ )} > {!!v.tip && ( - + + + )} {v.title} {!!filters[v.dataIndex] && ( diff --git a/src/components/modal/EditorProductSystem.tsx b/src/components/modal/EditorProductSystem.tsx index 0580822..4774ded 100644 --- a/src/components/modal/EditorProductSystem.tsx +++ b/src/components/modal/EditorProductSystem.tsx @@ -3,7 +3,7 @@ import { Loading } from '@/components/common/loading'; import { Modal, ModalProps } from '@/components/common/modal'; import { useProductSystem } from '@/lib/hooks/useDatas'; import { useIsVerifier } from '@/lib/hooks/useUser'; -import { shortStr, tryParse } from '@/lib/utils'; +import { shortStr, tryParse, wrapPath } from '@/lib/utils'; import classNames from 'classnames'; import _ from 'lodash'; import { @@ -116,8 +116,8 @@ export function LcaActionInfo(p: { if (modelStatus !== 1) return
等待解析
; return ( (openNewTab ? window.open(`/model?id=${modelId}`, '_blank') : undefined)} - to={!openNewTab ? `/model?id=${modelId}` : undefined} + onClick={() => (openNewTab ? window.open(`${wrapPath('/model')}?id=${modelId}`, '_blank') : undefined)} + to={!openNewTab ? `${wrapPath('/model')}?id=${modelId}` : undefined} action="在线查看" /> ); diff --git a/src/components/modal/ViewBomInfoModal.tsx b/src/components/modal/ViewBomInfoModal.tsx index a367d69..5e65f81 100644 --- a/src/components/modal/ViewBomInfoModal.tsx +++ b/src/components/modal/ViewBomInfoModal.tsx @@ -5,6 +5,7 @@ import { PairInfo } from './EditorProductSystem'; import { shortStr } from '@/lib/utils'; import { handleContentRender } from '@/lib/utils'; import { isTagType } from '@/lib/tagtools'; +import { Tooltip } from 'antd'; interface ViewBomInfoModalProps { onClose: () => void; @@ -61,8 +62,8 @@ const ViewBomInfoModal: FC = ({ onClose, ...props }) => { {(result || []).map((e: any, i: number) => { return ( -
-
{e.flowName}
+
+
{e.flowName}
{(e?.partNumbers || []).map((item: any, index: number) => { return ( @@ -70,13 +71,11 @@ const ViewBomInfoModal: FC = ({ onClose, ...props }) => { key={`value_${index}`} className="flex max-w-lg items-center bg-[#F1F1F1] h-6 mb-[10px] rounded ml-5" > -
- PN : {shortStr(item, 8, 8)} -
+ +
+ PN : {shortStr(item, 8, 8)} +
+
); })} diff --git a/src/components/routes/carbon/tags.tsx b/src/components/routes/carbon/tags.tsx index c818ffb..ca3c7e8 100644 --- a/src/components/routes/carbon/tags.tsx +++ b/src/components/routes/carbon/tags.tsx @@ -3,7 +3,7 @@ import WrapPageContainer from '@/components/ant/WrapPageContainer'; import { ProductQrcode } from '@/components/common/productQrcode'; import { Teacher as SvgTeacher } from '@/components/svgr'; import { useTags } from '@/lib/hooks/useDatas'; -import { getCurrentDate } from '@/lib/utils'; +import { getCurrentDate, wrapPath } from '@/lib/utils'; import _ from 'lodash'; import { useMemo } from 'react'; @@ -81,23 +81,24 @@ export function Tag() { }, ]; return records.map(({ loadName, proofTime, tokenId, tokenUrl, uuid, verifyUserName, orgName, orgType }) => { + const name = orgType !== 'aicp' ? 'Certified' : 'Verified'; return { title: loadName, icon: , by: `${getCurrentDate(proofTime, 'YYYY年MM月DD日')}签发 by ${orgName}`, id: uuid, qrcodeDisable: false, + name, link: [ { text: '标签信息', href: `/label?vin=${uuid}` }, { text: '在区块链浏览器查看', - href: `/chain?tokenId=${tokenId}`, + href: `/chain?tokenId=${tokenId}&name=${name}`, }, ], tokenId, - name: orgType !== 'aicp' ? 'Certified' : 'Verified', orgName, - qrCode: `${window.origin}/label?vin=${uuid}`, + qrCode: `${window.origin}${wrapPath('/label')}?vin=${uuid}`, }; }); }, [data]); diff --git a/src/components/routes/chain.tsx b/src/components/routes/chain.tsx index 8784772..409eb27 100644 --- a/src/components/routes/chain.tsx +++ b/src/components/routes/chain.tsx @@ -4,7 +4,7 @@ import { Table } from '@/components/common/table'; import { Aicp as SVGAICP, GGX as SvgGgx } from '@/components/svgr'; import { useSBT } from '@/lib/hooks/useDatas'; import { useT } from '@/lib/hooks/useT'; -import { autoFormaterRealTime, genScanUrl, shortStr } from '@/lib/utils'; +import { autoFormaterRealTime, genScanUrl, shortStr, wrapPath } from '@/lib/utils'; import { useSearchParams } from '@umijs/max'; import classNames from 'classnames'; import { now } from 'lodash'; @@ -13,6 +13,7 @@ import { VscQuestion, VscVerified } from 'react-icons/vsc'; import { WrapLink } from '../ant/Link'; import WrapPageContainer from '../ant/WrapPageContainer'; import { HeaderLayout } from '../common/headerLayout'; +import { Tooltip } from 'antd'; function ItemInfo(p: { label: string; text: string; link?: string; tip?: any; className?: string }) { return ( @@ -27,11 +28,9 @@ function ItemInfo(p: { label: string; text: string; link?: string; tip?: any; cl )} > {!!p.tip && ( - + + + )} {p.label}:{' '} {p.link ? ( @@ -106,6 +105,7 @@ function CardInfo(p: any) { export function Blockchain() { const [sq] = useSearchParams(); const tokenId = sq.get('tokenId'); + const name = sq.get('name'); const { t, formatRelativeTime } = useT(); const isMobile = useIsMobile(); const [current, setCurrent] = useState(''); @@ -128,7 +128,7 @@ export function Blockchain() { ), render: (text: string) => { return ( - + {shortStr(text)} ); @@ -164,7 +164,7 @@ export function Blockchain() { dataIndex: 'fromAddress', render: (text: string) => { return ( - + {shortStr(text)} ); @@ -175,7 +175,7 @@ export function Blockchain() { dataIndex: 'toAddress', render: (text: string) => { return ( - + {shortStr(text)} ); @@ -186,8 +186,6 @@ export function Blockchain() { 'GGX (GTech Green Chain) is a shared digital space for the automotive industry. GGX offers 3T (Transparency, Traceability, Trust) featured data as a solid foundation for cross-boundary collaboration between automotive value chain players.', ); - console.log('sbtTagList', sbtTagList); - return ( @@ -196,7 +194,8 @@ export function Blockchain() {
@@ -214,14 +213,14 @@ export function Blockchain() {
-
{t('Label Details')}
+
{t('Label Details')}
-

{t('Item Activity on Blockchain')}

+

{t('Item Activity on Blockchain')}

@@ -230,7 +229,7 @@ export function Blockchain() {

{t('Platform powered by:')}

- + {t('Automotive Industry Carbon Platform')}

@@ -244,7 +243,7 @@ export function Blockchain() {

{t('Blockchain powered by:')}

- + {t('GGX Blockchain')}

diff --git a/src/components/routes/label.tsx b/src/components/routes/label.tsx index 755d836..6248ded 100644 --- a/src/components/routes/label.tsx +++ b/src/components/routes/label.tsx @@ -2,7 +2,7 @@ import { Carbon3 as SVGCarbon3 } from '@/components/svgr'; import { useTagInfo } from '@/lib/hooks/useDatas'; import { useT } from '@/lib/hooks/useT'; -import { genScanUrl, handleCarbonStr } from '@/lib/utils'; +import { genScanUrl, handleCarbonStr, wrapPath } from '@/lib/utils'; import { useSearchParams } from '@umijs/max'; import { Fragment } from 'react'; import WrapPageContainer from '../ant/WrapPageContainer'; @@ -118,9 +118,9 @@ export function Label() { 'A Soul-bounded Token (a special type of NFT that is not allowed to transfer after created) has been generated on blockchain to make sure the information in this label is immutable and will be maintain for traceability forever. Check {{value}} to verify the SBT on blockchain explorer.', ).replace( '{{value}}', - `${t( - 'here', - )}`, + `${t('here')}`, ), }} /> diff --git a/src/components/routes/tools/verificationManagement/index.tsx b/src/components/routes/tools/verificationManagement/index.tsx index 957cb50..c4c2b6c 100644 --- a/src/components/routes/tools/verificationManagement/index.tsx +++ b/src/components/routes/tools/verificationManagement/index.tsx @@ -123,6 +123,7 @@ export function VerificationManagementList() { title: '验证时间', dataIndex: 'proofTime', valueType: 'dateTime', + width: 170, }, { diff --git a/src/layout/_app.tsx b/src/layout/_app.tsx index ec617b1..4c82585 100644 --- a/src/layout/_app.tsx +++ b/src/layout/_app.tsx @@ -5,14 +5,10 @@ import classNames from 'classnames'; import { authGetResData } from '@/lib/http'; import React, { FC, ReactNode } from 'react'; import 'react-tippy/dist/tippy.css'; -import { Tooltip } from 'react-tooltip'; import 'react-tooltip/dist/react-tooltip.css'; import { SWRConfig } from 'swr/_internal'; function InitProvider(p: { children: React.ReactNode }) { - // useEffect(() => { - // modalRootRef.current = document.body as any; - // }, []); return ( - ); -} - function App(p: { children?: ReactNode }) { return (
@@ -47,7 +29,6 @@ function App(p: { children?: ReactNode }) { {p.children} -
); } diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 8d53f07..9788937 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,10 +1,10 @@ import { useIntl } from '@umijs/max'; import { AxiosError } from 'axios'; +import dayjs from 'dayjs'; import _, { toInteger } from 'lodash'; import moment from 'moment'; +import { historyType } from '../../config/defaultSettings'; import { LABEL_CONTRACT, SCAN_BASE } from './env'; -import dayjs from 'dayjs'; - export const DATE_FTM = { long: 'YYYY-MM-DD HH:mm:ss', short: 'YYYY-MM-DD', @@ -234,3 +234,10 @@ export const convertArr = (label: string | number, value: string | number, arr?: return { label: item[label], value: item[value] }; }); }; + +export function wrapPath(path: `/${string}`) { + if (historyType === 'hash') { + return '/#' + path; + } + return path; +}