mirror of
https://github.com/open-webui/computer.git
synced 2026-11-22 21:50:43 -05:00
refac
This commit is contained in:
1 parent
7f333407f2
commit
64eb831b61
3 files changed
+22
-5
No files matched your search
@@ -63,7 +63,9 @@
|
||||
function resizeImage(file: File): Promise<Blob> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const img = new Image();
|
||||
const url = URL.createObjectURL(file);
|
||||
img.onload = () => {
|
||||
URL.revokeObjectURL(url);
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = 256;
|
||||
canvas.height = 256;
|
||||
@@ -80,8 +82,11 @@
|
||||
'image/png'
|
||||
);
|
||||
};
|
||||
img.onerror = () => reject(new Error('Failed to load image'));
|
||||
img.src = URL.createObjectURL(file);
|
||||
img.onerror = () => {
|
||||
URL.revokeObjectURL(url);
|
||||
reject(new Error('Failed to load image'));
|
||||
};
|
||||
img.src = url;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
let fitAddon: FitAddon | null = null;
|
||||
let ws: WebSocket | null = null;
|
||||
let resizeObserver: ResizeObserver | null = null;
|
||||
let themeObserver: MutationObserver | null = null;
|
||||
let resizeTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||
let reconnectTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
let destroyed = false;
|
||||
@@ -262,12 +263,12 @@
|
||||
});
|
||||
|
||||
// Watch for theme changes
|
||||
const observer = new MutationObserver(() => {
|
||||
themeObserver = new MutationObserver(() => {
|
||||
if (term) {
|
||||
term.options.theme = terminalTheme();
|
||||
}
|
||||
});
|
||||
observer.observe(document.documentElement, {
|
||||
themeObserver.observe(document.documentElement, {
|
||||
attributes: true,
|
||||
attributeFilter: ['class', 'style']
|
||||
});
|
||||
@@ -506,8 +507,14 @@
|
||||
if (reconnectTimer) clearTimeout(reconnectTimer);
|
||||
if (hapticTimer) clearTimeout(hapticTimer);
|
||||
resizeObserver?.disconnect();
|
||||
themeObserver?.disconnect();
|
||||
releaseWakeLock();
|
||||
ws?.close();
|
||||
if (ws) {
|
||||
ws.onmessage = null;
|
||||
ws.onclose = null;
|
||||
ws.onerror = null;
|
||||
ws.close();
|
||||
}
|
||||
term?.dispose();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1721,6 +1721,11 @@
|
||||
showTtsFailure(err?.message || 'playback failed');
|
||||
}
|
||||
} finally {
|
||||
if (generation === ttsGeneration && ttsObjectUrl) {
|
||||
URL.revokeObjectURL(ttsObjectUrl);
|
||||
ttsObjectUrl = null;
|
||||
}
|
||||
if (generation === ttsGeneration) ttsAudio = null;
|
||||
if (generation === ttsGeneration) ttsPlaying = false;
|
||||
if (generation === ttsGeneration) speakingMessageId = null;
|
||||
if (generation === ttsGeneration) ttsStopRequested = false;
|
||||
|
||||
Reference in new issue
Block a user