mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-28 08:09:27 -05:00
refac
This commit is contained in:
1 parent
5beeb0cc29
commit
6b69a5b685
1 file changed
+23
-9
@@ -25,6 +25,8 @@
|
||||
let vncRetry: ReturnType<typeof setTimeout>;
|
||||
let width = 1024;
|
||||
let height = 768;
|
||||
let displayWidth = width;
|
||||
let displayHeight = height;
|
||||
let socket: WebSocket | null = null;
|
||||
let disposed = false;
|
||||
let retry: ReturnType<typeof setTimeout>;
|
||||
@@ -96,6 +98,9 @@
|
||||
if (!bounds.width || !bounds.height) return;
|
||||
width = mobile ? 390 : Math.max(240, Math.round(bounds.width));
|
||||
height = mobile ? 844 : Math.max(200, Math.round(bounds.height));
|
||||
const scale = Math.min(1, bounds.width / width, bounds.height / height);
|
||||
displayWidth = width * scale;
|
||||
displayHeight = height * scale;
|
||||
command('viewport', { width, height, mobile });
|
||||
};
|
||||
$: if (socket) command('visibility', { visible: active });
|
||||
@@ -279,18 +284,27 @@
|
||||
>
|
||||
{#if transport === 'vnc'}
|
||||
<div bind:this={vncSurface} class="vnc h-full w-full"></div>
|
||||
{:else if transport === 'frames'}
|
||||
<FrameCanvas bind:this={frames} />
|
||||
{:else if frame}<img
|
||||
src={frame}
|
||||
alt="Browser page"
|
||||
draggable="false"
|
||||
class="max-h-full max-w-full select-none"
|
||||
style:aspect-ratio={`${width}/${height}`}
|
||||
/>{/if}
|
||||
{:else if transport === 'frames' || frame}
|
||||
<!-- Stream resolution can differ from the page viewport, especially in personal Chrome. -->
|
||||
<div
|
||||
class="frame shrink-0"
|
||||
style:width={`${displayWidth}px`}
|
||||
style:height={`${displayHeight}px`}
|
||||
>
|
||||
{#if transport === 'frames'}
|
||||
<FrameCanvas bind:this={frames} />
|
||||
{:else}
|
||||
<img src={frame} alt="Browser page" draggable="false" class="h-full w-full select-none" />
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.frame :global(canvas) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.vnc > :global(div) {
|
||||
background: transparent !important;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user