添加按ALT键拖拽信号源自定义矩形开窗
This commit is contained in:
parent
03364ccbb9
commit
ba04ab3f70
|
@ -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,15 +801,60 @@ 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 =
|
||||
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
|
||||
);
|
||||
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(
|
||||
uuid,
|
||||
x,
|
||||
|
@ -809,67 +862,43 @@ 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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue