Skip to content

Commit

Permalink
Merge pull request #2 from gtech-world/main
Browse files Browse the repository at this point in the history
v1.0.1
  • Loading branch information
XueMoMo authored Oct 18, 2023
2 parents 37cfa76 + 5bcecef commit e16a293
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 65 deletions.
7 changes: 4 additions & 3 deletions config/config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// 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';

const { REACT_APP_ENV = 'dev' } = process.env;

export default defineConfig({
esbuildMinifyIIFE: true,
codeSplitting: { jsStrategy: 'granularChunks' },
/**
* @name 开启 hash 模式
* @description 让 build 之后的产物包含 hash 后缀。通常用于增量发布和避免浏览器加载缓存。
Expand All @@ -18,8 +19,8 @@ export default defineConfig({
/**
* @name 使用 Router
*/
history: { type: 'browser' },
exportStatic: {},
history: { type: historyType },
// exportStatic: {},
/**
* @name 兼容性设置
* @description 设置 ie11 不一定完美兼容,需要检查自己使用的所有依赖
Expand Down
2 changes: 2 additions & 0 deletions config/defaultSettings.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down
9 changes: 4 additions & 5 deletions src/components/common/table.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -132,11 +133,9 @@ export const Table: FC<Table.ITable> = ({
)}
>
{!!v.tip && (
<VscQuestion
data-tooltip-id="tooltip"
data-tooltip-content={v.tip}
className="inline-block text-xl mt-[-0.15rem] mr-1"
/>
<Tooltip title={v.tip}>
<VscQuestion className="inline-block text-xl mt-[-0.15rem] mr-1" />
</Tooltip>
)}
<span>{v.title}</span>
{!!filters[v.dataIndex] && (
Expand Down
6 changes: 3 additions & 3 deletions src/components/modal/EditorProductSystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -116,8 +116,8 @@ export function LcaActionInfo(p: {
if (modelStatus !== 1) return <div className="text-base font-normal leading-none text-amber-500">等待解析</div>;
return (
<ActionBtn
onClick={() => (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="在线查看"
/>
);
Expand Down
17 changes: 8 additions & 9 deletions src/components/modal/ViewBomInfoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -61,22 +62,20 @@ const ViewBomInfoModal: FC<ViewBomInfoModalProps> = ({ onClose, ...props }) => {
<PairInfo tit="Part Number信息" value={null} />
{(result || []).map((e: any, i: number) => {
return (
<div key={`info_${i}`} className="flex flex-row gap-10 p-0">
<div className="w-[200px] text-sm text-[#666666] ">{e.flowName}</div>
<div key={`info_${i}`} className="flex flex-row gap-10 mt-[-15px] ">
<div className="w-[230px] text-sm text-[#666666] ">{e.flowName}</div>
<div className="flex flex-wrap flex-shrink w-[30rem] items-center">
{(e?.partNumbers || []).map((item: any, index: number) => {
return (
<div
key={`value_${index}`}
className="flex max-w-lg items-center bg-[#F1F1F1] h-6 mb-[10px] rounded ml-5"
>
<div
className=" w-full text-sm mx-[10px] items-center font-normal"
data-tooltip-id="tooltip"
data-tooltip-content={handleContentRender(item, 10)}
>
PN : {shortStr(item, 8, 8)}
</div>
<Tooltip title={handleContentRender(item, 10)}>
<div className=" w-full text-sm mx-[10px] items-center font-normal">
PN : {shortStr(item, 8, 8)}
</div>
</Tooltip>
</div>
);
})}
Expand Down
9 changes: 5 additions & 4 deletions src/components/routes/carbon/tags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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: <SvgTeacher className="w-[2.75rem]" />,
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]);
Expand Down
31 changes: 15 additions & 16 deletions src/components/routes/chain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 (
Expand All @@ -27,11 +28,9 @@ function ItemInfo(p: { label: string; text: string; link?: string; tip?: any; cl
)}
>
{!!p.tip && (
<VscQuestion
data-tooltip-id="tooltip"
data-tooltip-content={p.tip}
className="absolute text-black left-[-1.6rem] text-xl top-[0.29rem]"
/>
<Tooltip title={p.tip}>
<VscQuestion className="absolute text-black left-[-1.6rem] text-xl top-[0.29rem]" />
</Tooltip>
)}
<span className="font-bold text-black">{p.label}:</span>{' '}
{p.link ? (
Expand Down Expand Up @@ -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('');
Expand All @@ -128,7 +128,7 @@ export function Blockchain() {
),
render: (text: string) => {
return (
<WrapLink className="text-green-2" target="_blank" to={genScanUrl('tx', text)}>
<WrapLink className="text-green-2 !text-base" target="_blank" to={genScanUrl('tx', text)}>
{shortStr(text)}
</WrapLink>
);
Expand Down Expand Up @@ -164,7 +164,7 @@ export function Blockchain() {
dataIndex: 'fromAddress',
render: (text: string) => {
return (
<WrapLink className="text-green-2" target="_blank" to={genScanUrl('address', text)}>
<WrapLink className="text-green-2 !text-base" target="_blank" to={genScanUrl('address', text)}>
{shortStr(text)}
</WrapLink>
);
Expand All @@ -175,7 +175,7 @@ export function Blockchain() {
dataIndex: 'toAddress',
render: (text: string) => {
return (
<WrapLink className="text-green-2" target="_blank" to={genScanUrl('address', text)}>
<WrapLink className="text-green-2 !text-base" target="_blank" to={genScanUrl('address', text)}>
{shortStr(text)}
</WrapLink>
);
Expand All @@ -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 (
<HeaderLayout>
<WrapPageContainer loading={loading} className="flex flex-col flex-1 w-full text-black bg-gray-16 min-h-fit">
Expand All @@ -196,7 +194,8 @@ export function Blockchain() {
<div className="bg-white flex justify-center px-10 items-center rounded-lg mo:h-[21rem] mo:px-0">
<ProductQrcode
className=""
data={`${current || 'https://aicp.gtech.world'}/car?vin=${sbtTagList?.uuid}`}
name={name}
data={`${current || 'https://aicp.gtech.world'}${wrapPath('/label')}?vin=${sbtTagList?.uuid}`}
/>
</div>
<div className="flex flex-col flex-1 ml-5 mo:ml-0 mo:mt-5">
Expand All @@ -214,14 +213,14 @@ export function Blockchain() {
</div>
</div>
<div className="px-12 py-5 bg-white rounded-lg mo:pl-10 mo:pr-3">
<h5 className="text-xl mb-3.5 font-bold mo:text-lg">{t('Label Details')}</h5>
<h5 className="mb-3.5 font-bold text-lg">{t('Label Details')}</h5>
<CardInfo data={sbtTagList} />
</div>
</div>
</div>

<div className="px-8 py-5 mt-5 bg-white rounded-lg mo:px-4">
<h3 className="font-bold">{t('Item Activity on Blockchain')}</h3>
<h3 className="text-lg font-bold">{t('Item Activity on Blockchain')}</h3>
<div className="w-full overflow-hidden overflow-x-auto mo:pb-5">
<Table className="mt-5 mo:w-[52rem]" columns={columns} data={sbtTagList?.transferEvents || []} />
</div>
Expand All @@ -230,7 +229,7 @@ export function Blockchain() {
<SVGAICP fill="#29953A" className="w-[6.125rem] mb-5" />
<p className="font-bold">{t('Platform powered by:')}</p>
<p className="text-green-2">
<WrapLink to="https://aicp.gtech.world/" target="_blank">
<WrapLink className="!text-base" to="https://aicp.gtech.world/" target="_blank">
{t('Automotive Industry Carbon Platform')}
</WrapLink>
</p>
Expand All @@ -244,7 +243,7 @@ export function Blockchain() {
<SvgGgx className="mb-5" />
<p className="font-bold">{t('Blockchain powered by:')}</p>
<p className="text-green-2">
<WrapLink to={`https://explorer.gtech.world`} target="_blank">
<WrapLink className="!text-base" to={`https://explorer.gtech.world`} target="_blank">
{t('GGX Blockchain')}
</WrapLink>
</p>
Expand Down
8 changes: 4 additions & 4 deletions src/components/routes/label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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}}',
`<a class="text-green-2 cursor-pointer" href="/chain?tokenId=${tokenId}" rel="noreferrer">${t(
'here',
)}</a>`,
`<a class="text-green-2 cursor-pointer" href="${wrapPath(
'/chain',
)}?tokenId=${tokenId}" rel="noreferrer">${t('here')}</a>`,
),
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export function VerificationManagementList() {
title: '验证时间',
dataIndex: 'proofTime',
valueType: 'dateTime',

width: 170,
},
{
Expand Down
19 changes: 0 additions & 19 deletions src/layout/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<SWRConfig
value={{
Expand All @@ -26,28 +22,13 @@ function InitProvider(p: { children: React.ReactNode }) {
);
}

function InitToolTip() {
return (
<Tooltip
className="z-[999999] break-all shadow-[0_10px_10px_0_rgba(0,0,0,0.3)] border border-[#eee] max-w-[22.5rem]"
style={{ backgroundColor: 'rgb(255, 255, 255,1)', color: '#222' }}
id="tooltip"
opacity={1}
closeOnScroll={true}
closeOnResize={true}
delayHide={100}
/>
);
}

function App(p: { children?: ReactNode }) {
return (
<div suppressHydrationWarning id="__app" className={classNames('App font-OpenSans relative')}>
<InitProvider>
{p.children}
<Toast />
</InitProvider>
<InitToolTip />
</div>
);
}
Expand Down
11 changes: 9 additions & 2 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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;
}

0 comments on commit e16a293

Please sign in to comment.