From e125c3448ba9b90a83dba9e9c30f9b4c4231fa63 Mon Sep 17 00:00:00 2001 From: Fine Date: Fri, 16 Dec 2022 17:35:39 +0800 Subject: [PATCH] refactor: topology icons --- src/assets/img/icons.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/assets/img/icons.ts b/src/assets/img/icons.ts index a24f439b..6a9d8a60 100755 --- a/src/assets/img/icons.ts +++ b/src/assets/img/icons.ts @@ -14,8 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const requireComponent: any = import.meta.glob("./technologies/*.svg"); -const requireTool: any = import.meta.glob("./tools/*.png"); +const requireComponent: any = import.meta.glob("./technologies/*.png", { eager: true }); +const requireTool: any = import.meta.glob("./tools/*.png", { eager: true }); const result: { [key: string]: string } = {}; const t: { [key: string]: string } = {}; @@ -28,19 +28,15 @@ function validateFileName(str: string): string | undefined { } } Object.keys(requireComponent).forEach((filePath: string) => { - const componentConfig = requireComponent(filePath); - const fileName = validateFileName(filePath); if (fileName) { - result[fileName] = componentConfig; + result[fileName] = requireComponent[filePath].default; } }); Object.keys(requireTool).forEach((filePath: string) => { - const componentConfig = requireTool[filePath]; - const fileName = validateFileName(filePath); if (fileName) { - t[fileName] = componentConfig; + t[fileName] = requireTool[filePath].default; } });