From 491bf88063f46f775de067faa3775160c76afb5e Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Tue, 8 Feb 2022 14:39:39 +0800 Subject: [PATCH] feat: update topology --- src/locales/lang/zh.ts | 1 + .../dashboard/related/topology/utils/icons.ts | 2 +- .../dashboard/related/topology/utils/tool.ts | 21 +------------------ tsconfig.json | 1 + 4 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/locales/lang/zh.ts b/src/locales/lang/zh.ts index 42137a22..4156e0cf 100644 --- a/src/locales/lang/zh.ts +++ b/src/locales/lang/zh.ts @@ -23,6 +23,7 @@ const msg = { infrastructure: "基础结构", virtualMachine: "虚拟机", kubernetes: "Kubernetes", + dashboardNew: "新建仪表板", dashboardHome: "仪表盘首页", dashboardList: "仪表盘列表", log: "日志", diff --git a/src/views/dashboard/related/topology/utils/icons.ts b/src/views/dashboard/related/topology/utils/icons.ts index bfd40353..ac659977 100755 --- a/src/views/dashboard/related/topology/utils/icons.ts +++ b/src/views/dashboard/related/topology/utils/icons.ts @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const requireComponent = require.context("../../assets", false, /\.png$/); +const requireComponent = require.context("./tool", false, /\.png$/); const result: { [key: string]: string } = {}; function capitalizeFirstLetter(str: string) { diff --git a/src/views/dashboard/related/topology/utils/tool.ts b/src/views/dashboard/related/topology/utils/tool.ts index 89ddd0a8..96a0f8f8 100644 --- a/src/views/dashboard/related/topology/utils/tool.ts +++ b/src/views/dashboard/related/topology/utils/tool.ts @@ -14,26 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const requireComponent = require.context("./tool", false, /\.png$/); -const icons: { [key: string]: string } = {}; - -function capitalizeFirstLetter(str: string) { - return str.toUpperCase(); -} -function validateFileName(str: string): string | undefined { - if (/^\S+\.png$/.test(str)) { - return str.replace(/^\S+\/(\w+)\.png$/, (rs, $1) => - capitalizeFirstLetter($1) - ); - } -} -requireComponent.keys().forEach((filePath: string) => { - const componentConfig = requireComponent(filePath); - const fileName = validateFileName(filePath); - if (fileName) { - icons[fileName] = componentConfig; - } -}); +import icons from "./icons"; const Hexagon = (side: number, r: number, cx: number, cy: number) => { let path = ""; diff --git a/tsconfig.json b/tsconfig.json index 045b4baf..e2594fd6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -30,6 +30,7 @@ "baseUrl": ".", "allowJs": true, "resolveJsonModule": true, + "noImplicitThis": false, "types": [ "webpack-env", "jest"