From 99ee03aeff99b35d4851f33fe92a815104411396 Mon Sep 17 00:00:00 2001 From: Chushen Date: Tue, 20 Jun 2023 16:02:27 +0800 Subject: [PATCH 1/2] feat: update to umijs 4 --- SECURITY.md | 2 +- package.json | 2 +- packages/gi-site/.umirc.ts | 89 ++++++++++++------- packages/gi-site/package.json | 17 ++-- packages/gi-site/scripts/pre-build.mjs | 8 +- .../src/components/DataSource/index.tsx | 2 +- .../gi-site/src/components/Empty/index.tsx | 3 +- .../gi-site/src/components/Navbar/Links.tsx | 2 +- .../src/components/Navbar/SaveWorkbook.tsx | 3 +- .../gi-site/src/components/Navbar/SiteNav.tsx | 3 +- .../gi-site/src/components/Navbar/Theme.tsx | 2 +- .../src/components/Navbar/WorkbookNav.tsx | 3 +- packages/gi-site/src/hooks/useUserInfo.ts | 2 +- packages/gi-site/src/layouts/SideNav.tsx | 12 ++- packages/gi-site/src/layouts/index.tsx | 26 +----- .../src/layouts/{index.less => main.less} | 0 packages/gi-site/src/layouts/main.tsx | 24 +++++ .../src/pages/Analysis/DataServices/index.tsx | 6 +- .../src/pages/Analysis/DataSource/index.tsx | 2 +- packages/gi-site/src/pages/Analysis/index.tsx | 5 +- packages/gi-site/src/pages/Analysis/typing.ts | 2 +- .../src/pages/AssetsList/CartContent.tsx | 3 +- packages/gi-site/src/pages/Dataset/Detail.tsx | 6 +- packages/gi-site/src/pages/Dataset/Table.tsx | 3 +- .../gi-site/src/pages/Tab/TableMode/index.tsx | 2 +- .../gi-site/src/pages/Tab/TableMode/utils.ts | 2 +- packages/gi-site/src/pages/Template/Cards.tsx | 3 +- packages/gi-site/src/pages/Template/Table.tsx | 3 +- .../src/pages/Workspace/Case/index.tsx | 3 +- .../gi-site/src/pages/Workspace/Create.tsx | 3 +- .../gi-site/src/pages/Workspace/Projects.tsx | 3 +- .../gi-site/src/pages/Workspace/SaveList.tsx | 2 - packages/gi-site/src/pages/document.ejs | 43 --------- packages/gi-site/tsconfig.json | 24 +++++ 34 files changed, 159 insertions(+), 156 deletions(-) rename packages/gi-site/src/layouts/{index.less => main.less} (100%) create mode 100644 packages/gi-site/src/layouts/main.tsx delete mode 100644 packages/gi-site/src/pages/document.ejs create mode 100644 packages/gi-site/tsconfig.json diff --git a/SECURITY.md b/SECURITY.md index 0af68e712..cf6635bab 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -13,7 +13,7 @@ currently being supported with security updates. | pnpm | 7.x | | antd | 4.x | | react | 17.x | -| umi | 3.x | +| umi | 4.x | | father | 2.x | | webpack | 5.x | diff --git a/package.json b/package.json index 084f98450..d14d8af15 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "react": "17", "react-dom": "17.x", "stream-browserify": "^3.0.0", - "umi": "3.x" + "@umijs/max": "4.x" }, "devDependencies": { "@changesets/cli": "^2.26.1", diff --git a/packages/gi-site/.umirc.ts b/packages/gi-site/.umirc.ts index 2278cbcce..c97fbb554 100644 --- a/packages/gi-site/.umirc.ts +++ b/packages/gi-site/.umirc.ts @@ -1,6 +1,6 @@ +import { defineConfig } from 'umi'; import GI_SDK from '@antv/gi-sdk/package.json'; import GI_THEME_ANTD from '@antv/gi-theme-antd/package.json'; - import deps_externals from './scripts/deps_externals.json'; export const G6_VERSION = '4.8.14'; export const GRAPHIN_VERSION = '2.7.16'; @@ -26,22 +26,25 @@ export const externalScripts = deps_externals.map(c => { return { src: c.url }; }); console.log('externals', externals, BUILD_MODE); +const BASE_CONFIG = { + links: [ + { + href: 'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*7svFR6wkPMoAAAAAAAAAAAAADmJ7AQ/original', + rel: 'shortcut icon', + }, + ], +}; const EXTRA_CONFIG = isDev ? { externals: { react: 'React', 'react-dom': 'ReactDOM', antd: 'antd', - // '@antv/g6': 'G6', - // '@antv/graphin': 'Graphin', }, scripts: [ - 'https://gw.alipayobjects.com/os/lib/react/17.0.2/umd/react.production.min.js', - 'https://gw.alipayobjects.com/os/lib/react-dom/17.0.2/umd/react-dom.production.min.js', + 'https://gw.alipayobjects.com/os/lib/react/18.2.0/umd/react.production.min.js', + 'https://gw.alipayobjects.com/os/lib/react-dom/18.2.0/umd/react-dom.production.min.js', 'https://gw.alipayobjects.com/os/lib/antd/4.24.8/dist/antd.min.js', - // 'https://gw.alipayobjects.com/os/lib/antv/g6/4.8.8/dist/g6.min.js', - // // 'https://gw.alipayobjects.com/os/lib/antv/graphin/2.7.13/dist/graphin.min.js', - // 'http://localhost:5501/graphin.min.js', ], links: [], } @@ -58,31 +61,48 @@ const EXTRA_CONFIG = isDev }; export default { - // base: '/', base: '/', + title: 'AntV Insight 让数据栩栩如生', + metas: [ + { + name: 'keywords', + content: 'AntV Insight 数据可视化平台 图可视化 地理可视化 分析应用低代码构建', + }, + { + name: 'description', + content: + 'AntV Insight 是蚂蚁集团 AntV 团队推出的一款数据分析产品,用户可以在线完成视觉映射,分析洞察工作,也可以一键导出SDK,二次开发,集成部署', + }, + ], + externals: EXTRA_CONFIG.externals, + scripts: EXTRA_CONFIG.scripts, + links: [...BASE_CONFIG.links, ...EXTRA_CONFIG.links], + styles: ['body {background: var(--background-color); color: var(--text-color)}'], + headScripts: [ + 'https://www.googletagmanager.com/gtag/js?id=G-9Z6Z0NTLFB', + "window.dataLayer = window.dataLayer || [];function gtag() {dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'G-9Z6Z0NTLFB');", + "window.TracertCmdCache = window.TracertCmdCache || [];var t = window.Tracert || {_isRenderInit: !0,call: function () {window.TracertCmdCache.push(arguments);},},f = ['call','start','config','logPv','info','err','click','expo','pageName','pageState','time','timeEnd','parse','checkExpo','stringify','report','set','before'];for (let i = 0; i < f.length; i++) {(function (fn) {t[fn] = function () {var a = [],l = arguments.length;for (var j = 0; j < l; j++) {a.push(arguments[j]);}a.unshift(fn);window.TracertCmdCache.push(a);};})(f[i]);}window.Tracert = t;window._to = window._to || {};function filterLog(logType) {return function (opts) {return !!window.GI_USER_INFO?.outUserNo;};}window.Tracert.call('before', 'logPv', filterLog('PageMonitor'));window.Tracert.call('before', 'expo', filterLog('expo'));window.Tracert.call('before', 'click', filterLog('click'));", + 'https://ur.alipay.com/tracert_a3220.js', + ], publicPath: BUILD_MODE === 'docker' ? '/public/' : '/', hash: true, - favicon: 'https://gw.alipayobjects.com/zos/bmw-prod/b9a0f537-3768-445d-aa39-ff49de82124a.svg', + favicons: ['https://gw.alipayobjects.com/zos/bmw-prod/b9a0f537-3768-445d-aa39-ff49de82124a.svg'], history: { - type: 'hash', + type: 'browser', }, alias: { '@': './src', - }, - nodeModulesTransform: { - type: 'none', + // '@antv/gi-sdk': '../gi-sdk/src', }, routes: [ - { exact: true, path: '/', redirect: '/home' }, + { exact: true, path: '', redirect: '/home' }, { exact: true, path: '/workspace/:projectId', component: 'Analysis' }, { exact: true, path: '/share/:shareId', component: 'Share' }, { exact: true, path: '/tabs/:type', component: 'Tab' }, { path: '/', - component: '@/layouts/index', + component: '@/layouts/Main', routes: [ - { exact: true, path: '/workspace', component: 'Workspace' }, - { exact: true, path: '/services', component: 'ServerCenter' }, { exact: true, path: '/home', component: 'Home' }, { path: '/dataset', @@ -182,25 +202,34 @@ export default { }, ], }, - { component: '404' }, + { exact: true, path: '/services', component: 'ServerCenter' }, + { exact: true, path: '/workspace', component: 'Workspace' }, ], }, + { component: '404' }, ], - ...EXTRA_CONFIG, + request: { dataField: '', }, - // ...EXTRA_CONFIG, - analyze: { - analyzerMode: 'server', - analyzerPort: 8888, - openAnalyzer: true, - // generate stats file while ANALYZE_DUMP exist - generateStatsFile: false, - statsFilename: 'stats.json', - logLevel: 'info', - defaultSizes: 'parsed', // stat // gzip + fastRefresh: true, + mfsu: { + // exclude: ['@antv/*', '@alipay/*'], + // strategy: 'eager', }, + // monorepoRedirect: { + // srcDir: ['src'], + // }, + // analyze: { + // analyzerMode: 'server', + // analyzerPort: 8888, + // openAnalyzer: true, + // // generate stats file while ANALYZE_DUMP exist + // generateStatsFile: false, + // statsFilename: 'stats.json', + // logLevel: 'info', + // defaultSizes: 'parsed', // stat // gzip + // }, chainWebpack(memo, { type }) { memo.module .rule('mjs$') diff --git a/packages/gi-site/package.json b/packages/gi-site/package.json index abc8c561f..f8ddb5b37 100644 --- a/packages/gi-site/package.json +++ b/packages/gi-site/package.json @@ -10,15 +10,14 @@ ], "main": "dist/app.js", "scripts": { - "analyse": "ANALYZE=1 NODE_OPTIONS=--max_old_space_size=4096 umi build", - "build": "node --experimental-json-modules scripts/pre-build.mjs && NODE_OPTIONS=--max_old_space_size=4096 umi build", - "build:docker": "node scripts/link.mjs && cd ../../ && npm run build:all:umd && cd packages/gi-site/ && BUILD_MODE=docker node scripts/pre-build.mjs && node scripts/copy-assets.mjs && BUILD_MODE=docker NODE_OPTIONS=--max_old_space_size=4096 umi build", + "analyse": "ANALYZE=1 NODE_OPTIONS=--max_old_space_size=4096 max build", + "build": "node --experimental-json-modules scripts/pre-build.mjs && NODE_OPTIONS=--max_old_space_size=4096 max build", + "build:docker": "node scripts/link.mjs && cd ../../ && npm run build:all:umd && cd packages/gi-site/ && BUILD_MODE=docker node scripts/pre-build.mjs && node scripts/copy-assets.mjs && BUILD_MODE=docker NODE_OPTIONS=--max_old_space_size=4096 max build", "deploy": "node ./scripts/deploy.js", - "start": "node --experimental-json-modules scripts/link.mjs && node scripts/pre-build.mjs && cross-env NODE_OPTIONS=--max_old_space_size=4096 cross-env PORT=8000 umi dev", + "start": "node --experimental-json-modules scripts/link.mjs && node scripts/pre-build.mjs && cross-env NODE_OPTIONS=--max_old_space_size=4096 cross-env PORT=8000 max dev", "link": "node scripts/link.mjs", "unlink": "cross-env UNLINK=true node scripts/link.mjs", "eject": "cross-env EJECT=true node scripts/link.mjs" - }, "dependencies": { "@ant-design/charts": "^1.0.21", @@ -41,12 +40,14 @@ "@antv/gi-common-components": "workspace:*", "@antv/gi-sdk": "workspace:*", "@antv/gi-theme-antd": "workspace:*", + "@antv/s2-react": "^1.41.0", + "@antv/s2": "^1.48.0", + "@antv/util": "^3.3.2", "@faker-js/faker": "latest", "@fast-csv/format": "latest", "@types/classnames": "^2.2.9", "@types/node": "^7.0.12", "@types/systemjs": "latest", - "@umijs/preset-react": "^1.8.12", "ahooks": "^2.10.9", "classnames": "^2.2.6", "d3-scale": "^4.0.0", @@ -62,10 +63,10 @@ "node-fetch": "^3.3.0", "react-color": "^2.19.3", "react-monaco-editor": "^0.48.0", - "react-router-dom": "^5.1.1", "swr": "^1.2.2", "systemjs": "^6.11.0", - "umi": "^3.5.18", + "@umijs/max": "^4.0.0", + "umi": "^4.0.0", "umi-request": "^1.3.9", "use-immer": "^0.7.0", "xlsx2js": "^1.3.8" diff --git a/packages/gi-site/scripts/pre-build.mjs b/packages/gi-site/scripts/pre-build.mjs index 8bde73702..4493a9570 100644 --- a/packages/gi-site/scripts/pre-build.mjs +++ b/packages/gi-site/scripts/pre-build.mjs @@ -43,15 +43,15 @@ const depsPackage = [ name: 'localforage', }, { - url: 'https://gw.alipayobjects.com/os/lib/react/17.0.2/umd/react.production.min.js', - version: '17.0.2', + url: 'https://gw.alipayobjects.com/os/lib/react/18.2.0/umd/react.production.min.js', + version: '18.2.0', global: 'React', name: 'react', }, { - url: 'https://gw.alipayobjects.com/os/lib/react-dom/17.0.2/umd/react-dom.production.min.js', + url: 'https://gw.alipayobjects.com/os/lib/react-dom/18.2.0/umd/react-dom.production.min.js', name: 'react-dom', - version: '17.0.2', + version: '18.2.0', global: 'ReactDOM', }, { diff --git a/packages/gi-site/src/components/DataSource/index.tsx b/packages/gi-site/src/components/DataSource/index.tsx index 7607333c3..fa63c385b 100644 --- a/packages/gi-site/src/components/DataSource/index.tsx +++ b/packages/gi-site/src/components/DataSource/index.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { useImmer } from 'use-immer'; -import { getSearchParams } from '../../components/utils'; +import { getSearchParams } from '../utils'; import Detail from './Detail'; import './index.less'; import SideList from './List'; diff --git a/packages/gi-site/src/components/Empty/index.tsx b/packages/gi-site/src/components/Empty/index.tsx index 57196551e..1a2bccd81 100644 --- a/packages/gi-site/src/components/Empty/index.tsx +++ b/packages/gi-site/src/components/Empty/index.tsx @@ -1,6 +1,6 @@ import { Button, Empty } from 'antd'; import * as React from 'react'; -import { useHistory } from 'react-router-dom'; +import { history } from 'umi'; interface EmptyDemoProps { url: string; title: string; @@ -8,7 +8,6 @@ interface EmptyDemoProps { const EmptyDemo: React.FunctionComponent = props => { const { url, title } = props; - const history = useHistory(); return ( { const SaveWorkbook: React.FunctionComponent = props => { const { workbookId } = props; - const history = useHistory(); const { context, updateContext } = useContext(); const { config, activeAssetsKeys, name, graphRef } = context; const handleSave = async () => { diff --git a/packages/gi-site/src/components/Navbar/SiteNav.tsx b/packages/gi-site/src/components/Navbar/SiteNav.tsx index 039dba274..cbbed656e 100644 --- a/packages/gi-site/src/components/Navbar/SiteNav.tsx +++ b/packages/gi-site/src/components/Navbar/SiteNav.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { useHistory } from 'react-router-dom'; +import { history } from 'umi'; import DataModeCard from '../DataModeCard'; import Github from './Github'; import Links from './Links'; @@ -28,7 +28,6 @@ const styles = { const SiteNav: React.FunctionComponent = props => { const { active } = props; - const history = useHistory(); return (
diff --git a/packages/gi-site/src/components/Navbar/Theme.tsx b/packages/gi-site/src/components/Navbar/Theme.tsx index 210b05783..209522649 100644 --- a/packages/gi-site/src/components/Navbar/Theme.tsx +++ b/packages/gi-site/src/components/Navbar/Theme.tsx @@ -5,7 +5,7 @@ import ThemeVars from '../ThemeVars'; import './index.less'; interface ThemeProps { - changeTheme: (val: string) => void; + changeTheme?: (val: string) => void; } const options = [ { diff --git a/packages/gi-site/src/components/Navbar/WorkbookNav.tsx b/packages/gi-site/src/components/Navbar/WorkbookNav.tsx index 04c9fd874..44bae5575 100644 --- a/packages/gi-site/src/components/Navbar/WorkbookNav.tsx +++ b/packages/gi-site/src/components/Navbar/WorkbookNav.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { useHistory } from 'react-router-dom'; +import { history } from 'umi'; import { useContext } from '../../pages/Analysis/hooks/useContext'; import ProjectTitle from '../ProjectTitle'; import useTheme from '../ThemeVars/useTheme'; @@ -38,7 +38,6 @@ const WorkbookBar: React.FunctionComponent = props => { const { workbookId } = props; const { context, updateContext } = useContext(); const { changeTheme } = useTheme(context, updateContext); - const history = useHistory(); const { name } = context; return ( diff --git a/packages/gi-site/src/hooks/useUserInfo.ts b/packages/gi-site/src/hooks/useUserInfo.ts index 2a9f95ae1..1aa17672a 100644 --- a/packages/gi-site/src/hooks/useUserInfo.ts +++ b/packages/gi-site/src/hooks/useUserInfo.ts @@ -23,7 +23,7 @@ export const getLoginUserInfo = async () => { const VIP_ASSETS = await fetch('https://unpkg.alipay.com/@alipay/gi-assets-vip@latest/json/assets.json').then( res => res.json(), ); - setAssetPackages(VIP_ASSETS); //暂时移除从user中获取资产信息 + // setAssetPackages(VIP_ASSETS); //暂时移除从user中获取资产信息 //@ts-ignore window.GI_USER_INFO = result; return result; diff --git a/packages/gi-site/src/layouts/SideNav.tsx b/packages/gi-site/src/layouts/SideNav.tsx index 2755a3d33..1c727a72a 100644 --- a/packages/gi-site/src/layouts/SideNav.tsx +++ b/packages/gi-site/src/layouts/SideNav.tsx @@ -1,3 +1,4 @@ +import { history, useLocation } from 'umi'; import { AppstoreOutlined, DeleteOutlined, @@ -11,7 +12,7 @@ import { import { Menu, MenuProps } from 'antd'; import * as React from 'react'; -import './index.less'; +import { Outlet } from 'umi'; interface ILayoutProps {} const DATASET_ITEMS = [ @@ -70,8 +71,7 @@ const getItems = location => { }; const SideNav: React.FunctionComponent = props => { - //@ts-ignore - const { children, location, history } = props; + const location = useLocation(); const [state, setState] = React.useState({ active: location.pathname.split('/').splice(0, 3).join('/'), }); @@ -81,25 +81,23 @@ const SideNav: React.FunctionComponent = props => { history.push(e.key); }; - const { items, name } = getItems(location); + const { items } = getItems(location); const { active } = state; return (
- {/*

{name}

*/}
- {children} +
); diff --git a/packages/gi-site/src/layouts/index.tsx b/packages/gi-site/src/layouts/index.tsx index 3da98ea84..ddeef96e3 100644 --- a/packages/gi-site/src/layouts/index.tsx +++ b/packages/gi-site/src/layouts/index.tsx @@ -1,32 +1,14 @@ import * as React from 'react'; -import Navbar from '../components/Navbar/SiteNav'; +import { Outlet } from 'umi'; import { BUILD_MODE } from '../env'; -import useInitial from '../hooks/useInitial'; -import useUpdate from '../hooks/useUpdate'; -import './index.less'; + /** 挂载在浏览器全局下面,方便其他资产包需要 */ window['GI_PUBLIC_PATH'] = BUILD_MODE === 'docker' ? '/public/' : '/'; interface ILayoutProps {} -const Layout: React.FunctionComponent = props => { - //@ts-ignore - const { children, location } = props; - const active = location.pathname.split('/')[1]; - React.useEffect(() => { - useUpdate(); - useInitial(); - }, []); - - return ( - <> -
- - {/* */} -
{children}
-
- - ); +const Layout: React.FunctionComponent = () => { + return ; }; export default Layout; diff --git a/packages/gi-site/src/layouts/index.less b/packages/gi-site/src/layouts/main.less similarity index 100% rename from packages/gi-site/src/layouts/index.less rename to packages/gi-site/src/layouts/main.less diff --git a/packages/gi-site/src/layouts/main.tsx b/packages/gi-site/src/layouts/main.tsx new file mode 100644 index 000000000..01f1241f8 --- /dev/null +++ b/packages/gi-site/src/layouts/main.tsx @@ -0,0 +1,24 @@ +import * as React from 'react'; +import { Outlet, useLocation } from 'umi'; +import Navbar from '../components/Navbar/SiteNav'; +import useInitial from '../hooks/useInitial'; +import useUpdate from '../hooks/useUpdate'; +import './main.less'; + +export default () => { + const location = useLocation(); + const active = location.pathname.split('/')[1]; + React.useEffect(() => { + useUpdate(); + useInitial(); + }, []); + + return ( +
+ +
+ +
+
+ ); +}; diff --git a/packages/gi-site/src/pages/Analysis/DataServices/index.tsx b/packages/gi-site/src/pages/Analysis/DataServices/index.tsx index 7b6d83359..92e9c529c 100644 --- a/packages/gi-site/src/pages/Analysis/DataServices/index.tsx +++ b/packages/gi-site/src/pages/Analysis/DataServices/index.tsx @@ -3,14 +3,14 @@ import { produce } from 'immer'; import * as React from 'react'; import { useImmer } from 'use-immer'; import DataSource from '../../../components/DataSource/index'; +import { useMatch } from 'umi'; import BaseNavbar from '../../../components/Navbar/BaseNavbar'; import { getSearchParams } from '../../../components/utils'; import * as ProjectServices from '../../../services/project'; interface DataServicesProps {} const DataServices: React.FunctionComponent = props => { - //@ts-ignore - const { match } = props; + const match = useMatch({ path: '/workspace/:projectId' })!; const { projectId } = match.params; const { searchParams } = getSearchParams(window.location); @@ -22,7 +22,7 @@ const DataServices: React.FunctionComponent = props => { }); React.useEffect(() => { - ProjectServices.getById(projectId).then((res: any) => { + ProjectServices.getById(projectId!).then((res: any) => { const { data, serviceConfig } = res; updateState(draft => { diff --git a/packages/gi-site/src/pages/Analysis/DataSource/index.tsx b/packages/gi-site/src/pages/Analysis/DataSource/index.tsx index 616ecd2d7..9b3a9c0c7 100644 --- a/packages/gi-site/src/pages/Analysis/DataSource/index.tsx +++ b/packages/gi-site/src/pages/Analysis/DataSource/index.tsx @@ -2,7 +2,7 @@ import { Icon, utils } from '@antv/gi-sdk'; import { Drawer, Tabs } from 'antd'; import * as React from 'react'; import FileServerEngine from '../../../components/FileServerEngine'; -import { useContext } from '../../Analysis/hooks/useContext'; +import { useContext } from '../hooks/useContext'; interface uploadPanel { visible: boolean; diff --git a/packages/gi-site/src/pages/Analysis/index.tsx b/packages/gi-site/src/pages/Analysis/index.tsx index c188f1a6a..2d39a1a3f 100644 --- a/packages/gi-site/src/pages/Analysis/index.tsx +++ b/packages/gi-site/src/pages/Analysis/index.tsx @@ -1,4 +1,5 @@ import GISDK, { useContext as useGIContext, utils } from '@antv/gi-sdk'; +import { useMatch } from 'umi'; import { message } from 'antd'; import { original } from 'immer'; import React, { useRef, useState } from 'react'; @@ -27,8 +28,8 @@ const GraphRef = props => { return null; }; const Analysis = props => { - const { match } = props; - const { projectId } = match.params; + const match = useMatch({ path: '/workspace/:projectId' })!; + const projectId = match.params.projectId!; const graphRef = useRef(null); const [state, updateState] = useModel(); diff --git a/packages/gi-site/src/pages/Analysis/typing.ts b/packages/gi-site/src/pages/Analysis/typing.ts index 8228a6679..b82059455 100644 --- a/packages/gi-site/src/pages/Analysis/typing.ts +++ b/packages/gi-site/src/pages/Analysis/typing.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import type { GIAssets, GIConfig, GIService } from '@antv/gi-sdk/src/typing'; +import type { GIAssets, GIConfig, GIService } from '@antv/gi-sdk'; import { GraphinData } from '@antv/graphin'; export interface IActiveAssetsKeys { components: string[]; diff --git a/packages/gi-site/src/pages/AssetsList/CartContent.tsx b/packages/gi-site/src/pages/AssetsList/CartContent.tsx index 05413be6f..420b7c385 100644 --- a/packages/gi-site/src/pages/AssetsList/CartContent.tsx +++ b/packages/gi-site/src/pages/AssetsList/CartContent.tsx @@ -1,7 +1,7 @@ import { AssetInfo, GIComponentAssets, Icon, template as TEMPLATE, utils } from '@antv/gi-sdk'; import { Button, Divider, Drawer, Form, Input, Tag, notification } from 'antd'; import * as React from 'react'; -import { useHistory } from 'react-router-dom'; +import { history } from 'umi'; import { queryAssets } from '../../services/assets'; import * as TemplateServices from '../../services/template'; import getComponentsByAssets from '../Analysis/getAssets/getComponentsByAssets'; @@ -16,7 +16,6 @@ interface CartContentProps { const CartContent: React.FunctionComponent = props => { const { visible, setVisible } = props; const [form] = Form.useForm(); - const history = useHistory(); const res = JSON.parse(localStorage.getItem('GI_CART_LIST') || '{}'); const list = Object.values(res).filter((c: any) => c.checked) as AssetInfo[]; const keys = list.map(item => item.id); diff --git a/packages/gi-site/src/pages/Dataset/Detail.tsx b/packages/gi-site/src/pages/Dataset/Detail.tsx index 42ff8b02a..d29398cd9 100644 --- a/packages/gi-site/src/pages/Dataset/Detail.tsx +++ b/packages/gi-site/src/pages/Dataset/Detail.tsx @@ -1,5 +1,6 @@ import { ApartmentOutlined, BarsOutlined } from '@ant-design/icons'; import { utils } from '@antv/gi-sdk'; +import { useMatch } from 'umi'; import Graphin, { GraphinData } from '@antv/graphin'; import { Breadcrumb } from 'antd'; import * as React from 'react'; @@ -9,8 +10,7 @@ import { IDataset } from '../../services/typing'; interface DetailProps {} const Detail: React.FunctionComponent = props => { - //@ts-ignore - const { match } = props; + const match = useMatch({ path: '/dataset/list/:id' })!; const { id } = match.params; const [state, setState] = React.useState<{ dataset: Partial; schemaGraph: GraphinData }>({ dataset: {}, @@ -20,7 +20,7 @@ const Detail: React.FunctionComponent = props => { React.useEffect(() => { (async () => { - const info = (await DatasetServices.queryDatasetInfo(id)) as IDataset; + const info = (await DatasetServices.queryDatasetInfo(id!)) as IDataset; const schemaGraph = utils.getSchemaGraph(info.schemaData, { nodes: [], edges: [] }); setState(preState => { diff --git a/packages/gi-site/src/pages/Dataset/Table.tsx b/packages/gi-site/src/pages/Dataset/Table.tsx index 6763916d9..5bfef5265 100644 --- a/packages/gi-site/src/pages/Dataset/Table.tsx +++ b/packages/gi-site/src/pages/Dataset/Table.tsx @@ -11,7 +11,7 @@ import { import { utils } from '@antv/gi-sdk'; import { Button, Input, Table, Tag, Tooltip } from 'antd'; import * as React from 'react'; -import { useHistory } from 'react-router-dom'; +import { history } from 'umi'; import { recoverDataset, recycleDataset, updateDataset } from '../../services/dataset'; import { isNil } from '@antv/util'; // import { getUid } from '../Workspace/utils'; @@ -42,7 +42,6 @@ export const TYPE_MAPPING = { }, }; const DatasetTable = ({ data, queryData, recoverable = false, deletable = true }) => { - const history = useHistory(); // const handleEncode = record => { // console.log(record); diff --git a/packages/gi-site/src/pages/Tab/TableMode/index.tsx b/packages/gi-site/src/pages/Tab/TableMode/index.tsx index e6ab73290..5eb035dbf 100644 --- a/packages/gi-site/src/pages/Tab/TableMode/index.tsx +++ b/packages/gi-site/src/pages/Tab/TableMode/index.tsx @@ -5,7 +5,7 @@ import '@antv/s2-react/dist/style.min.css'; import { Alert, Tabs } from 'antd'; import React, { useState } from 'react'; import getData from './utils'; -import { IGraphData } from '@antv/gi-sdk/src/process/schema'; +import { IGraphData } from '@antv/gi-sdk'; const { TabPane } = Tabs; interface TableModeProps {} diff --git a/packages/gi-site/src/pages/Tab/TableMode/utils.ts b/packages/gi-site/src/pages/Tab/TableMode/utils.ts index 5a45b15ca..89b17ef57 100644 --- a/packages/gi-site/src/pages/Tab/TableMode/utils.ts +++ b/packages/gi-site/src/pages/Tab/TableMode/utils.ts @@ -1,4 +1,4 @@ -import { IGraphData } from '@antv/gi-sdk/src/process/schema'; +import { IGraphData } from '@antv/gi-sdk'; import { GraphinData } from '@antv/graphin'; const getData = ( diff --git a/packages/gi-site/src/pages/Template/Cards.tsx b/packages/gi-site/src/pages/Template/Cards.tsx index 506141bde..c3bc4fd1b 100644 --- a/packages/gi-site/src/pages/Template/Cards.tsx +++ b/packages/gi-site/src/pages/Template/Cards.tsx @@ -1,7 +1,7 @@ import { DeleteOutlined, EllipsisOutlined, ExportOutlined } from '@ant-design/icons'; import { Card, Col, Dropdown, Row, Typography } from 'antd'; import * as React from 'react'; -import { useHistory } from 'react-router-dom'; +import { history } from 'umi'; import { deleteDataset } from '../../services/dataset'; import { ITemplate } from '../../services/typing'; @@ -14,7 +14,6 @@ interface ICardsProps { const Cards: React.FunctionComponent = props => { const { data } = props; - const history = useHistory(); const handleClick = id => { history.push(`/workbook/template/${id}`); }; diff --git a/packages/gi-site/src/pages/Template/Table.tsx b/packages/gi-site/src/pages/Template/Table.tsx index 505a43826..21adcf469 100644 --- a/packages/gi-site/src/pages/Template/Table.tsx +++ b/packages/gi-site/src/pages/Template/Table.tsx @@ -1,10 +1,9 @@ import { Button, Space, Table } from 'antd'; import * as React from 'react'; -import { useHistory } from 'react-router-dom'; +import { history } from 'umi'; import { deleteDataset } from '../../services/dataset'; // import { getUid } from '../Workspace/utils'; const DatasetTable = ({ data }) => { - const history = useHistory(); const handleDelete = async record => { await deleteDataset(record.id); diff --git a/packages/gi-site/src/pages/Workspace/Case/index.tsx b/packages/gi-site/src/pages/Workspace/Case/index.tsx index f091197d1..b98507895 100644 --- a/packages/gi-site/src/pages/Workspace/Case/index.tsx +++ b/packages/gi-site/src/pages/Workspace/Case/index.tsx @@ -1,7 +1,7 @@ import { VideoCameraOutlined } from '@ant-design/icons'; import { Card, Col, Row, Skeleton, Tag } from 'antd'; import * as React from 'react'; -import { useHistory } from 'react-router-dom'; +import { history } from 'umi'; import { useImmer } from 'use-immer'; import { queryCaseList } from '../../../services/case'; import { IProject } from '../../../services/typing'; @@ -9,7 +9,6 @@ import './index.less'; interface CaseProps {} const Case: React.FunctionComponent = props => { - const history = useHistory(); const [state, updateState] = useImmer({ lists: [] as IProject[], visible: false, diff --git a/packages/gi-site/src/pages/Workspace/Create.tsx b/packages/gi-site/src/pages/Workspace/Create.tsx index 578407bc3..0758b35c8 100644 --- a/packages/gi-site/src/pages/Workspace/Create.tsx +++ b/packages/gi-site/src/pages/Workspace/Create.tsx @@ -1,7 +1,7 @@ import { EditableProTable } from '@ant-design/pro-table'; import { Alert, Button, Form, Input, Modal, Radio, Tabs } from 'antd'; import React, { useState } from 'react'; -import { useHistory } from 'react-router-dom'; +import { history } from 'umi'; import * as ProjectServices from '../../services/project'; import './index.less'; @@ -66,7 +66,6 @@ const SOLUTIONS = [ const GI_ENV = localStorage.getItem('GI_SERVER_ENV'); const CreatePanel: React.FC = ({ visible, handleClose }) => { const [form] = Form.useForm(); - const history = useHistory(); const defaultData = [ { name: 'test', diff --git a/packages/gi-site/src/pages/Workspace/Projects.tsx b/packages/gi-site/src/pages/Workspace/Projects.tsx index 3d3a53067..cc19d0f15 100644 --- a/packages/gi-site/src/pages/Workspace/Projects.tsx +++ b/packages/gi-site/src/pages/Workspace/Projects.tsx @@ -3,7 +3,7 @@ import { utils } from '@antv/gi-sdk'; import { isNil } from '@antv/util'; import { Button, Card, Col, Input, Menu, Popconfirm, Row, Skeleton, Tooltip } from 'antd'; import * as React from 'react'; -import { useHistory } from 'react-router-dom'; +import { history } from 'umi'; import { useImmer } from 'use-immer'; import Empty from '../../components/Empty'; import * as ProjectService from '../../services/project'; @@ -30,7 +30,6 @@ interface ProjectListState { const ProjectList: React.FunctionComponent = props => { const { type, onCreate } = props; - const history = useHistory(); const [state, updateState] = useImmer({ lists: [], isLoading: true, diff --git a/packages/gi-site/src/pages/Workspace/SaveList.tsx b/packages/gi-site/src/pages/Workspace/SaveList.tsx index 53c189d3c..e21a289ff 100644 --- a/packages/gi-site/src/pages/Workspace/SaveList.tsx +++ b/packages/gi-site/src/pages/Workspace/SaveList.tsx @@ -2,7 +2,6 @@ import { EllipsisOutlined } from '@ant-design/icons'; import { utils } from '@antv/gi-sdk'; import { Button, Col, Dropdown, Empty, Menu, message, Popconfirm, Row, Typography } from 'antd'; import * as React from 'react'; -import { useHistory } from 'react-router-dom'; import { useImmer } from 'use-immer'; import ProjectCard from '../../components/ProjectCard'; import { GI_SITE } from '../../services/const'; @@ -22,7 +21,6 @@ interface SaveListProps { const SaveList: React.FunctionComponent = props => { const { type } = props; - const history = useHistory(); const [state, updateState] = useImmer({ lists: [], visible: false, diff --git a/packages/gi-site/src/pages/document.ejs b/packages/gi-site/src/pages/document.ejs deleted file mode 100644 index 377fd1a9d..000000000 --- a/packages/gi-site/src/pages/document.ejs +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - AntV Insight 让数据栩栩如生 - - - - - - - - - - - - - -
- - - \ No newline at end of file diff --git a/packages/gi-site/tsconfig.json b/packages/gi-site/tsconfig.json new file mode 100644 index 000000000..8942365d7 --- /dev/null +++ b/packages/gi-site/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "allowJs": true, + "declaration": true, + "target": "ES2016", + "moduleResolution": "node", + "jsx": "react", + "resolveJsonModule": true, + "strict": true, + "noImplicitAny": false, + "lib": ["dom", "esnext"], + "module": "esnext", + "esModuleInterop": true, + "skipLibCheck": true, + "isolatedModules": false, + "rootDir": ".", + "baseUrl": ".", + "paths": { + "@@/*": ["src/.umi/*"] + } + }, + "include": ["src"] +} From 7187475125a0e04703fc5954cfa6fec0360f91a7 Mon Sep 17 00:00:00 2001 From: Chushen Date: Wed, 21 Jun 2023 09:34:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E5=85=B3=E9=97=ADmfsu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .npmrc | 3 ++- .../AnalysisHistory/TemplateModal.tsx | 11 +++++------ .../src/components/LayoutSwitch/Component.tsx | 2 +- packages/gi-sdk/src/GISDK.tsx | 3 +-- packages/gi-sdk/src/index.tsx | 1 + packages/gi-sdk/src/process/index.ts | 1 + packages/gi-site/.umirc.ts | 18 ++++++------------ packages/gi-site/package.json | 6 +++--- packages/gi-site/scripts/pre-build.mjs | 12 ------------ .../src/components/Navbar/ExportSdk.tsx | 4 ++-- 10 files changed, 22 insertions(+), 39 deletions(-) diff --git a/.npmrc b/.npmrc index e21cbf73e..16d202260 100644 --- a/.npmrc +++ b/.npmrc @@ -2,4 +2,5 @@ registry=https://registry.npmmirror.com # pnpm auto-install-peers=true -git-checks=false \ No newline at end of file +git-checks=false +# public-hoist-pattern[]=* \ No newline at end of file diff --git a/packages/gi-assets-advance/src/components/AnalysisHistory/TemplateModal.tsx b/packages/gi-assets-advance/src/components/AnalysisHistory/TemplateModal.tsx index 55e83e04e..46f73fab7 100644 --- a/packages/gi-assets-advance/src/components/AnalysisHistory/TemplateModal.tsx +++ b/packages/gi-assets-advance/src/components/AnalysisHistory/TemplateModal.tsx @@ -1,5 +1,4 @@ -import { useContext } from '@antv/gi-sdk'; -import { createUuid } from '@antv/gi-sdk/lib/process/common'; +import { useContext, utils } from '@antv/gi-sdk'; import * as React from 'react'; import { useImmer } from 'use-immer'; import { CheckCircleFilled, PictureOutlined } from '@ant-design/icons'; @@ -87,8 +86,8 @@ const TemplateModal: React.FC = props => { updateState(draft => { draft.configuring = undefined; draft.graphData = { - id: createUuid(), - name: createUuid(), + id: utils.createUuid(), + name: utils.createUuid(), nodes, edges: [ { @@ -123,8 +122,8 @@ const TemplateModal: React.FC = props => { updateState(draft => { draft.configuring = undefined; draft.graphData = { - id: createUuid(), - name: createUuid(), + id: utils.createUuid(), + name: utils.createUuid(), nodes, edges, }; diff --git a/packages/gi-assets-basic/src/components/LayoutSwitch/Component.tsx b/packages/gi-assets-basic/src/components/LayoutSwitch/Component.tsx index 58bd107a7..f3481d012 100644 --- a/packages/gi-assets-basic/src/components/LayoutSwitch/Component.tsx +++ b/packages/gi-assets-basic/src/components/LayoutSwitch/Component.tsx @@ -1,6 +1,6 @@ import type { GILayoutConfig, IGIAC } from '@antv/gi-sdk'; import { Icon, extra, useContext, utils } from '@antv/gi-sdk'; -import { LayoutConfig } from '@antv/gi-sdk/lib/typing'; +import type { LayoutConfig } from '@antv/gi-sdk'; import { Card, Popover, Radio, Space } from 'antd'; import React, { useEffect, useMemo } from 'react'; diff --git a/packages/gi-sdk/src/GISDK.tsx b/packages/gi-sdk/src/GISDK.tsx index 413f7087b..afdc61fb9 100644 --- a/packages/gi-sdk/src/GISDK.tsx +++ b/packages/gi-sdk/src/GISDK.tsx @@ -9,7 +9,6 @@ import { GraphInsightContext } from './context'; import getComponents from './hooks/useComponents'; import './index.less'; import * as utils from './process'; -import { createUuid } from './process/common'; import { registerLayouts, registerShapes } from './register'; import type { GIComponentConfig, GIGraphData, Props, State } from './typing'; @@ -337,7 +336,7 @@ const GISDK = (props: Props) => { // @ts-ignore draft.history = (draft.history || []).concat([ { - id: createUuid(), + id: utils.createUuid(), timestamp: time, ...param, }, diff --git a/packages/gi-sdk/src/index.tsx b/packages/gi-sdk/src/index.tsx index beb345ec1..576b32212 100644 --- a/packages/gi-sdk/src/index.tsx +++ b/packages/gi-sdk/src/index.tsx @@ -58,6 +58,7 @@ export type { GraphSchemaData, ISourceDataMap, ServiceObject, + LayoutConfig, } from './typing'; export { extra, template, useContext, utils, version }; diff --git a/packages/gi-sdk/src/process/index.ts b/packages/gi-sdk/src/process/index.ts index 98021d187..69c369b0b 100644 --- a/packages/gi-sdk/src/process/index.ts +++ b/packages/gi-sdk/src/process/index.ts @@ -13,6 +13,7 @@ export { mergeObjectByRule, time, uniqueElementsBy, + createUuid, } from './common'; export { filterByRules } from './filterByRules'; export { findAllPath, getNeighbors } from './findAllPath'; diff --git a/packages/gi-site/.umirc.ts b/packages/gi-site/.umirc.ts index c97fbb554..da3262325 100644 --- a/packages/gi-site/.umirc.ts +++ b/packages/gi-site/.umirc.ts @@ -41,11 +41,7 @@ const EXTRA_CONFIG = isDev 'react-dom': 'ReactDOM', antd: 'antd', }, - scripts: [ - 'https://gw.alipayobjects.com/os/lib/react/18.2.0/umd/react.production.min.js', - 'https://gw.alipayobjects.com/os/lib/react-dom/18.2.0/umd/react-dom.production.min.js', - 'https://gw.alipayobjects.com/os/lib/antd/4.24.8/dist/antd.min.js', - ], + scripts: ['https://gw.alipayobjects.com/os/lib/antd/4.24.8/dist/antd.min.js'], links: [], } : { @@ -83,6 +79,8 @@ export default { "window.dataLayer = window.dataLayer || [];function gtag() {dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'G-9Z6Z0NTLFB');", "window.TracertCmdCache = window.TracertCmdCache || [];var t = window.Tracert || {_isRenderInit: !0,call: function () {window.TracertCmdCache.push(arguments);},},f = ['call','start','config','logPv','info','err','click','expo','pageName','pageState','time','timeEnd','parse','checkExpo','stringify','report','set','before'];for (let i = 0; i < f.length; i++) {(function (fn) {t[fn] = function () {var a = [],l = arguments.length;for (var j = 0; j < l; j++) {a.push(arguments[j]);}a.unshift(fn);window.TracertCmdCache.push(a);};})(f[i]);}window.Tracert = t;window._to = window._to || {};function filterLog(logType) {return function (opts) {return !!window.GI_USER_INFO?.outUserNo;};}window.Tracert.call('before', 'logPv', filterLog('PageMonitor'));window.Tracert.call('before', 'expo', filterLog('expo'));window.Tracert.call('before', 'click', filterLog('click'));", 'https://ur.alipay.com/tracert_a3220.js', + 'https://gw.alipayobjects.com/os/lib/react/18.2.0/umd/react.production.min.js', + 'https://gw.alipayobjects.com/os/lib/react-dom/18.2.0/umd/react-dom.production.min.js', ], publicPath: BUILD_MODE === 'docker' ? '/public/' : '/', hash: true, @@ -92,7 +90,6 @@ export default { }, alias: { '@': './src', - // '@antv/gi-sdk': '../gi-sdk/src', }, routes: [ { exact: true, path: '', redirect: '/home' }, @@ -212,13 +209,10 @@ export default { request: { dataField: '', }, - fastRefresh: true, - mfsu: { - // exclude: ['@antv/*', '@alipay/*'], - // strategy: 'eager', - }, + mfsu: false, // monorepoRedirect: { - // srcDir: ['src'], + // srcDir: ['.', 'src'], + // exclude: [/^(?!@alipay|@antv).*/], // }, // analyze: { // analyzerMode: 'server', diff --git a/packages/gi-site/package.json b/packages/gi-site/package.json index f8ddb5b37..104b935c3 100644 --- a/packages/gi-site/package.json +++ b/packages/gi-site/package.json @@ -48,6 +48,7 @@ "@types/classnames": "^2.2.9", "@types/node": "^7.0.12", "@types/systemjs": "latest", + "@umijs/max": "^4.0.0", "ahooks": "^2.10.9", "classnames": "^2.2.6", "d3-scale": "^4.0.0", @@ -65,7 +66,6 @@ "react-monaco-editor": "^0.48.0", "swr": "^1.2.2", "systemjs": "^6.11.0", - "@umijs/max": "^4.0.0", "umi": "^4.0.0", "umi-request": "^1.3.9", "use-immer": "^0.7.0", @@ -80,8 +80,8 @@ "peerDependencies": { "@antv/graphin": "^2.7.15", "antd": "4.x", - "react": "17.x", - "react-dom": "17.x" + "react": "18.x", + "react-dom": "18.x" }, "publishConfig": { "access": "public" diff --git a/packages/gi-site/scripts/pre-build.mjs b/packages/gi-site/scripts/pre-build.mjs index 4493a9570..ebeb6cc68 100644 --- a/packages/gi-site/scripts/pre-build.mjs +++ b/packages/gi-site/scripts/pre-build.mjs @@ -42,18 +42,6 @@ const depsPackage = [ global: 'localforage', name: 'localforage', }, - { - url: 'https://gw.alipayobjects.com/os/lib/react/18.2.0/umd/react.production.min.js', - version: '18.2.0', - global: 'React', - name: 'react', - }, - { - url: 'https://gw.alipayobjects.com/os/lib/react-dom/18.2.0/umd/react-dom.production.min.js', - name: 'react-dom', - version: '18.2.0', - global: 'ReactDOM', - }, { url: 'https://gw.alipayobjects.com/os/lib/lodash/4.17.21/lodash.min.js', name: 'lodash', diff --git a/packages/gi-site/src/components/Navbar/ExportSdk.tsx b/packages/gi-site/src/components/Navbar/ExportSdk.tsx index f17b0d9de..268397dd4 100644 --- a/packages/gi-site/src/components/Navbar/ExportSdk.tsx +++ b/packages/gi-site/src/components/Navbar/ExportSdk.tsx @@ -54,8 +54,8 @@ const SdkContent = () => { data: { transData: data }, }, deps: { - react: '17.x', - 'react-dom': '17.x', + react: '18.x', + 'react-dom': '18.x', localforage: '1.10.0', antd: ANTD_VERSION, '@antv/gi-theme-antd': GI_THEME_ANTD_VERSION,