forked from open-webui/open-webui
		
	code style: npm run format
This commit is contained in:
		
							parent
							
								
									b8790200e9
								
							
						
					
					
						commit
						c8f7bb990c
					
				
					 1 changed files with 19 additions and 13 deletions
				
			
		|  | @ -97,25 +97,31 @@ export const getGravatarURL = (email) => { | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const generateInitialsImage = (name) => { | export const generateInitialsImage = (name) => { | ||||||
|     const canvas = document.createElement('canvas'); | 	const canvas = document.createElement('canvas'); | ||||||
|     const ctx = canvas.getContext('2d'); | 	const ctx = canvas.getContext('2d'); | ||||||
|     canvas.width = 100; | 	canvas.width = 100; | ||||||
|     canvas.height = 100; | 	canvas.height = 100; | ||||||
| 
 | 
 | ||||||
|     ctx.fillStyle = '#F39C12'; | 	ctx.fillStyle = '#F39C12'; | ||||||
|     ctx.fillRect(0, 0, canvas.width, canvas.height); | 	ctx.fillRect(0, 0, canvas.width, canvas.height); | ||||||
| 
 | 
 | ||||||
|     ctx.fillStyle = '#FFFFFF'; | 	ctx.fillStyle = '#FFFFFF'; | ||||||
|     ctx.font = '40px Helvetica'; | 	ctx.font = '40px Helvetica'; | ||||||
|     ctx.textAlign = 'center'; | 	ctx.textAlign = 'center'; | ||||||
|     ctx.textBaseline = 'middle'; | 	ctx.textBaseline = 'middle'; | ||||||
| 
 | 
 | ||||||
| 	const sanitizedName = name.trim(); | 	const sanitizedName = name.trim(); | ||||||
|     const initials = sanitizedName.length > 0 ? sanitizedName[0] + (sanitizedName.split(' ').length > 1 ? sanitizedName[sanitizedName.lastIndexOf(' ') + 1] : '') : ''; | 	const initials = | ||||||
|  | 		sanitizedName.length > 0 | ||||||
|  | 			? sanitizedName[0] + | ||||||
|  | 			  (sanitizedName.split(' ').length > 1 | ||||||
|  | 					? sanitizedName[sanitizedName.lastIndexOf(' ') + 1] | ||||||
|  | 					: '') | ||||||
|  | 			: ''; | ||||||
| 
 | 
 | ||||||
|     ctx.fillText(initials.toUpperCase(), canvas.width / 2, canvas.height / 2); | 	ctx.fillText(initials.toUpperCase(), canvas.width / 2, canvas.height / 2); | ||||||
| 
 | 
 | ||||||
|     return canvas.toDataURL(); | 	return canvas.toDataURL(); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const copyToClipboard = (text) => { | export const copyToClipboard = (text) => { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Danny Liu
						Danny Liu