From 4a27195611d3c3eecb54cc35a05140294085a74e Mon Sep 17 00:00:00 2001 From: Peter Pan Date: Mon, 13 Jul 2020 16:59:49 +0800 Subject: [PATCH] frontend: remove runtime public path config (#711) * build: remove protobufjs dependency * chore: support runtime config * v2.0.0-beta.44 * fix: api url build config * v2.0.0-beta.45 * fix: give up runtime config * fix code style * use publicPath config in i18n * fix python app typo --- .gitignore | 2 ++ frontend/lerna.json | 2 +- frontend/packages/cli/package.json | 4 +-- .../packages/core/components/ChartPage.tsx | 4 ++- frontend/packages/core/components/Error.tsx | 4 ++- .../core/components/GraphsPage/Graph.tsx | 6 +++-- .../GraphsPage/NodeDocumentationSidebar.tsx | 3 +-- frontend/packages/core/components/Navbar.tsx | 7 ++--- .../packages/core/components/Preloader.tsx | 2 +- frontend/packages/core/next.config.d.ts | 1 + frontend/packages/core/next.config.js | 4 +-- frontend/packages/core/package.json | 10 +++---- frontend/packages/core/pages/_app.tsx | 26 ++++--------------- frontend/packages/core/pages/_document.tsx | 6 ----- frontend/packages/core/types/global.d.ts | 4 --- frontend/packages/core/utils/fetch.ts | 17 ++++++------ frontend/packages/core/utils/i18n.ts | 1 + frontend/packages/core/utils/style.ts | 4 ++- frontend/packages/i18n/package.json | 2 +- .../packages/i18n/src/config/create-config.ts | 2 +- .../i18n/src/config/default-config.ts | 1 + .../i18n/src/hocs/app-with-translation.tsx | 4 +-- frontend/packages/i18n/types.d.ts | 1 + frontend/packages/mock/package.json | 2 +- frontend/packages/netron/package.json | 2 +- frontend/packages/server/index.ts | 9 ++++++- frontend/packages/server/package.json | 10 +++---- frontend/packages/serverless/package.json | 4 +-- frontend/packages/wasm/package.json | 2 +- visualdl/server/app.py | 2 +- 30 files changed, 71 insertions(+), 77 deletions(-) diff --git a/.gitignore b/.gitignore index 66ccd931..c80ec38f 100644 --- a/.gitignore +++ b/.gitignore @@ -112,3 +112,5 @@ ENV/ # asdf .tool-versions + +docker-compose.override.yml diff --git a/frontend/lerna.json b/frontend/lerna.json index 2d7884cb..6110d770 100644 --- a/frontend/lerna.json +++ b/frontend/lerna.json @@ -2,7 +2,7 @@ "packages": [ "packages/*" ], - "version": "2.0.0-beta.43", + "version": "2.0.0-beta.45", "npmClient": "yarn", "useWorkspaces": true, "command": { diff --git a/frontend/packages/cli/package.json b/frontend/packages/cli/package.json index dccd19f5..c6440cad 100644 --- a/frontend/packages/cli/package.json +++ b/frontend/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@visualdl/cli", - "version": "2.0.0-beta.43", + "version": "2.0.0-beta.45", "description": "A platform to visualize the deep learning process and result.", "keywords": [ "visualdl", @@ -34,7 +34,7 @@ "dist" ], "dependencies": { - "@visualdl/server": "2.0.0-beta.43", + "@visualdl/server": "2.0.0-beta.45", "open": "7.0.4", "ora": "4.0.4", "pm2": "4.4.0", diff --git a/frontend/packages/core/components/ChartPage.tsx b/frontend/packages/core/components/ChartPage.tsx index 4f5036ab..75461d95 100644 --- a/frontend/packages/core/components/ChartPage.tsx +++ b/frontend/packages/core/components/ChartPage.tsx @@ -11,6 +11,8 @@ import groupBy from 'lodash/groupBy'; import styled from 'styled-components'; import useSearchValue from '~/hooks/useSearchValue'; +const PUBLIC_PATH = process.env.PUBLIC_PATH; + const StyledPagination = styled(Pagination)` margin-top: ${rem(20)}; `; @@ -52,7 +54,7 @@ const Empty = styled.div<{height?: string}>` height: ${props => props.height ?? 'auto'}; padding: ${rem(320)} 0 ${rem(70)}; background-color: ${backgroundColor}; - background-image: url(${`${process.env.PUBLIC_PATH}/images/empty.svg`}); + background-image: url(${`${PUBLIC_PATH}/images/empty.svg`}); background-repeat: no-repeat; background-position: calc(50% + ${rem(25)}) ${rem(70)}; background-size: ${rem(280)} ${rem(244)}; diff --git a/frontend/packages/core/components/Error.tsx b/frontend/packages/core/components/Error.tsx index 11662d0f..402f80ff 100644 --- a/frontend/packages/core/components/Error.tsx +++ b/frontend/packages/core/components/Error.tsx @@ -4,6 +4,8 @@ import {WithStyled, backgroundColor, em, link, rem, size, textColor, textLightCo import styled from 'styled-components'; +const PUBLIC_PATH = process.env.PUBLIC_PATH; + const Wrapper = styled.div` display: flex; justify-content: center; @@ -13,7 +15,7 @@ const Wrapper = styled.div` width: 100%; > .image { - background-image: url(${`${process.env.PUBLIC_PATH}/images/empty.svg`}); + background-image: url(${`${PUBLIC_PATH}/images/empty.svg`}); background-repeat: no-repeat; background-position: center center; background-size: 100% 100%; diff --git a/frontend/packages/core/components/GraphsPage/Graph.tsx b/frontend/packages/core/components/GraphsPage/Graph.tsx index 23993d6d..54556362 100644 --- a/frontend/packages/core/components/GraphsPage/Graph.tsx +++ b/frontend/packages/core/components/GraphsPage/Graph.tsx @@ -8,6 +8,8 @@ import styled from 'styled-components'; import {toast} from 'react-toastify'; import {useTranslation} from '~/utils/i18n'; +const PUBLIC_PATH = process.env.PUBLIC_PATH; + const toolboxHeight = rem(40); const Wrapper = styled.div` @@ -247,7 +249,7 @@ const Graph = React.forwardRef(