修复右键开窗时坐标计算失败的BUG

This commit is contained in:
fangxiang 2022-04-08 14:10:46 +08:00
parent 191793fbf3
commit f12879faa8
1 changed files with 80 additions and 101 deletions

View File

@ -771,55 +771,58 @@ export default defineComponent({
open_window_request.paused = window.paused; open_window_request.paused = window.paused;
open_window_request.play_speed = window.play_speed; open_window_request.play_speed = window.play_speed;
console.log(window); setTimeout(() => {
if (!window) {
return;
}
switch (type) {
case "polling":
{
const open_polling_request =
new Protocol.OpenPollingRequestEntity(
uuid,
x,
y,
width,
height
);
open_polling_request.muted = window.muted;
open_polling_request.volume = window.volume;
open_polling_request.paused = window.paused;
open_polling_request.play_speed =
window.play_speed;
GlobalData.getInstance()
.getCurrentClient()
?.openPolling(open_polling_request);
}
//setTimeout(() => { break;
switch (type) { case "signal_source":
case "polling": {
{ const open_window_request =
const open_polling_request = new Protocol.OpenWindowRequestEntity(
new Protocol.OpenPollingRequestEntity( uuid,
uuid, x,
x, y,
y, width,
width, height
height );
); open_window_request.muted = window.muted;
open_polling_request.muted = window.muted; open_window_request.volume = window.volume;
open_polling_request.volume = window.volume; open_window_request.paused = window.paused;
open_polling_request.paused = window.paused; open_window_request.play_speed =
open_polling_request.play_speed = window.play_speed; window.play_speed;
GlobalData.getInstance() if (signal_sources.length) {
.getCurrentClient() const signal_source = signal_sources[0];
?.openPolling(open_polling_request); if (signal_source) {
} client?.openWindow(open_window_request);
}
break;
case "signal_source":
{
const open_window_request =
new Protocol.OpenWindowRequestEntity(
uuid,
x,
y,
width,
height
);
open_window_request.muted = window.muted;
open_window_request.volume = window.volume;
open_window_request.paused = window.paused;
open_window_request.play_speed = window.play_speed;
if (signal_sources.length) {
const signal_source = signal_sources[0];
if (signal_source) {
client?.openWindow(open_window_request);
} }
} }
}
break; break;
} }
//}, 100); }, 50);
} }
} }
} }
@ -997,6 +1000,7 @@ export default defineComponent({
if (!wall.value) { if (!wall.value) {
return; return;
} }
const obj = await file_manage_dialog.value.showDialogAsync( const obj = await file_manage_dialog.value.showDialogAsync(
"select", "select",
".mp4;.avi;.ts;.jpg;.png;" ".mp4;.avi;.ts;.jpg;.png;"
@ -1032,22 +1036,19 @@ export default defineComponent({
const cell_width = 1.0 / $store.state.wall_col; const cell_width = 1.0 / $store.state.wall_col;
const cell_height = 1.0 / $store.state.wall_row; const cell_height = 1.0 / $store.state.wall_row;
const x = const col = Math.floor(
parseInt( last_context_menu_pos_x.value /
( wall.value.offsetWidth /
last_context_menu_pos_x.value / cell_width
wall.value.offsetWidth / );
cell_width const row = Math.floor(
).toFixed(0) last_context_menu_pos_y.value /
) * cell_width; wall.value.offsetHeight /
const y = cell_height
parseInt( );
(
last_context_menu_pos_y.value / const x = col * cell_width;
wall.value.offsetHeight / const y = row * cell_height;
cell_height
).toFixed(0)
) * cell_height;
if (!isNaN(x) && !isNaN(y)) { if (!isNaN(x) && !isNaN(y)) {
const open_window_request = const open_window_request =
@ -1114,49 +1115,27 @@ export default defineComponent({
.getCurrentClient() .getCurrentClient()
?.addSignalSource(entity); ?.addSignalSource(entity);
if (response && response.success) { if (response && response.success) {
const cell_width = 1.0 / $store.state.wall_col; const open_window_request =
const cell_height = 1.0 / $store.state.wall_row; new Protocol.OpenWindowRequestEntity(
response.uuid,
old_window.x,
old_window.y,
old_window.width,
old_window.height
);
const x = open_window_request.muted = old_window.muted;
parseInt( open_window_request.volume = old_window.volume;
( open_window_request.paused = old_window.paused;
last_context_menu_pos_x.value / open_window_request.play_speed = old_window.play_speed;
wall.value.offsetWidth /
cell_width
).toFixed(0)
) * cell_width;
const y =
parseInt(
(
last_context_menu_pos_y.value /
wall.value.offsetHeight /
cell_height
).toFixed(0)
) * cell_height;
if (!isNaN(x) && !isNaN(y)) { GlobalData.getInstance()
const open_window_request = .getCurrentClient()
new Protocol.OpenWindowRequestEntity( ?.closeWindow(old_window.window_id);
response.uuid,
old_window.x,
old_window.y,
old_window.width,
old_window.height
);
open_window_request.muted = old_window.muted; GlobalData.getInstance()
open_window_request.volume = old_window.volume; .getCurrentClient()
open_window_request.paused = old_window.paused; ?.openWindow(open_window_request);
open_window_request.play_speed = old_window.play_speed;
GlobalData.getInstance()
.getCurrentClient()
?.closeWindow(old_window.window_id);
GlobalData.getInstance()
.getCurrentClient()
?.openWindow(open_window_request);
}
} }
} catch {} } catch {}
} }