56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
// 从 @iconify-json/catppuccin(Catppuccin VSCode Icons)提取对象存储用到的文件类型图标,
|
|
// 生成 src/components/objectstorage/fileIcons.ts 静态模块,避免把 659 个图标全量打进 bundle。
|
|
// 再生成:node scripts/gen-file-icons.mjs
|
|
import { createRequire } from 'node:module'
|
|
import { writeFileSync } from 'node:fs'
|
|
|
|
const require = createRequire(import.meta.url)
|
|
const { icons } = require('@iconify-json/catppuccin/icons.json')
|
|
|
|
// 图标名 → 该集合内的 icon key(catppuccin 集为 16x16)
|
|
const PICK = [
|
|
'folder',
|
|
'file',
|
|
'image',
|
|
'json',
|
|
'yaml',
|
|
'toml',
|
|
'properties',
|
|
'python',
|
|
'javascript',
|
|
'typescript',
|
|
'markdown',
|
|
'database',
|
|
'bash',
|
|
'go',
|
|
'zip',
|
|
'pdf',
|
|
'video',
|
|
'audio',
|
|
'html',
|
|
'css',
|
|
'text',
|
|
'log',
|
|
'csv',
|
|
'xml',
|
|
'binary',
|
|
'ms-word',
|
|
'ms-excel',
|
|
'ms-powerpoint'
|
|
]
|
|
|
|
const entries = PICK.map((name) => {
|
|
const icon = icons[name]
|
|
if (!icon) throw new Error(`icon not found: ${name}`)
|
|
return ` ${JSON.stringify(name)}:\n '${icon.body.replaceAll("'", "\\'")}',`
|
|
}).join('\n')
|
|
|
|
const out = `// 由 scripts/gen-file-icons.mjs 从 @iconify-json/catppuccin 提取,勿手改;
|
|
// 来源:Catppuccin VSCode Icons(MIT),16x16 viewBox。
|
|
export const FILE_ICON_BODIES: Record<string, string> = {
|
|
${entries}
|
|
}
|
|
`
|
|
writeFileSync(new URL('../src/components/objectstorage/fileIcons.ts', import.meta.url), out)
|
|
console.log(`written ${PICK.length} icons`)
|