mirror of
https://github.com/open-webui/open-webui
synced 2024-11-24 21:13:59 +00:00
refac
This commit is contained in:
parent
bc73cb1390
commit
f33ca4c9a5
@ -127,6 +127,41 @@
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
window.addEventListener('message', async (event) => {
|
||||
if (event.origin === window.origin) {
|
||||
// Replace with your iframe's origin
|
||||
console.log('Message received from iframe:', event.data);
|
||||
if (event.data.type === 'input:prompt') {
|
||||
console.log(event.data.text);
|
||||
|
||||
const inputElement = document.getElementById('chat-textarea');
|
||||
|
||||
if (inputElement) {
|
||||
prompt = event.data.text;
|
||||
inputElement.focus();
|
||||
}
|
||||
}
|
||||
|
||||
if (event.data.type === 'action:submit') {
|
||||
console.log(event.data.text);
|
||||
|
||||
if (prompt !== '') {
|
||||
await tick();
|
||||
submitPrompt(prompt);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.data.type === 'input:prompt:submit') {
|
||||
console.log(event.data.text);
|
||||
|
||||
if (prompt !== '') {
|
||||
await tick();
|
||||
submitPrompt(event.data.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!$chatId) {
|
||||
chatId.subscribe(async (value) => {
|
||||
if (!value) {
|
||||
|
@ -50,33 +50,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('message', (event) => {
|
||||
if (event.origin === window.origin) {
|
||||
// Replace with your iframe's origin
|
||||
console.log('Message received from iframe:', event.data);
|
||||
if (event.data.type === 'input:prompt') {
|
||||
console.log(event.data.text);
|
||||
|
||||
const inputElement = document.getElementById('chat-textarea');
|
||||
|
||||
if (inputElement) {
|
||||
inputElement.value = event.data.text;
|
||||
inputElement.focus();
|
||||
}
|
||||
}
|
||||
|
||||
if (event.data.type === 'action:submit-prompt') {
|
||||
console.log(event.data.text);
|
||||
|
||||
const submitButtonElement = document.getElementById('send-message-button');
|
||||
|
||||
if (submitButtonElement) {
|
||||
submitButtonElement.click();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('resize', onResize);
|
||||
|
||||
const setWakeLock = async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user