// ═══════════════════════════════════════════════════════════════════════════════ // Seti 字体字符映射(与 QodeChatPanel 完全一致:FileReviewPart 内联 + utils/fileIconMaps.js) // 用于 qoder-seti.woff,勿改为 VSCode vs-seti 码位(E051/E055 等) // ═══════════════════════════════════════════════════════════════════════════════ export const SETI_CHAR_MAP: Record = { javascript: '\ue054', typescript: '\ue099', react: '\ue07d', json: '\ue059', html: '\ue048', css: '\ue01d', python: '\ue07b', java: '\ue050', go: '\ue039', rust: '\ue082', php: '\ue070', ruby: '\ue081', vue: '\ue09d', svelte: '\ue090', markdown: '\ue060', yaml: '\ue0a7', xml: '\ue0a5', shell: '\ue089', sass: '\ue084', settings: '\ue019', default: '\ue023', } // ═══════════════════════════════════════════════════════════════════════════════ // Seti 图标颜色(tokenized,用于 Seti 字体渲染 style.color) // ═══════════════════════════════════════════════════════════════════════════════ export const SETI_COLOR_MAP: Record = { javascript: 'var(--color-yellow)', typescript: 'var(--color-blue)', react: 'var(--color-blue)', json: 'var(--color-yellow)', html: 'var(--color-blue)', css: 'var(--color-blue)', python: 'var(--color-blue)', java: 'var(--color-error)', go: 'var(--color-blue)', rust: 'var(--color-lavender)', php: 'var(--color-purple)', ruby: 'var(--color-error)', vue: 'var(--color-success)', svelte: 'var(--color-error)', markdown: 'var(--color-blue)', yaml: 'var(--color-purple)', xml: 'var(--color-orange)', shell: 'var(--color-success)', sass: 'var(--color-error)', settings: 'var(--color-lavender)', default: 'var(--color-lavender)', } // ═══════════════════════════════════════════════════════════════════════════════ // 扩展名 -> 类型名 // ═══════════════════════════════════════════════════════════════════════════════ export const FILE_TYPE_MAP: Record = { js: 'javascript', jsx: 'react', ts: 'typescript', tsx: 'typescript', json: 'json', html: 'html', css: 'css', scss: 'sass', sass: 'sass', less: 'css', py: 'python', java: 'java', go: 'go', rs: 'rust', php: 'php', rb: 'ruby', vue: 'vue', svelte: 'svelte', md: 'markdown', yml: 'yaml', yaml: 'yaml', xml: 'xml', sh: 'shell', bash: 'shell', zsh: 'shell', config: 'settings', conf: 'settings', } // ═══════════════════════════════════════════════════════════════════════════════ // 类型 -> Tailwind 设计 token 类(无 Seti 字体时用通用图标+此类) // ═══════════════════════════════════════════════════════════════════════════════ export const TYPE_TO_TOKEN_CLASS: Record = { javascript: 'text-info', typescript: 'text-info', react: 'text-info', json: 'text-info', html: 'text-info', css: 'text-info', python: 'text-teal', java: 'text-error', go: 'text-info', rust: 'text-text-tertiary', php: 'text-text-tertiary', ruby: 'text-error', vue: 'text-success', svelte: 'text-error', markdown: 'text-text-secondary', yaml: 'text-text-tertiary', xml: 'text-text-tertiary', shell: 'text-success', sass: 'text-error', settings: 'text-text-tertiary', default: 'text-text-tertiary', } export function getSetiIconType(fileType?: string, filename?: string): string { let iconType: string | null = null if (filename && typeof filename === 'string' && filename.trim()) { const lastDot = filename.lastIndexOf('.') if (lastDot > 0 && lastDot < filename.length - 1) { const ext = filename.substring(lastDot + 1).toLowerCase().trim() if (ext && FILE_TYPE_MAP[ext]) iconType = FILE_TYPE_MAP[ext] } } if (!iconType && fileType && typeof fileType === 'string' && fileType.trim()) { const lower = fileType.toLowerCase().trim() if (FILE_TYPE_MAP[lower]) iconType = FILE_TYPE_MAP[lower] else if (SETI_CHAR_MAP[lower]) iconType = lower } return iconType || 'default' } export function getSetiIcon(fileType?: string, filename?: string): string { const iconType = getSetiIconType(fileType, filename) return SETI_CHAR_MAP[iconType] ?? SETI_CHAR_MAP.default } export function getSetiIconColor(fileType?: string, filename?: string): string { const type = getSetiIconType(fileType, filename) return SETI_COLOR_MAP[type] ?? SETI_COLOR_MAP.default } /** 返回 Tailwind token 类名,用于通用文件图标(非 Seti 字体) */ export function getFileIconColorClass(fileType?: string, filename?: string): string { const type = getSetiIconType(fileType, filename) return TYPE_TO_TOKEN_CLASS[type] ?? TYPE_TO_TOKEN_CLASS.default }