添加按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) {
console.log(a);
},
onDrop(e: DragEvent) {
async onDrop(e: DragEvent) {
e.preventDefault();
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) {
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) {
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")) {
//
const cell_width = 1 / $store.state.wall_col;
@ -747,44 +789,10 @@ export default defineComponent({
}
} catch {}
const x = col * cell_width;
const y = row * cell_height;
const width = cell_width;
const 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;
}
x = col * cell_width;
y = row * cell_height;
width = cell_width;
height = cell_height;
} else if (dom_element.classList.contains("window_flag")) {
//
const rep_uuid = dom_element.getAttribute("uuid");
@ -793,26 +801,51 @@ export default defineComponent({
(item) => item.uuid == rep_uuid
);
if (window) {
let client = GlobalData.getInstance().getCurrentClient();
if (client) {
let x = window.x;
let y = window.y;
let width = window.width;
let height = window.height;
x = window.x;
y = window.y;
width = window.width;
height = window.height;
muted = window.muted;
volume = window.volume;
paused = window.paused;
play_speed = window.play_speed;
find_window = window.window_id;
find_flag = true;
}
}
}
client.closeWindow(window.window_id);
const open_window_request =
new Protocol.OpenPollingRequestEntity(
uuid,
x,
y,
width,
height
if (e.altKey) {
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
);
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 (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) {
@ -829,11 +862,10 @@ export default defineComponent({
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;
open_polling_request.muted = muted;
open_polling_request.volume = volume;
open_polling_request.paused = paused;
open_polling_request.play_speed = play_speed;
GlobalData.getInstance()
.getCurrentClient()
?.openPolling(open_polling_request);
@ -850,15 +882,16 @@ export default defineComponent({
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;
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) {
client?.openWindow(open_window_request);
GlobalData.getInstance()
.getCurrentClient()
?.openWindow(open_window_request);
}
}
}
@ -869,10 +902,6 @@ export default defineComponent({
}
}
}
}
}
}
}
},
onDragEnter(e: DragEvent) {