添加按ALT键拖拽信号源自定义矩形开窗
This commit is contained in:
parent
03364ccbb9
commit
ba04ab3f70
|
@ -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,26 +801,51 @@ 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) {
|
||||||
new Protocol.OpenPollingRequestEntity(
|
try {
|
||||||
uuid,
|
const result =
|
||||||
x,
|
await window_rect_edit_dialog.value.showDialogAsync(
|
||||||
y,
|
x * $store.state.device_screen_width,
|
||||||
width,
|
y * $store.state.device_screen_height,
|
||||||
height
|
width * $store.state.device_screen_width,
|
||||||
|
height * $store.state.device_screen_height
|
||||||
);
|
);
|
||||||
open_window_request.muted = window.muted;
|
if (result) {
|
||||||
open_window_request.volume = window.volume;
|
x = result.x / $store.state.device_screen_width;
|
||||||
open_window_request.paused = window.paused;
|
y = result.y / $store.state.device_screen_height;
|
||||||
open_window_request.play_speed = window.play_speed;
|
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(() => {
|
setTimeout(() => {
|
||||||
if (!window) {
|
if (!window) {
|
||||||
|
@ -829,11 +862,10 @@ export default defineComponent({
|
||||||
width,
|
width,
|
||||||
height
|
height
|
||||||
);
|
);
|
||||||
open_polling_request.muted = window.muted;
|
open_polling_request.muted = muted;
|
||||||
open_polling_request.volume = window.volume;
|
open_polling_request.volume = volume;
|
||||||
open_polling_request.paused = window.paused;
|
open_polling_request.paused = paused;
|
||||||
open_polling_request.play_speed =
|
open_polling_request.play_speed = play_speed;
|
||||||
window.play_speed;
|
|
||||||
GlobalData.getInstance()
|
GlobalData.getInstance()
|
||||||
.getCurrentClient()
|
.getCurrentClient()
|
||||||
?.openPolling(open_polling_request);
|
?.openPolling(open_polling_request);
|
||||||
|
@ -850,15 +882,16 @@ export default defineComponent({
|
||||||
width,
|
width,
|
||||||
height
|
height
|
||||||
);
|
);
|
||||||
open_window_request.muted = window.muted;
|
open_window_request.muted = muted;
|
||||||
open_window_request.volume = window.volume;
|
open_window_request.volume = volume;
|
||||||
open_window_request.paused = window.paused;
|
open_window_request.paused = paused;
|
||||||
open_window_request.play_speed =
|
open_window_request.play_speed = play_speed;
|
||||||
window.play_speed;
|
|
||||||
if (signal_sources.length) {
|
if (signal_sources.length) {
|
||||||
const signal_source = signal_sources[0];
|
const signal_source = signal_sources[0];
|
||||||
if (signal_source) {
|
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) {
|
onDragEnter(e: DragEvent) {
|
||||||
|
|
Loading…
Reference in New Issue