添加按ALT键拖拽信号源自定义矩形开窗

This commit is contained in:
fangxiang 2022-04-28 15:48:10 +08:00
parent 03364ccbb9
commit ba04ab3f70
1 changed files with 136 additions and 107 deletions

View File

@ -701,9 +701,40 @@ export default defineComponent({
loga(a: any) { loga(a: any) {
console.log(a); console.log(a);
}, },
onDrop(e: DragEvent) { async onDrop(e: DragEvent) {
e.preventDefault(); e.preventDefault();
let target = e.target as any; let target = e.target as any;
//
const find_parent_dom = (dom: HTMLElement, classess: string[]) => {
let parent: HTMLElement | null = dom;
while (parent) {
if (parent) {
for (const clazz of classess) {
if (clazz) {
if (parent.classList.contains(clazz)) {
return parent;
}
}
}
parent = parent.parentElement;
} else {
break;
}
}
return parent;
};
if (target) {
const temp = find_parent_dom(target, [
"wall_item_flag",
"window_flag",
]);
if (temp) {
target = temp;
}
}
if (target) { if (target) {
target.classList.remove("drag-enter"); target.classList.remove("drag-enter");
} }
@ -726,8 +757,19 @@ export default defineComponent({
); );
{ {
const dom_element: HTMLElement | null = e.target as HTMLElement; const dom_element: HTMLElement | null = target as HTMLElement;
if (wall.value && dom_element) { if (wall.value && dom_element) {
let x = 0;
let y = 0;
let width = 0;
let height = 0;
let muted = true;
let volume = 20;
let paused = false;
let play_speed = 1;
let find_flag = false;
let find_window = 0;
if (dom_element.classList.contains("wall_item_flag")) { if (dom_element.classList.contains("wall_item_flag")) {
// //
const cell_width = 1 / $store.state.wall_col; const cell_width = 1 / $store.state.wall_col;
@ -747,44 +789,10 @@ export default defineComponent({
} }
} catch {} } catch {}
const x = col * cell_width; x = col * cell_width;
const y = row * cell_height; y = row * cell_height;
const width = cell_width; width = cell_width;
const height = cell_height; height = cell_height;
switch (type) {
case "polling":
GlobalData.getInstance()
.getCurrentClient()
?.openPolling(
new Protocol.OpenPollingRequestEntity(
uuid,
x,
y,
width,
height
)
);
break;
case "signal_source" /**OpenPollingRequestEntity */:
if (signal_sources.length) {
const signal_source = signal_sources[0];
if (signal_source) {
GlobalData.getInstance()
.getCurrentClient()
?.openWindow(
new Protocol.OpenWindowRequestEntity(
signal_source.uuid,
x,
y,
width,
height
)
);
}
}
break;
}
} else if (dom_element.classList.contains("window_flag")) { } else if (dom_element.classList.contains("window_flag")) {
// //
const rep_uuid = dom_element.getAttribute("uuid"); const rep_uuid = dom_element.getAttribute("uuid");
@ -793,15 +801,60 @@ export default defineComponent({
(item) => item.uuid == rep_uuid (item) => item.uuid == rep_uuid
); );
if (window) { if (window) {
let client = GlobalData.getInstance().getCurrentClient(); x = window.x;
if (client) { y = window.y;
let x = window.x; width = window.width;
let y = window.y; height = window.height;
let width = window.width; muted = window.muted;
let height = window.height; volume = window.volume;
paused = window.paused;
play_speed = window.play_speed;
find_window = window.window_id;
find_flag = true;
}
}
}
client.closeWindow(window.window_id); if (e.altKey) {
const open_window_request = if (window_rect_edit_dialog.value) {
try {
const result =
await window_rect_edit_dialog.value.showDialogAsync(
x * $store.state.device_screen_width,
y * $store.state.device_screen_height,
width * $store.state.device_screen_width,
height * $store.state.device_screen_height
);
if (result) {
x = result.x / $store.state.device_screen_width;
y = result.y / $store.state.device_screen_height;
width = result.width / $store.state.device_screen_width;
height =
result.height / $store.state.device_screen_height;
} else {
//
return;
}
} catch {
return;
}
}
}
if (find_flag) {
GlobalData.getInstance()
.getCurrentClient()
?.closeWindow(find_window);
}
setTimeout(() => {
if (!window) {
return;
}
switch (type) {
case "polling":
{
const open_polling_request =
new Protocol.OpenPollingRequestEntity( new Protocol.OpenPollingRequestEntity(
uuid, uuid,
x, x,
@ -809,67 +862,43 @@ export default defineComponent({
width, width,
height height
); );
open_window_request.muted = window.muted; open_polling_request.muted = muted;
open_window_request.volume = window.volume; open_polling_request.volume = volume;
open_window_request.paused = window.paused; open_polling_request.paused = paused;
open_window_request.play_speed = window.play_speed; open_polling_request.play_speed = play_speed;
GlobalData.getInstance()
setTimeout(() => { .getCurrentClient()
if (!window) { ?.openPolling(open_polling_request);
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);
}
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;
}
}, 50);
} }
}
break;
case "signal_source":
{
const open_window_request =
new Protocol.OpenWindowRequestEntity(
uuid,
x,
y,
width,
height
);
open_window_request.muted = muted;
open_window_request.volume = volume;
open_window_request.paused = paused;
open_window_request.play_speed = play_speed;
if (signal_sources.length) {
const signal_source = signal_sources[0];
if (signal_source) {
GlobalData.getInstance()
.getCurrentClient()
?.openWindow(open_window_request);
}
}
}
break;
} }
} }, 50);
} }
} }
} }