From bf6150879624b7846fade553bb8b1640d1fb5dfd Mon Sep 17 00:00:00 2001 From: pengxiaolong <15716207+pengxiaolong711@user.noreply.gitee.com> Date: Mon, 29 Sep 2025 20:45:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/hosts/hostsList.vue | 135 ++++++++++++++++++++++++++-------- 1 file changed, 103 insertions(+), 32 deletions(-) diff --git a/src/views/hosts/hostsList.vue b/src/views/hosts/hostsList.vue index 34585d4..c8611dd 100644 --- a/src/views/hosts/hostsList.vue +++ b/src/views/hosts/hostsList.vue @@ -17,7 +17,7 @@ size="large" style="width: 180px" type="number" - :disabled = "streamdialogVisibletext || isRunnings" + :disabled="streamdialogVisibletext || isRunnings" /> -
{{ streamdialogVisibletext ? '已指定直播间' : '指定直播间' }}
+ {{ streamdialogVisibletext ? "已指定直播间" : "指定直播间" }} +
当前网络:{{ countryData }}
-
- 运行时间:{{ String(hourstuo).padStart(2, '0') }}:{{ String(minutestuo).padStart(2, '0') }}:{{ String(secondstuo).padStart(2, '0') }} -
+
+ 运行时间:{{ String(hourstuo).padStart(2, "0") }}:{{ + String(minutestuo).padStart(2, "0") + }}:{{ String(secondstuo).padStart(2, "0") }} +
@@ -177,6 +184,23 @@ + + + +
@@ -354,7 +384,17 @@ import { color } from "echarts"; import { getCountryName } from "@/utils/countryUtil"; import { ElLoading } from "element-plus"; - +let longPressTimer = ref(null); +//长按进入直播间 +function handleLongPress(event) { + longPressTimer = setTimeout(() => { + openhostDisplayId(event); + }, 500); +} +//长按结束 +function resetTimer() { + clearTimeout(longPressTimer); +} //复制单元格内容 function handleCellDbClick(row, column, cell, event) { const text = cell?.textContent?.trim(); @@ -380,25 +420,22 @@ async function copyToClipboard(text) { }); return; } - // 备用方法:使用document.execCommand - const textarea = document.createElement('textarea'); + const textarea = document.createElement("textarea"); textarea.value = text; document.body.appendChild(textarea); textarea.select(); - - if (document.execCommand('copy')) { + if (document.execCommand("copy")) { ElMessage({ - type: "success", + type: "success", message: "复制成功", }); } else { - throw new Error('execCommand failed'); + throw new Error("execCommand failed"); } - document.body.removeChild(textarea); } catch (err) { - console.error('复制失败:', err); + console.error("复制失败:", err); ElMessage({ type: "error", message: "复制失败", @@ -406,7 +443,6 @@ async function copyToClipboard(text) { } } - //ip国家 let countryData = ref(""); //获取屏幕宽度 @@ -501,8 +537,7 @@ function specifyClick() { }); return; } - setStorageStreamId(textarea.value).then((res) => { - }); + setStorageStreamId(textarea.value).then((res) => {}); queryFormData.value.anchor_ids = textarea.value.split("\n"); streamdialogVisible.value = false; streamdialogVisibletext.value = true; @@ -512,13 +547,13 @@ function specifyClick() { function specifyreset() { textarea.value = ""; streamdialogVisibletext.value = false; - queryFormData.value.anchor_ids = [] + queryFormData.value.anchor_ids = []; } //指定直播间取消 function specifyCancel() { streamdialogVisible.value = false; streamdialogVisibletext.value = false; - queryFormData.value.anchor_ids = [] + queryFormData.value.anchor_ids = []; } //输入框input function handleInput() { @@ -536,7 +571,12 @@ function getBigBrother() { queryFormData.value.region = countryData.value; startTimerfun(); isRunnings.value = true; - if (queryFormData.value.anchor_ids == [] || queryFormData.value.anchor_ids == null || queryFormData.value.anchor_ids == undefined || queryFormData.value.anchor_ids.length == "") { + if ( + queryFormData.value.anchor_ids == [] || + queryFormData.value.anchor_ids == null || + queryFormData.value.anchor_ids == undefined || + queryFormData.value.anchor_ids.length == "" + ) { controlTask(JSON.stringify(queryFormData.value)).then((res) => { queryFormData.value.isRunning = false; timerId.value = setInterval(() => { @@ -569,7 +609,7 @@ const { getBrotherInfo, Specifystreaming, setStorageStreamId, - getStorageStreamId + getStorageStreamId, } = usePythonBridge(); let num = ref(0); @@ -620,6 +660,8 @@ let streamdialogVisible = ref(false); let textarea = ref(""); //计时器 let startTime = ref(null); +//筛选弹窗 +let filterdialogVisible = ref(false); //分配的员工 let staffId = ref({}); //备注信息 @@ -635,8 +677,11 @@ let options = ref([]); let version = ref("0.0.0"); +const lastVisibleTime = ref(null); + onMounted(() => { window.addEventListener("resize", handleResize); + window.addEventListener("visibilitychange", handleVisibilityChange); setTimeout(() => { getUserdata(); getStorageStreamId(1).then((res) => { @@ -645,6 +690,31 @@ onMounted(() => { }, 500); }); +onBeforeUnmount(() => { + window.removeEventListener("resize", handleResize); + window.removeEventListener("visibilitychange", handleVisibilityChange); +}); + +function handleVisibilityChange() { + if (isRunnings.value) { + if (document.hidden) { + // 页面变为不可见 + lastVisibleTime.value = Date.now(); + stopTimerfun(); + } else { + // 页面重新可见 + if (lastVisibleTime.value) { + const hiddenDuration = Math.floor((Date.now() - lastVisibleTime.value) / 1000); + secondstuo.value += hiddenDuration % 60; + minutestuo.value += Math.floor(hiddenDuration / 60) % 60; + hourstuo.value += Math.floor(hiddenDuration / 3600); + } + + startTimerfun(); + } + } +} + // 启动计时器 function startTimerfun() { startTime.value = setInterval(() => { @@ -660,13 +730,11 @@ function startTimerfun() { }, 1000); } - // 停止计时器 function stopTimerfun() { clearInterval(startTime.value); } - //表格单元格长度判断 function handleResize() { screenWidth.value = window.innerWidth / 11; @@ -807,6 +875,9 @@ function openHTML(id) { givePyAnchorId(id); } +function openhostDisplayId(hostDisplayId) { + givePyAnchorId(hostDisplayId); +}