@huyooo/file-explorer-frontend-react 0.4.18 → 0.4.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/index.css +0 -1
  2. package/dist/index.js +1 -3456
  3. package/package.json +4 -4
  4. package/dist/index.css.map +0 -1
  5. package/dist/index.js.map +0 -1
  6. package/src/components/Breadcrumb.css +0 -61
  7. package/src/components/Breadcrumb.tsx +0 -38
  8. package/src/components/CompressDialog.css +0 -267
  9. package/src/components/CompressDialog.tsx +0 -222
  10. package/src/components/ContextMenu.css +0 -155
  11. package/src/components/ContextMenu.tsx +0 -375
  12. package/src/components/FileGrid.css +0 -239
  13. package/src/components/FileGrid.tsx +0 -278
  14. package/src/components/FileIcon.css +0 -41
  15. package/src/components/FileIcon.tsx +0 -86
  16. package/src/components/FileInfoDialog.css +0 -214
  17. package/src/components/FileInfoDialog.tsx +0 -202
  18. package/src/components/FileList.css +0 -169
  19. package/src/components/FileList.tsx +0 -228
  20. package/src/components/FileListView.css +0 -36
  21. package/src/components/FileListView.tsx +0 -355
  22. package/src/components/FileSidebar.css +0 -94
  23. package/src/components/FileSidebar.tsx +0 -66
  24. package/src/components/ProgressDialog.css +0 -211
  25. package/src/components/ProgressDialog.tsx +0 -183
  26. package/src/components/SortIndicator.css +0 -7
  27. package/src/components/SortIndicator.tsx +0 -19
  28. package/src/components/StatusBar.css +0 -20
  29. package/src/components/StatusBar.tsx +0 -21
  30. package/src/components/Toolbar.css +0 -150
  31. package/src/components/Toolbar.tsx +0 -127
  32. package/src/components/Window.css +0 -246
  33. package/src/components/Window.tsx +0 -335
  34. package/src/hooks/useApplicationIcon.ts +0 -80
  35. package/src/hooks/useDragAndDrop.ts +0 -104
  36. package/src/hooks/useMediaPlayer.ts +0 -164
  37. package/src/hooks/useSelection.ts +0 -112
  38. package/src/hooks/useWindowDrag.ts +0 -60
  39. package/src/hooks/useWindowResize.ts +0 -126
  40. package/src/index.css +0 -184
  41. package/src/index.ts +0 -37
  42. package/src/types/index.ts +0 -274
  43. package/src/utils/fileTypeIcon.ts +0 -309
  44. package/src/utils/folderTypeIcon.ts +0 -132
@@ -1,309 +0,0 @@
1
- import { FileType } from '../types';
2
-
3
- /**
4
- * 文件图标映射(基于 material-icon-theme.json)
5
- *
6
- * 原理:
7
- * 1. KNOWN_TYPES:从 material-icon-theme.json 提取的所有图标名
8
- * 2. EXT_MAP:扩展名 → 图标名
9
- * 3. SPECIAL_FILES:特殊文件名 → 图标名
10
- * 4. 逻辑:特殊文件名匹配 → 扩展名匹配 → 兜底
11
- */
12
-
13
- // 从 material-icon-theme.json 提取的所有图标名(~200 个常用)
14
- const KNOWN_TYPES = new Set([
15
- '3d', 'actionscript', 'ada', 'adobe-illustrator', 'adobe-photoshop', 'android',
16
- 'angular', 'applescript', 'arduino', 'asciidoc', 'assembly', 'astro', 'audio',
17
- 'aurelia', 'babel', 'ballerina', 'bazel', 'biome', 'blender', 'bower', 'bun',
18
- 'c', 'cabal', 'caddy', 'cake', 'certificate', 'changelog', 'circleci', 'claude',
19
- 'clojure', 'cmake', 'cobol', 'coffee', 'command', 'conduct', 'contributing',
20
- 'controller', 'copilot', 'cpp', 'crystal', 'csharp', 'css', 'css-map', 'cucumber',
21
- 'cuda', 'cursor', 'cypress', 'd', 'dart', 'database', 'deno', 'dependabot', 'diff',
22
- 'django', 'docker', 'document', 'drawio', 'drizzle', 'editorconfig', 'ejs',
23
- 'elixir', 'elm', 'email', 'ember', 'epub', 'erlang', 'esbuild', 'eslint',
24
- 'excalidraw', 'exe', 'favicon', 'figma', 'firebase', 'flash', 'flow', 'font',
25
- 'forth', 'fortran', 'freemarker', 'fsharp', 'gamemaker', 'gatsby', 'gcp', 'gemfile',
26
- 'gemini', 'git', 'gitlab', 'gleam', 'go', 'go-mod', 'godot', 'gradle', 'graphql',
27
- 'groovy', 'grunt', 'gulp', 'h', 'haml', 'handlebars', 'hardhat', 'haskell', 'haxe',
28
- 'hcl', 'helm', 'hjson', 'hosts', 'hpp', 'html', 'http', 'husky', 'i18n', 'image',
29
- 'imba', 'ionic', 'jar', 'java', 'javaclass', 'javascript', 'javascript-map',
30
- 'jenkins', 'jest', 'jinja', 'jsconfig', 'json', 'julia', 'jupyter', 'just',
31
- 'karma', 'key', 'kotlin', 'kubernetes', 'laravel', 'lean', 'lefthook', 'lerna',
32
- 'less', 'lib', 'license', 'lighthouse', 'liquid', 'lisp', 'livescript', 'lock',
33
- 'log', 'lua', 'luau', 'makefile', 'markdown', 'markdownlint', 'matlab', 'maven',
34
- 'mdx', 'mercurial', 'mermaid', 'meson', 'minecraft', 'mjml', 'mocha', 'mojo',
35
- 'nest', 'netlify', 'next', 'nginx', 'nim', 'nix', 'nodejs', 'nodemon', 'npm',
36
- 'nuget', 'nunjucks', 'nuxt', 'nx', 'objective-c', 'objective-cpp', 'ocaml', 'odin',
37
- 'openapi', 'opentofu', 'pascal', 'pdf', 'perl', 'php', 'phpstan', 'phpunit',
38
- 'pipeline', 'playwright', 'pnpm', 'postcss', 'powerpoint', 'powershell', 'prettier',
39
- 'prisma', 'processing', 'prolog', 'proto', 'pug', 'puppet', 'purescript', 'python',
40
- 'pytorch', 'quasar', 'r', 'racket', 'razor', 'react', 'react-ts', 'readme', 'reason',
41
- 'remark', 'remix', 'renovate', 'replit', 'rescript', 'riot', 'roadmap', 'robot',
42
- 'robots', 'rollup', 'routing', 'rspec', 'rubocop', 'ruby', 'ruff', 'rust', 'salt',
43
- 'san', 'sas', 'sass', 'sbt', 'scala', 'scheme', 'search', 'sentry', 'sequelize',
44
- 'serverless', 'settings', 'shader', 'shellcheck', 'sketch', 'slim', 'slint',
45
- 'smarty', 'snakemake', 'snapcraft', 'snyk', 'solidity', 'spwn', 'stackblitz',
46
- 'stan', 'stencil', 'storybook', 'stryker', 'stylelint', 'stylus', 'sublime',
47
- 'subtitles', 'supabase', 'svelte', 'svg', 'svgo', 'swagger', 'swc', 'swift',
48
- 'tailwindcss', 'taskfile', 'tauri', 'tcl', 'teal', 'templ', 'template', 'terraform',
49
- 'test-js', 'test-jsx', 'test-ts', 'tex', 'todo', 'toml', 'travis', 'tree', 'tsconfig',
50
- 'tsdoc', 'turborepo', 'twig', 'typescript', 'typescript-def', 'unity', 'unocss',
51
- 'vagrant', 'vanilla-extract', 'vercel', 'verilog', 'video', 'vim', 'vite', 'vitest',
52
- 'vlang', 'vscode', 'vue', 'vue-config', 'wakatime', 'wallaby', 'webassembly',
53
- 'webhint', 'webpack', 'windicss', 'word', 'wrangler', 'wxt', 'xaml', 'xmake',
54
- 'xml', 'yaml', 'yarn', 'zig', 'zip',
55
- ]);
56
-
57
- // 扩展名 → 图标名
58
- const EXT_MAP: Record<string, string> = {
59
- // JavaScript/TypeScript
60
- 'js': 'javascript', 'mjs': 'javascript', 'cjs': 'javascript',
61
- 'jsx': 'react',
62
- 'ts': 'typescript', 'mts': 'typescript', 'cts': 'typescript',
63
- 'tsx': 'react-ts',
64
- // 前端框架
65
- 'vue': 'vue',
66
- 'svelte': 'svelte',
67
- 'astro': 'astro',
68
- // 后端语言
69
- 'py': 'python', 'pyw': 'python', 'pyi': 'python', 'pyc': 'python',
70
- 'java': 'java', 'class': 'javaclass', 'jar': 'jar',
71
- 'c': 'c', 'h': 'h',
72
- 'cpp': 'cpp', 'cc': 'cpp', 'cxx': 'cpp', 'hpp': 'hpp', 'hh': 'hpp', 'hxx': 'hpp',
73
- 'cs': 'csharp', 'csx': 'csharp',
74
- 'go': 'go',
75
- 'rs': 'rust',
76
- 'php': 'php', 'phtml': 'php',
77
- 'rb': 'ruby', 'rake': 'ruby',
78
- 'swift': 'swift',
79
- 'kt': 'kotlin', 'kts': 'kotlin',
80
- 'scala': 'scala',
81
- 'dart': 'dart',
82
- 'lua': 'lua', 'luau': 'luau',
83
- 'r': 'r', 'rdata': 'r', 'rds': 'r',
84
- 'pl': 'perl', 'pm': 'perl',
85
- 'sh': 'command', 'bash': 'command', 'zsh': 'command', 'fish': 'command',
86
- 'ps1': 'powershell', 'psm1': 'powershell', 'psd1': 'powershell',
87
- 'bat': 'command', 'cmd': 'command',
88
- // 样式
89
- 'css': 'css',
90
- 'scss': 'sass', 'sass': 'sass',
91
- 'less': 'less',
92
- 'styl': 'stylus',
93
- // 标记/配置
94
- 'html': 'html', 'htm': 'html', 'xhtml': 'html',
95
- 'xml': 'xml', 'xsl': 'xml', 'xslt': 'xml',
96
- 'json': 'json', 'jsonc': 'json', 'json5': 'json',
97
- 'yaml': 'yaml', 'yml': 'yaml',
98
- 'toml': 'toml',
99
- 'ini': 'settings',
100
- 'conf': 'settings', 'config': 'settings',
101
- // 文档
102
- 'md': 'markdown', 'markdown': 'markdown', 'mdx': 'mdx',
103
- 'txt': 'document',
104
- 'pdf': 'pdf',
105
- 'doc': 'word', 'docx': 'word', 'dot': 'word', 'dotx': 'word', 'odt': 'word',
106
- 'xls': 'table', 'xlsx': 'table', 'xlsm': 'table', 'ods': 'table', 'csv': 'table',
107
- 'ppt': 'powerpoint', 'pptx': 'powerpoint', 'odp': 'powerpoint',
108
- // 图片
109
- 'jpg': 'image', 'jpeg': 'image', 'png': 'image', 'gif': 'image', 'webp': 'image',
110
- 'ico': 'image', 'bmp': 'image', 'tiff': 'image', 'tif': 'image', 'heic': 'image', 'heif': 'image',
111
- 'svg': 'svg',
112
- 'psd': 'adobe-photoshop',
113
- 'ai': 'adobe-illustrator',
114
- 'sketch': 'sketch',
115
- 'fig': 'figma', 'figma': 'figma',
116
- // 视频/音频
117
- 'mp4': 'video', 'mov': 'video', 'avi': 'video', 'mkv': 'video', 'webm': 'video',
118
- 'flv': 'video', 'wmv': 'video', 'm4v': 'video', '3gp': 'video', 'mpeg': 'video', 'mpg': 'video',
119
- 'mp3': 'audio', 'wav': 'audio', 'flac': 'audio', 'aac': 'audio', 'ogg': 'audio',
120
- 'wma': 'audio', 'm4a': 'audio', 'aiff': 'audio',
121
- // 压缩
122
- 'zip': 'zip', 'rar': 'zip', '7z': 'zip', 'tar': 'zip', 'gz': 'zip', 'bz2': 'zip',
123
- 'xz': 'zip', 'tgz': 'zip', 'tbz2': 'zip',
124
- // 数据库
125
- 'sql': 'database',
126
- 'db': 'database', 'sqlite': 'database', 'sqlite3': 'database',
127
- 'prisma': 'prisma',
128
- // 其他
129
- 'log': 'log',
130
- 'lock': 'lock',
131
- 'env': 'settings',
132
- 'graphql': 'graphql', 'gql': 'graphql',
133
- 'proto': 'proto',
134
- 'wasm': 'webassembly',
135
- 'zig': 'zig',
136
- 'nim': 'nim',
137
- 'nix': 'nix',
138
- 'hcl': 'hcl', 'tf': 'terraform',
139
- 'sol': 'solidity',
140
- 'ex': 'elixir', 'exs': 'elixir',
141
- 'erl': 'erlang', 'hrl': 'erlang',
142
- 'hs': 'haskell', 'lhs': 'haskell',
143
- 'ml': 'ocaml', 'mli': 'ocaml',
144
- 'clj': 'clojure', 'cljs': 'clojure', 'cljc': 'clojure',
145
- 'lisp': 'lisp', 'lsp': 'lisp', 'el': 'lisp',
146
- 'vim': 'vim',
147
- 'dockerfile': 'docker',
148
- };
149
-
150
- // 特殊文件名 → 图标名
151
- const SPECIAL_FILES: Record<string, string> = {
152
- // Git
153
- '.gitignore': 'git', '.gitattributes': 'git', '.gitmodules': 'git', '.gitkeep': 'git',
154
- // 环境
155
- '.env': 'settings', '.env.local': 'settings', '.env.development': 'settings',
156
- '.env.production': 'settings', '.env.test': 'settings', '.env.example': 'settings',
157
- // Node/包管理
158
- 'package.json': 'nodejs', 'package-lock.json': 'npm',
159
- 'yarn.lock': 'yarn', '.yarnrc': 'yarn', '.yarnrc.yml': 'yarn',
160
- 'pnpm-lock.yaml': 'pnpm', '.pnpmfile.cjs': 'pnpm',
161
- 'bun.lockb': 'bun', 'bunfig.toml': 'bun',
162
- // Python
163
- 'requirements.txt': 'python', 'pipfile': 'python', 'pipfile.lock': 'python',
164
- 'pyproject.toml': 'python', 'poetry.lock': 'python', 'setup.py': 'python',
165
- // Rust
166
- 'cargo.toml': 'rust', 'cargo.lock': 'rust',
167
- // Go
168
- 'go.mod': 'go-mod', 'go.sum': 'go-mod', 'go.work': 'go-mod',
169
- // PHP
170
- 'composer.json': 'php', 'composer.lock': 'php',
171
- // Ruby
172
- 'gemfile': 'gemfile', 'gemfile.lock': 'gemfile', 'rakefile': 'ruby',
173
- // Docker
174
- 'dockerfile': 'docker', 'docker-compose.yml': 'docker', 'docker-compose.yaml': 'docker',
175
- '.dockerignore': 'docker',
176
- // 构建工具
177
- 'makefile': 'makefile', 'gnumakefile': 'makefile',
178
- 'cmakelists.txt': 'cmake',
179
- 'build.gradle': 'gradle', 'build.gradle.kts': 'gradle', 'settings.gradle': 'gradle',
180
- 'pom.xml': 'maven',
181
- // 配置
182
- 'tsconfig.json': 'tsconfig', 'jsconfig.json': 'jsconfig',
183
- '.prettierrc': 'prettier', '.prettierrc.json': 'prettier', '.prettierrc.js': 'prettier',
184
- '.prettierignore': 'prettier', 'prettier.config.js': 'prettier',
185
- '.eslintrc': 'eslint', '.eslintrc.json': 'eslint', '.eslintrc.js': 'eslint',
186
- '.eslintignore': 'eslint', 'eslint.config.js': 'eslint', 'eslint.config.mjs': 'eslint',
187
- '.editorconfig': 'editorconfig',
188
- 'vite.config.ts': 'vite', 'vite.config.js': 'vite',
189
- 'webpack.config.js': 'webpack', 'webpack.config.ts': 'webpack',
190
- 'rollup.config.js': 'rollup', 'rollup.config.ts': 'rollup',
191
- 'esbuild.config.js': 'esbuild',
192
- 'tailwind.config.js': 'tailwindcss', 'tailwind.config.ts': 'tailwindcss',
193
- 'postcss.config.js': 'postcss', 'postcss.config.cjs': 'postcss',
194
- 'babel.config.js': 'babel', '.babelrc': 'babel',
195
- 'jest.config.js': 'jest', 'jest.config.ts': 'jest',
196
- 'vitest.config.ts': 'vitest', 'vitest.config.js': 'vitest',
197
- 'playwright.config.ts': 'playwright', 'playwright.config.js': 'playwright',
198
- 'cypress.config.ts': 'cypress', 'cypress.config.js': 'cypress',
199
- '.swcrc': 'swc', 'swc.config.js': 'swc',
200
- 'turbo.json': 'turborepo',
201
- 'nx.json': 'nx',
202
- 'biome.json': 'biome',
203
- '.nvmrc': 'nodejs', '.node-version': 'nodejs',
204
- // 框架配置
205
- 'nuxt.config.ts': 'nuxt', 'nuxt.config.js': 'nuxt',
206
- 'next.config.js': 'next', 'next.config.mjs': 'next', 'next.config.ts': 'next',
207
- 'svelte.config.js': 'svelte',
208
- 'astro.config.mjs': 'astro', 'astro.config.ts': 'astro',
209
- 'vue.config.js': 'vue-config',
210
- 'angular.json': 'angular',
211
- 'nest-cli.json': 'nest',
212
- 'tauri.conf.json': 'tauri',
213
- // CI/CD
214
- '.travis.yml': 'travis',
215
- '.gitlab-ci.yml': 'gitlab',
216
- 'vercel.json': 'vercel',
217
- 'netlify.toml': 'netlify',
218
- // 其他
219
- 'license': 'license', 'license.md': 'license', 'license.txt': 'license',
220
- 'readme': 'readme', 'readme.md': 'readme', 'readme.txt': 'readme',
221
- 'changelog': 'changelog', 'changelog.md': 'changelog',
222
- '.npmrc': 'npm', '.npmignore': 'npm',
223
- 'robots.txt': 'robots',
224
- '.htaccess': 'nginx',
225
- 'vagrantfile': 'vagrant',
226
- '.stylelintrc': 'stylelint', '.stylelintrc.json': 'stylelint',
227
- 'nodemon.json': 'nodemon',
228
- '.huskyrc': 'husky',
229
- 'renovate.json': 'renovate',
230
- '.snyk': 'snyk',
231
- 'deno.json': 'deno', 'deno.jsonc': 'deno',
232
- };
233
-
234
- /**
235
- * 根据文件名获取 material-icon-theme 图标名称
236
- */
237
- export function getFileTypeIcon(fileName: string, fallbackType?: FileType): string {
238
- const lowerName = fileName.toLowerCase();
239
-
240
- // 1. 特殊文件名匹配
241
- if (SPECIAL_FILES[lowerName]) {
242
- const type = SPECIAL_FILES[lowerName];
243
- if (KNOWN_TYPES.has(type)) {
244
- return `material-icon-theme:${type}`;
245
- }
246
- }
247
-
248
- // 2. Dockerfile 特殊处理
249
- if (lowerName === 'dockerfile' || lowerName.startsWith('dockerfile.')) {
250
- return 'material-icon-theme:docker';
251
- }
252
-
253
- // 3. .env 变体处理
254
- if (lowerName === '.env' || lowerName.startsWith('.env.')) {
255
- return 'material-icon-theme:settings';
256
- }
257
-
258
- // 4. 提取扩展名并匹配
259
- const lastDotIndex = fileName.lastIndexOf('.');
260
- const ext = lastDotIndex > 0 ? fileName.substring(lastDotIndex + 1).toLowerCase() : '';
261
-
262
- // 处理复合扩展名
263
- if (ext === 'ts' || ext === 'js') {
264
- const baseName = fileName.substring(0, lastDotIndex).toLowerCase();
265
- if (baseName.endsWith('.d')) {
266
- return 'material-icon-theme:typescript-def';
267
- }
268
- if (baseName.endsWith('.test') || baseName.endsWith('.spec')) {
269
- return ext === 'ts' ? 'material-icon-theme:test-ts' : 'material-icon-theme:test-js';
270
- }
271
- }
272
- if (ext === 'jsx' || ext === 'tsx') {
273
- const baseName = fileName.substring(0, lastDotIndex).toLowerCase();
274
- if (baseName.endsWith('.test') || baseName.endsWith('.spec')) {
275
- return ext === 'tsx' ? 'material-icon-theme:test-ts' : 'material-icon-theme:test-jsx';
276
- }
277
- }
278
-
279
- if (ext && EXT_MAP[ext]) {
280
- const type = EXT_MAP[ext];
281
- if (KNOWN_TYPES.has(type)) {
282
- return `material-icon-theme:${type}`;
283
- }
284
- }
285
-
286
- // 5. 根据 fallbackType 返回兜底图标
287
- if (fallbackType) {
288
- return getFallbackIcon(fallbackType);
289
- }
290
-
291
- // 6. 最终兜底
292
- return 'material-icon-theme:document';
293
- }
294
-
295
- function getFallbackIcon(type: FileType): string {
296
- switch (type) {
297
- case FileType.IMAGE: return 'material-icon-theme:image';
298
- case FileType.VIDEO: return 'material-icon-theme:video';
299
- case FileType.MUSIC: return 'material-icon-theme:audio';
300
- case FileType.CODE: return 'material-icon-theme:javascript';
301
- case FileType.TEXT: return 'material-icon-theme:document';
302
- case FileType.DOCUMENT: return 'material-icon-theme:word';
303
- case FileType.PDF: return 'material-icon-theme:pdf';
304
- case FileType.ARCHIVE: return 'material-icon-theme:zip';
305
- case FileType.APPLICATION: return 'material-icon-theme:exe';
306
- default: return 'material-icon-theme:document';
307
- }
308
- }
309
-
@@ -1,132 +0,0 @@
1
- /**
2
- * 文件夹图标映射(基于 material-icon-theme.json)
3
- *
4
- * 原理:
5
- * 1. KNOWN_TYPES:从 material-icon-theme.json 提取的所有 folder-{type} 类型
6
- * 2. ALIASES:常见变体映射到标准名
7
- * 3. 逻辑:目录名小写 → 查别名 → 查白名单 → 命中则返回 material-icon-theme:folder-{type}
8
- */
9
-
10
- // 从 material-icon-theme.json 提取的所有 folder-* 类型(去掉 folder- 前缀和 -open 后缀)
11
- const KNOWN_TYPES = new Set([
12
- 'admin', 'android', 'angular', 'animation', 'ansible', 'api', 'apollo', 'app',
13
- 'archive', 'astro', 'atom', 'attachment', 'audio', 'aurelia', 'aws',
14
- 'azure-pipelines', 'backup', 'base', 'batch', 'benchmark', 'bibliography',
15
- 'bicep', 'blender', 'bloc', 'bower', 'buildkite', 'cart', 'changesets', 'ci',
16
- 'circleci', 'class', 'claude', 'client', 'cline', 'cloud-functions', 'cloudflare',
17
- 'cluster', 'cobol', 'command', 'components', 'config', 'connection', 'console',
18
- 'constant', 'container', 'content', 'context', 'contract', 'controller', 'core',
19
- 'coverage', 'css', 'cue', 'cursor', 'custom', 'cypress', 'dal', 'dart', 'database',
20
- 'debug', 'decorators', 'delta', 'desktop', 'directive', 'dist', 'docker', 'docs',
21
- 'download', 'drizzle', 'dump', 'element', 'enum', 'environment', 'error', 'eslint',
22
- 'event', 'examples', 'expo', 'export', 'fastlane', 'favicon', 'features', 'filter',
23
- 'firebase', 'firestore', 'flow', 'flutter', 'font', 'forgejo', 'functions',
24
- 'gamemaker', 'generator', 'gh-workflows', 'git', 'gitea', 'github', 'gitlab',
25
- 'global', 'godot', 'gradle', 'graphql', 'guard', 'gulp', 'helm', 'helper', 'home',
26
- 'hook', 'husky', 'i18n', 'images', 'import', 'include', 'input', 'intellij',
27
- 'interceptor', 'interface', 'ios', 'java', 'javascript', 'jinja', 'job', 'json',
28
- 'jupyter', 'keys', 'kubernetes', 'kusto', 'layout', 'lefthook', 'less', 'lib',
29
- 'license', 'link', 'linux', 'liquibase', 'log', 'lottie', 'lua', 'luau', 'macos',
30
- 'mail', 'mappings', 'markdown', 'mercurial', 'messages', 'meta', 'metro',
31
- 'middleware', 'migrations', 'mjml', 'mobile', 'mock', 'mojo', 'molecule', 'moon',
32
- 'netlify', 'next', 'ngrx-store', 'node', 'nuxt', 'obsidian', 'organism', 'other',
33
- 'packages', 'pdf', 'pdm', 'php', 'phpmailer', 'pipe', 'plastic', 'plugin', 'policy',
34
- 'powershell', 'prisma', 'private', 'project', 'prompts', 'proto', 'public', 'python',
35
- 'pytorch', 'quasar', 'queue', 'react-components', 'redux-reducer', 'repository',
36
- 'resolver', 'resource', 'review', 'robot', 'routes', 'rules', 'rust', 'salt',
37
- 'sandbox', 'sass', 'scala', 'scons', 'scripts', 'secure', 'seeders', 'server',
38
- 'serverless', 'shader', 'shared', 'simulations', 'snapcraft', 'snippet', 'src',
39
- 'src-tauri', 'stack', 'stencil', 'store', 'storybook', 'stylus', 'sublime',
40
- 'supabase', 'svelte', 'svg', 'syntax', 'target', 'taskfile', 'tasks', 'television',
41
- 'temp', 'template', 'terraform', 'test', 'theme', 'toc', 'tools', 'trash', 'trigger',
42
- 'turborepo', 'typescript', 'ui', 'unity', 'update', 'upload', 'utils', 'vercel',
43
- 'verdaccio', 'video', 'views', 'vm', 'vscode', 'vue', 'vue-directives', 'vuepress',
44
- 'vuex-store', 'wakatime', 'webpack', 'windows', 'wordpress', 'yarn', 'zeabur',
45
- ]);
46
-
47
- // 别名映射
48
- const ALIASES: Record<string, string> = {
49
- // 复数/变体
50
- 'tests': 'test', '__tests__': 'test', '__test__': 'test', 'spec': 'test', 'specs': 'test',
51
- 'script': 'scripts',
52
- 'configs': 'config', 'configuration': 'config', 'configurations': 'config',
53
- 'route': 'routes', 'routing': 'routes',
54
- 'stories': 'storybook', 'story': 'storybook',
55
- 'templates': 'template',
56
- 'themes': 'theme',
57
- 'videos': 'video',
58
- 'imgs': 'images', 'img': 'images', 'image': 'images',
59
- 'fonts': 'font',
60
- 'styles': 'css', 'style': 'css', 'styling': 'css', 'stylesheets': 'css',
61
- 'view': 'views', 'pages': 'views', 'page': 'views',
62
- 'layouts': 'layout',
63
- 'models': 'database', 'model': 'database',
64
- 'modules': 'lib', 'module': 'lib', 'mods': 'lib',
65
- 'plugins': 'plugin', 'addons': 'plugin', 'extensions': 'plugin',
66
- 'middlewares': 'middleware',
67
- 'helpers': 'helper', 'utilities': 'utils', 'util': 'utils',
68
- 'tool': 'tools', 'tooling': 'tools',
69
- 'resources': 'resource', 'res': 'resource', 'assets': 'resource', 'asset': 'resource',
70
- 'hooks': 'hook', 'composables': 'hook',
71
- 'mocks': 'mock', '__mocks__': 'mock', 'fixtures': 'mock', '__fixtures__': 'mock',
72
- 'logs': 'log',
73
- 'uploads': 'upload',
74
- 'function': 'functions', 'func': 'functions', 'fns': 'functions',
75
- 'services': 'server', 'service': 'server',
76
- 'component': 'components', 'comp': 'components', 'comps': 'components',
77
- 'controllers': 'controller',
78
- // 常见变体
79
- 'source': 'src', 'sources': 'src',
80
- 'distribution': 'dist', 'build': 'dist', 'builds': 'dist', 'out': 'dist', 'output': 'dist',
81
- 'documentation': 'docs', 'doc': 'docs', 'document': 'docs', 'documents': 'docs',
82
- 'static': 'public', 'statics': 'public', 'publics': 'public',
83
- 'libs': 'lib', 'library': 'lib', 'vendor': 'lib', 'vendors': 'lib',
84
- 'bin': 'scripts', 'binaries': 'scripts',
85
- 'tmp': 'temp', 'temporary': 'temp', 'cache': 'temp', 'caches': 'temp', '.cache': 'temp', '.turbo': 'temp',
86
- 'types': 'typescript', '@types': 'typescript', 'typings': 'typescript', 'dts': 'typescript',
87
- 'locales': 'i18n', 'locale': 'i18n', 'lang': 'i18n', 'languages': 'i18n', 'translations': 'i18n',
88
- 'db': 'database', 'databases': 'database', 'sql': 'database', 'queries': 'database',
89
- 'migration': 'migrations', 'seeds': 'seeders', 'seed': 'seeders',
90
- // 技术栈
91
- '.vscode': 'vscode',
92
- '.github': 'github',
93
- '.gitlab': 'gitlab',
94
- '.circleci': 'circleci',
95
- '.husky': 'husky',
96
- '.docker': 'docker',
97
- 'node_modules': 'node',
98
- 'scss': 'sass',
99
- 'renderer': 'client', 'frontend': 'client', 'web': 'client', 'webapp': 'client', 'website': 'client',
100
- 'backend': 'server', 'main': 'server',
101
- 'preload': 'scripts',
102
- '.idea': 'intellij',
103
- '.git': 'git',
104
- 'k8s': 'kubernetes', 'kube': 'kubernetes',
105
- 'mongo': 'database', 'mongodb': 'database', 'mysql': 'database', 'postgres': 'database',
106
- 'api': 'api', 'apis': 'api',
107
- 'interfaces': 'interface',
108
- 'notebook': 'jupyter', 'notebooks': 'jupyter', 'ipynb': 'jupyter',
109
- 'notification': 'messages', 'notifications': 'messages',
110
- 'env': 'environment', 'envs': 'environment',
111
- 'redux': 'redux-reducer', 'store': 'store', 'stores': 'store',
112
- 'electron': 'desktop',
113
- 'tauri': 'src-tauri',
114
- };
115
-
116
- /**
117
- * 根据文件夹名称获取对应的 material-icon-theme 图标名
118
- * @returns 图标名 或 undefined(让上层兜底默认图标)
119
- */
120
- export function getFolderTypeIcon(folderName: string): string | undefined {
121
- const name = (folderName || '').trim();
122
- if (!name) return undefined;
123
-
124
- const lower = name.replace(/[\\/]+$/, '').toLowerCase();
125
- const standardName = ALIASES[lower] ?? lower;
126
-
127
- if (KNOWN_TYPES.has(standardName)) {
128
- return `material-icon-theme:folder-${standardName}`;
129
- }
130
-
131
- return undefined;
132
- }