forked from open-webui/open-webui
		
	feat: response autocopy
This commit is contained in:
		
							parent
							
								
									47b7b63791
								
							
						
					
					
						commit
						6de9db6772
					
				
					 4 changed files with 186 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -52,6 +52,7 @@
 | 
			
		|||
	// Addons
 | 
			
		||||
	let titleAutoGenerate = true;
 | 
			
		||||
	let speechAutoSend = false;
 | 
			
		||||
	let responseAutoCopy = false;
 | 
			
		||||
 | 
			
		||||
	let gravatarEmail = '';
 | 
			
		||||
	let OPENAI_API_KEY = '';
 | 
			
		||||
| 
						 | 
				
			
			@ -123,6 +124,28 @@
 | 
			
		|||
		}
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	const toggleResponseAutoCopy = async () => {
 | 
			
		||||
		const permission = await navigator.clipboard
 | 
			
		||||
			.readText()
 | 
			
		||||
			.then(() => {
 | 
			
		||||
				return 'granted';
 | 
			
		||||
			})
 | 
			
		||||
			.catch(() => {
 | 
			
		||||
				return '';
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
		console.log(permission);
 | 
			
		||||
 | 
			
		||||
		if (permission === 'granted') {
 | 
			
		||||
			responseAutoCopy = !responseAutoCopy;
 | 
			
		||||
			saveSettings({ responseAutoCopy: responseAutoCopy });
 | 
			
		||||
		} else {
 | 
			
		||||
			toast.error(
 | 
			
		||||
				'Clipboard write permission denied. Please check your browser settings to grant the necessary access.'
 | 
			
		||||
			);
 | 
			
		||||
		}
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	const toggleAuthHeader = async () => {
 | 
			
		||||
		authEnabled = !authEnabled;
 | 
			
		||||
	};
 | 
			
		||||
| 
						 | 
				
			
			@ -319,6 +342,8 @@
 | 
			
		|||
		console.log(settings);
 | 
			
		||||
 | 
			
		||||
		theme = localStorage.theme ?? 'dark';
 | 
			
		||||
		notificationEnabled = settings.notificationEnabled ?? false;
 | 
			
		||||
 | 
			
		||||
		API_BASE_URL = settings.API_BASE_URL ?? OLLAMA_API_BASE_URL;
 | 
			
		||||
		system = settings.system ?? '';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -334,6 +359,8 @@
 | 
			
		|||
 | 
			
		||||
		titleAutoGenerate = settings.titleAutoGenerate ?? true;
 | 
			
		||||
		speechAutoSend = settings.speechAutoSend ?? false;
 | 
			
		||||
		responseAutoCopy = settings.responseAutoCopy ?? false;
 | 
			
		||||
 | 
			
		||||
		gravatarEmail = settings.gravatarEmail ?? '';
 | 
			
		||||
		OPENAI_API_KEY = settings.OPENAI_API_KEY ?? '';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -887,6 +914,28 @@
 | 
			
		|||
										</button>
 | 
			
		||||
									</div>
 | 
			
		||||
								</div>
 | 
			
		||||
 | 
			
		||||
								<div>
 | 
			
		||||
									<div class=" py-0.5 flex w-full justify-between">
 | 
			
		||||
										<div class=" self-center text-xs font-medium">
 | 
			
		||||
											Response AutoCopy to Clipboard
 | 
			
		||||
										</div>
 | 
			
		||||
 | 
			
		||||
										<button
 | 
			
		||||
											class="p-1 px-3 text-xs flex rounded transition"
 | 
			
		||||
											on:click={() => {
 | 
			
		||||
												toggleResponseAutoCopy();
 | 
			
		||||
											}}
 | 
			
		||||
											type="button"
 | 
			
		||||
										>
 | 
			
		||||
											{#if responseAutoCopy === true}
 | 
			
		||||
												<span class="ml-2 self-center">On</span>
 | 
			
		||||
											{:else}
 | 
			
		||||
												<span class="ml-2 self-center">Off</span>
 | 
			
		||||
											{/if}
 | 
			
		||||
										</button>
 | 
			
		||||
									</div>
 | 
			
		||||
								</div>
 | 
			
		||||
							</div>
 | 
			
		||||
 | 
			
		||||
							<hr class=" dark:border-gray-700" />
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue