fix(mac-address-lookup): added copy handler on button click
This commit is contained in:
		
							parent
							
								
									74073f5038
								
							
						
					
					
						commit
						c311e3824d
					
				| @ -24,7 +24,7 @@ | |||||||
|     </n-form-item> |     </n-form-item> | ||||||
| 
 | 
 | ||||||
|     <n-space justify="center"> |     <n-space justify="center"> | ||||||
|       <c-button :disabled="!details"> Copy vendor info </c-button> |       <c-button :disabled="!details" @click="copy"> Copy vendor info </c-button> | ||||||
|     </n-space> |     </n-space> | ||||||
|   </div> |   </div> | ||||||
| </template> | </template> | ||||||
| @ -32,6 +32,7 @@ | |||||||
| <script setup lang="ts"> | <script setup lang="ts"> | ||||||
| import db from 'oui/oui.json'; | import db from 'oui/oui.json'; | ||||||
| import { macAddressValidation } from '@/utils/macAddress'; | import { macAddressValidation } from '@/utils/macAddress'; | ||||||
|  | import { useCopy } from '@/composable/copy'; | ||||||
| 
 | 
 | ||||||
| const getVendorValue = (address: string) => address.trim().replace(/[.:-]/g, '').toUpperCase().substring(0, 6); | const getVendorValue = (address: string) => address.trim().replace(/[.:-]/g, '').toUpperCase().substring(0, 6); | ||||||
| 
 | 
 | ||||||
| @ -39,6 +40,8 @@ const macAddress = ref('20:37:06:12:34:56'); | |||||||
| const details = computed<string | undefined>(() => db[getVendorValue(macAddress.value)]); | const details = computed<string | undefined>(() => db[getVendorValue(macAddress.value)]); | ||||||
| 
 | 
 | ||||||
| const { attrs: validationAttrs } = macAddressValidation(macAddress); | const { attrs: validationAttrs } = macAddressValidation(macAddress); | ||||||
|  | 
 | ||||||
|  | const { copy } = useCopy({ source: details, text: 'Vendor info copied to the clipboard' }); | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| <style lang="less" scoped></style> | <style lang="less" scoped></style> | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user