refactor: topology icons

This commit is contained in:
Fine 2022-12-16 17:35:39 +08:00
parent f6b075c11c
commit e125c3448b

View File

@ -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;
}
});