import "./style.css"; import typescriptLogo from "./typescript.svg"; import viteLogo from "/vite.svg"; import { setupCounter } from "./counter.ts"; // document.querySelector('#app')!.innerHTML = ` //
// // // // // // //

Vite + TypeScript

//
// //
//

// Click on the Vite and TypeScript logos to learn more //

//
// ` // setupCounter(document.querySelector('#counter')!) // index.ts import fs from "fs/promises"; import { log } from "console"; const assetsPath = "./assets"; const tsPath = "./tsFiles"; async function main() { console.log(1111); const files = await fs.readdir(assetsPath); for (const file of files) { const filePath = path.join(assetsPath, file); const stat = await fs.stat(filePath); if (stat.isDirectory()) { console.log(`dir: ${filePath}`); } else if (stat.isFile() && ["svg", "png"].includes(path.extname(file))) { // 生成 ts files generateTsFile(filePath); } } } async function generateTsFile(filePath) { const fileContent = fs.readFile(filePath, "utf8"); if (fileContent.includes("]*>(.*?)<\/svg>/s); if (match) { console.log(`icon ${filePath} created!`); } } else if (fileContent.includes(".png")) { // png文件内容 const match = fileContent.match(/data:image\/png;,\s*base64\((.*?)\)/); if (match) { console.log(`icon ${filePath} created!`); } } } main().catch((error) => { console.error(error); });