refactor(uuid-generator): prevent NaN in quantity
This commit is contained in:
		
							parent
							
								
									7d7cc99866
								
							
						
					
					
						commit
						6fb4994603
					
				| @ -1,40 +1,36 @@ | |||||||
| <template> | <template> | ||||||
|   <div> |   <n-space vertical :size="20"> | ||||||
|     <n-card> |     <n-space align="center" justify="center"> | ||||||
|       <n-space align="center" justify="center"> |       Quantity : | ||||||
|         Quantity : |       <n-input-number v-model:value="count" :min="1" :max="50" placeholder="UUID quantity" /> | ||||||
|         <n-input-number v-model:value="count" :min="1" :max="50" /> |     </n-space> | ||||||
|       </n-space> | 
 | ||||||
|       <br /> |     <n-input | ||||||
|       <n-input |       style="text-align: center; font-family: monospace" | ||||||
|         style="text-align: center; font-family: monospace" |       :value="uuids" | ||||||
|         :value="uuids" |       type="textarea" | ||||||
|         type="textarea" |       placeholder="Your uuids" | ||||||
|         placeholder="Your uuids" |       :autosize="{ minRows: 1 }" | ||||||
|         :autosize="{ minRows: 1 }" |       readonly | ||||||
|         readonly |       autocomplete="off" | ||||||
|         autocomplete="off" |       autocorrect="off" | ||||||
|         autocorrect="off" |       autocapitalize="off" | ||||||
|         autocapitalize="off" |       spellcheck="false" | ||||||
|         spellcheck="false" |     /> | ||||||
|       /> | 
 | ||||||
|       <br /> |     <n-space justify="center"> | ||||||
|       <br /> |       <n-button secondary autofocus @click="copy"> Copy </n-button> | ||||||
|       <n-space justify="center"> |       <n-button secondary @click="refreshUUIDs"> Refresh </n-button> | ||||||
|         <n-button secondary autofocus @click="copy"> Copy </n-button> |     </n-space> | ||||||
|         <n-button secondary @click="refreshUUIDs"> Refresh </n-button> |   </n-space> | ||||||
|       </n-space> |  | ||||||
|     </n-card> |  | ||||||
|   </div> |  | ||||||
| </template> | </template> | ||||||
| 
 | 
 | ||||||
| <script setup lang="ts"> | <script setup lang="ts"> | ||||||
| import { useCopy } from '@/composable/copy'; | import { useCopy } from '@/composable/copy'; | ||||||
| import { v4 as generateUUID } from 'uuid'; | import { v4 as generateUUID } from 'uuid'; | ||||||
| import { useQueryParam } from '@/composable/queryParams'; |  | ||||||
| import { computedRefreshable } from '@/composable/computedRefreshable'; | import { computedRefreshable } from '@/composable/computedRefreshable'; | ||||||
| 
 | 
 | ||||||
| const count = useQueryParam({ defaultValue: 1, name: 'count' }); | const count = useStorage('uuid-generator:quantity', 1); | ||||||
| 
 | 
 | ||||||
| const [uuids, refreshUUIDs] = computedRefreshable(() => | const [uuids, refreshUUIDs] = computedRefreshable(() => | ||||||
|   Array.from({ length: count.value }, () => generateUUID()).join('\n'), |   Array.from({ length: count.value }, () => generateUUID()).join('\n'), | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user