This commit is contained in:
2024-11-24 18:03:06 +00:00
parent 641938f7e4
commit 16ba22d90b
39 changed files with 76 additions and 254 deletions

View File

@@ -32,20 +32,14 @@
</AppLayout>
</template>
<script setup lang="ts">
import FileManager from '../../components/FileManager/FileManager.vue';
import type { FileWithMeta } from '../../model/FileManager';
import {ref, inject, watch} from 'vue';
import {SenderSymbol} from '../../model/injectionSymbols';
import Tabs from '../../components/Tabs.vue';
import {VirtualFile} from '../../model/FileSystem/types';
import ScreenManager from '../../components/ScreenManager/ScreenManager.vue';
import RemoteDevices from '../../components/RemoteDevices/RemoteDevices.vue';
import Soundboard from '../../components/Audio/Soundboard.vue';
import FilesAside from '../../components/Files/FilesAside.vue';
import MapControl from '../../components/Map/MapControl.vue';
import AppLayout from '../../components/Common/AppLayout.vue';
const openedFile = ref<FileWithMeta>()
const sender = inject(SenderSymbol);
const imageWidth = ref(20);
@@ -78,66 +72,6 @@ watch(() => [positionX.value, positionY.value, flipped.value], () => {
})
});
function openFile(file: VirtualFile) {
console.log('openFile', file);
// sender?.sendMessage({
// type: 'showFile',
// file,
// })
// imageWidth.value = file.width ?? 20;
// openedFile.value = file;
}
function openMapWindow() {
window.open('/map/', 'map');
}
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
function onStreamImage() {
if (!openedFile.value?.path) {
return;
}
const image = new Image()
image.onload = async () => {
const canvas = document.createElement('canvas');
canvas.setAttribute('willReadFrequently', 'true');
canvas.width = image.width;
canvas.height = image.height;
const [maxWidth, maxHeight] = (image.width > image.height) ? [3840, 2160] : [2160, 3840];
if (image.width > maxWidth || image.height > maxHeight) {
const ratio = Math.min(maxWidth / image.width, maxHeight / image.height);
canvas.width = image.width * ratio;
canvas.height = image.height * ratio;
}
const ctx = canvas.getContext('2d')!;
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
const chunkSize = {width: 128, height: 128};
for (let x = 0; x < canvas.width; x += chunkSize.width) {
for (let y = 0; y < canvas.height; y += chunkSize.height) {
const imageData = ctx.getImageData(x, y, chunkSize.width, chunkSize.height);
sender?.sendMessage({
type: 'streamImage',
imageData: {
data: [...new Uint32Array(imageData.data.buffer)],
width: imageData.width,
height: imageData.height,
},
canvas: {
width: canvas.width,
height: canvas.height,
},
x,
y,
}, {webRTC: true});
await delay(100);
}
}
};
image.src = openedFile.value?.path;
}
</script>
<style>
.aside {

View File

@@ -6,10 +6,8 @@
</div>
</template>
<script setup lang="ts">
import {inject, ref} from 'vue';
import Debug from './Debug.vue';
import {inject} from 'vue';
import {WebRtcChannelSymbol} from '../../model/injectionSymbols';
import {VirtualFile} from '../../model/FileSystem/types';
const webRtc = inject(WebRtcChannelSymbol)!;
@@ -27,6 +25,7 @@ function sendScreenInfo() {
function sendAudioInfo() {
const ac = new AudioContext();
webRtc.send({
// @ts-ignore
type: 'audioInfo',
channels: ac.destination.channelCount,
channelInterpretation: ac.destination.channelInterpretation,
@@ -45,28 +44,7 @@ webRtc.on((message) => {
} else if (message.type === 'connected') {
sendScreenInfo();
sendAudioInfo();
} else if (message.type === 'fileTransfered') {
/*debugger;
const key = fileToKey(message.meta);
cachedFiles.set(key, message.blob);*/
} else if (message.type === 'showFile') {
/*debugger;
const key = fileToKey(message.file);
const blob = cachedFiles.get(key);
if (blob) {
const url = URL.createObjectURL(blob);
const img = new Image();
img.onload = () => {
const ctx = canvas.value!.getContext('2d')!;
canvas.value!.width = img.width;
canvas.value!.height = img.height;
ctx.drawImage(img, 0, 0);
}
img.src = url;
}*/
} else if (message.type === 'transform') {
// canvas.value.style = `max-width: 100%;transform: scale(${message.scale}) translate(${message.x}%, ${message.y}%);transition: transform 100ms;`;
}
}
});
</script>