Initial project

This commit is contained in:
Timi
2025-07-08 16:33:11 +08:00
parent 1a5a16be74
commit f862530142
80 changed files with 8301 additions and 129 deletions

26
src/utils/IconMapper.ts Normal file
View File

@@ -0,0 +1,26 @@
import iconJson from "../assets/icon.json";
export default class IconMapper {
private static instance: IconMapper;
icons = new Map<string, string>();
private constructor() {
Object.entries(iconJson).forEach(([key, value]) => this.icons.set(key, value));
}
public getSVG(name: string, scale = 1) {
const svg = IconMapper.getInstance().icons.get(name.toLowerCase());
return svg?.replace(/\d+(\.\d+)?/gm, n => {
return String((Number(n) * scale));
});
}
public static getInstance(): IconMapper {
if (!IconMapper.instance) {
IconMapper.instance = new IconMapper();
}
return IconMapper.instance;
}
}