Merge 7c12c12e21 into e876d03608
				
					
				
			This commit is contained in:
		
						commit
						ac6cb137be
					
				
							
								
								
									
										6
									
								
								components.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								components.d.ts
									
									
									
									
										vendored
									
									
								
							| @ -78,6 +78,7 @@ declare module '@vue/runtime-core' { | ||||
|     Encryption: typeof import('./src/tools/encryption/encryption.vue')['default'] | ||||
|     EtaCalculator: typeof import('./src/tools/eta-calculator/eta-calculator.vue')['default'] | ||||
|     FavoriteButton: typeof import('./src/components/FavoriteButton.vue')['default'] | ||||
|     FileType: typeof import('./src/tools/file-type/file-type.vue')['default'] | ||||
|     FormatTransformer: typeof import('./src/components/FormatTransformer.vue')['default'] | ||||
|     GitMemo: typeof import('./src/tools/git-memo/git-memo.vue')['default'] | ||||
|     'GitMemo.content': typeof import('./src/tools/git-memo/git-memo.content.md')['default'] | ||||
| @ -130,21 +131,18 @@ declare module '@vue/runtime-core' { | ||||
|     NCode: typeof import('naive-ui')['NCode'] | ||||
|     NCollapseTransition: typeof import('naive-ui')['NCollapseTransition'] | ||||
|     NConfigProvider: typeof import('naive-ui')['NConfigProvider'] | ||||
|     NDivider: typeof import('naive-ui')['NDivider'] | ||||
|     NEllipsis: typeof import('naive-ui')['NEllipsis'] | ||||
|     NFormItem: typeof import('naive-ui')['NFormItem'] | ||||
|     NGi: typeof import('naive-ui')['NGi'] | ||||
|     NGrid: typeof import('naive-ui')['NGrid'] | ||||
|     NH1: typeof import('naive-ui')['NH1'] | ||||
|     NH3: typeof import('naive-ui')['NH3'] | ||||
|     NIcon: typeof import('naive-ui')['NIcon'] | ||||
|     NInputNumber: typeof import('naive-ui')['NInputNumber'] | ||||
|     NLabel: typeof import('naive-ui')['NLabel'] | ||||
|     NLayout: typeof import('naive-ui')['NLayout'] | ||||
|     NLayoutSider: typeof import('naive-ui')['NLayoutSider'] | ||||
|     NMenu: typeof import('naive-ui')['NMenu'] | ||||
|     NScrollbar: typeof import('naive-ui')['NScrollbar'] | ||||
|     NSpin: typeof import('naive-ui')['NSpin'] | ||||
|     NSwitch: typeof import('naive-ui')['NSwitch'] | ||||
|     NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default'] | ||||
|     OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default'] | ||||
|     PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default'] | ||||
|  | ||||
| @ -60,6 +60,7 @@ | ||||
|     "emojilib": "^3.0.10", | ||||
|     "figlet": "^1.7.0", | ||||
|     "figue": "^1.2.0", | ||||
|     "file-type": "^19.0.0", | ||||
|     "fuse.js": "^6.6.2", | ||||
|     "highlight.js": "^11.7.0", | ||||
|     "iarna-toml-esm": "^3.0.5", | ||||
| @ -86,6 +87,7 @@ | ||||
|     "unicode-emoji-json": "^0.4.0", | ||||
|     "unplugin-auto-import": "^0.16.4", | ||||
|     "uuid": "^9.0.0", | ||||
|     "vite-plugin-node-polyfills": "^0.21.0", | ||||
|     "vue": "^3.3.4", | ||||
|     "vue-i18n": "^9.9.1", | ||||
|     "vue-router": "^4.1.6", | ||||
|  | ||||
							
								
								
									
										764
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										764
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										76
									
								
								src/tools/file-type/file-type.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								src/tools/file-type/file-type.vue
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,76 @@ | ||||
| <script setup lang="ts"> | ||||
| import type { FileTypeResult } from 'file-type'; | ||||
| import { fileTypeFromBuffer } from 'file-type'; | ||||
| import InputCopyable from '../../components/InputCopyable.vue'; | ||||
| 
 | ||||
| const status = ref<'idle' | 'done' | 'error' | 'processing'>('idle'); | ||||
| const file = ref<File | null>(null); | ||||
| const type = ref<FileTypeResult | undefined>(undefined); | ||||
| 
 | ||||
| async function onFileUploaded(uploadedFile: File) { | ||||
|   file.value = uploadedFile; | ||||
|   const fileBuffer = await uploadedFile.arrayBuffer(); | ||||
| 
 | ||||
|   status.value = 'processing'; | ||||
|   try { | ||||
|     type.value = await fileTypeFromBuffer(new Uint8Array(fileBuffer.slice(0, 4096))); | ||||
|     status.value = 'done'; | ||||
|   } | ||||
|   catch (e) { | ||||
|     status.value = 'error'; | ||||
|   } | ||||
| } | ||||
| </script> | ||||
| 
 | ||||
| <template> | ||||
|   <div> | ||||
|     <div style="flex: 0 0 100%" mb-3> | ||||
|       <div mx-auto max-w-600px> | ||||
|         <c-file-upload | ||||
|           title="Drag and drop a file here, or click to select a file" | ||||
|           @file-upload="onFileUploaded" | ||||
|         /> | ||||
|       </div> | ||||
|     </div> | ||||
| 
 | ||||
|     <div mt-3 flex justify-center> | ||||
|       <c-card v-if="status === 'done'" title="Information"> | ||||
|         <InputCopyable | ||||
|           :value="file?.name || ''" | ||||
|           label="File name:" | ||||
|           label-position="left" | ||||
|           label-width="100px" | ||||
|           label-align="right" | ||||
|           readonly | ||||
|           mt-2 | ||||
|         /> | ||||
| 
 | ||||
|         <InputCopyable | ||||
|           :value="type?.ext || '<unknown>'" | ||||
|           label="Extension:" | ||||
|           label-position="left" | ||||
|           label-width="100px" | ||||
|           label-align="right" | ||||
|           readonly | ||||
|           mt-2 | ||||
|         /> | ||||
|         <InputCopyable | ||||
|           :value="type?.mime || '<unknown>'" | ||||
|           label="MIME Type:" | ||||
|           label-position="left" | ||||
|           label-width="100px" | ||||
|           label-align="right" | ||||
|           readonly | ||||
|           mt-2 | ||||
|         /> | ||||
|       </c-card> | ||||
|       <c-alert v-if="status === 'error'" type="error"> | ||||
|         An error occured processing {{ file?.name }}. | ||||
|       </c-alert> | ||||
|       <n-spin | ||||
|         v-if="status === 'processing'" | ||||
|         size="small" | ||||
|       /> | ||||
|     </div> | ||||
|   </div> | ||||
| </template> | ||||
							
								
								
									
										12
									
								
								src/tools/file-type/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/tools/file-type/index.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | ||||
| import { File } from '@vicons/tabler'; | ||||
| import { defineTool } from '../tool'; | ||||
| 
 | ||||
| export const tool = defineTool({ | ||||
|   name: 'File Type Detector', | ||||
|   path: '/file-type', | ||||
|   description: 'Identify the type of a file', | ||||
|   keywords: ['file', 'type', 'identify', 'detector'], | ||||
|   component: () => import('./file-type.vue'), | ||||
|   icon: File, | ||||
|   createdAt: new Date('2024-04-20'), | ||||
| }); | ||||
| @ -6,6 +6,7 @@ import { tool as asciiTextDrawer } from './ascii-text-drawer'; | ||||
| 
 | ||||
| import { tool as textToUnicode } from './text-to-unicode'; | ||||
| import { tool as safelinkDecoder } from './safelink-decoder'; | ||||
| import { tool as fileType } from './file-type'; | ||||
| import { tool as pdfSignatureChecker } from './pdf-signature-checker'; | ||||
| import { tool as numeronymGenerator } from './numeronym-generator'; | ||||
| import { tool as macAddressGenerator } from './mac-address-generator'; | ||||
| @ -148,6 +149,7 @@ export const toolsByCategory: ToolCategory[] = [ | ||||
|       dockerRunToDockerComposeConverter, | ||||
|       xmlFormatter, | ||||
|       yamlViewer, | ||||
|       fileType, | ||||
|     ], | ||||
|   }, | ||||
|   { | ||||
|  | ||||
| @ -15,6 +15,7 @@ import { VitePWA } from 'vite-plugin-pwa'; | ||||
| import markdown from 'vite-plugin-vue-markdown'; | ||||
| import svgLoader from 'vite-svg-loader'; | ||||
| import { configDefaults } from 'vitest/config'; | ||||
| import { nodePolyfills } from 'vite-plugin-node-polyfills' | ||||
| 
 | ||||
| const baseUrl = process.env.BASE_URL ?? '/'; | ||||
| 
 | ||||
| @ -97,6 +98,7 @@ export default defineConfig({ | ||||
|       resolvers: [NaiveUiResolver(), IconsResolver({ prefix: 'icon' })], | ||||
|     }), | ||||
|     Unocss(), | ||||
|     nodePolyfills(), | ||||
|   ], | ||||
|   base: baseUrl, | ||||
|   resolve: { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user