Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
SatelliteDigital
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
nijiawen
SatelliteDigital
Commits
367404c5
提交
367404c5
authored
4月 17, 2026
作者:
周欢凯
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新了时间的ws,加了参数
上级
a3943e16
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
83 行增加
和
51 行删除
+83
-51
timers.vue
src/pages/footer/component/timers.vue
+57
-27
requestSocektTime.js
src/utils/requestSocektTime.js
+26
-24
没有找到文件。
src/pages/footer/component/timers.vue
浏览文件 @
367404c5
...
...
@@ -106,12 +106,12 @@ import { ElLoading, ElMessage } from 'element-plus'
import
Loading
from
'@/pages/all/components/loadingComponent/index.js'
import
{
ref
,
onMounted
,
onUnmounted
,
computed
,
watch
,
nextTick
,
watchEffect
}
from
'vue'
;
import
wss
from
'@/utils/requestSocekt.js'
import
{
getTimewss
,
createWebSocket
}
from
'@/utils/requestSocektTime.js'
import
Timewss
from
'@/utils/requestSocektTime.js'
import
useAppStore
from
'@/store/module/app'
import
dayjs
from
'dayjs'
;
const
wssInstance
=
ref
(
wss
)
let
wsTimeInstance
=
""
;
//时间ws实例
const
wsTimeInstance
=
ref
(
Timewss
)
;
//时间ws实例
// import { loading } from 'vxe-pc-ui';
// 用于表示速度改变时,正常数据返回后才能够再次改变速度
const
speedChangedNormalDataBack
=
ref
(
false
)
...
...
@@ -247,8 +247,8 @@ const compareTime = (time1, time2) => {
};
const
wsTimeInstanceFn
=
()
=>
{
console
.
log
(
'架子啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊'
,
wsTimeInstance
);
wsTimeInstance
.
onmessage
=
(
event
)
=>
{
console
.
log
(
'架子啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊'
,
wsTimeInstance
.
value
);
(
wsTimeInstance
.
value
)
.
onmessage
=
(
event
)
=>
{
console
.
log
(
selectedEndTime
.
value
,
'时间对比------------------------'
);
const
data
=
JSON
.
parse
(
event
.
data
);
// console.log('data', data)
...
...
@@ -317,12 +317,12 @@ const wssMessageHandle = () => {
if
(
window
.
ue5
)
{
window
.
ue5
(
"callBackTimeFn"
,
String
(
JSON
.
stringify
({
isRealtime
:
true
,
replayTime
:
formatDateTime
(
selectedEndTime
.
value
),
//
replayTime: formatDateTime(selectedEndTime.value),
taskCode
:
String
(
taskCode_everyChange
.
value
)
===
""
?
useAppStoreInstance
.
globalRecordMainSysTaskCode
||
(
useAppStoreInstance
.
globalSubsystemTaskCode
)
:
String
(
taskCode_everyChange
.
value
),
speed
:
playbackSpeed
.
value
,
status
:
"continue"
,
// 通知 UE5 继续播放
})));
console
.
log
(
"SMOOTH类型,通知UE5继续播放"
);
console
.
log
(
"SMOOTH类型,通知UE5继续播放"
,
"callBackTimeFn"
);
}
}
}
else
if
(
data
.
type
===
'history'
)
{
...
...
@@ -518,6 +518,7 @@ const handleDateRangeChange = async (val, flag = false, RemoveSat, speed) => {
window
.
ue5
(
"RemoveSat"
,
String
(
JSON
.
stringify
({
Sat
:
true
,
})))
wsTimeInstanceOpen
(
false
);
}
else
{
localStorage
.
setItem
(
"is_flag_isRealtime"
,
true
);
}
...
...
@@ -579,7 +580,7 @@ const handleDateRangeChange = async (val, flag = false, RemoveSat, speed) => {
currentTime
:
(
formatDateTime
(
selectedEndTime
.
value
)),
status
:
isPlaying
.
value
?
"stop"
:
"continue"
,
})))
console
.
log
(
"走了这里3"
);
console
.
log
(
"走了这里3"
,
"callBackTimeFn"
);
}
}
else
{
...
...
@@ -864,7 +865,7 @@ const toggleAutoPlay = () => {
// status: isPlaying.value ? "continue" : "stop",
//时间参数
})))
console
.
log
(
"走了这里4"
);
console
.
log
(
"走了这里4"
,
"callBackTimeFn"
);
}
...
...
@@ -1211,7 +1212,7 @@ const endDrag = () => {
speed
:
playbackSpeed
.
value
,
status
:
isPlaying
.
value
?
"continue"
:
"stop"
,
})));
console
.
log
(
"走了这里5"
);
console
.
log
(
"走了这里5"
,
"callBackTimeFn"
);
}
else
{
window
.
ue5
(
"callBackTimeFn"
,
String
(
JSON
.
stringify
({
isRealtime
:
false
,
...
...
@@ -1220,7 +1221,7 @@ const endDrag = () => {
speed
:
playbackSpeed
.
value
,
status
:
isPlaying
.
value
?
"continue"
:
"stop"
,
})));
console
.
log
(
"走了这里6"
);
console
.
log
(
"走了这里6"
,
"callBackTimeFn"
);
wssOpenHandle
({
isRealtime
:
false
,
replayTime
:
formatDateTime
(
selectedEndTime
.
value
),
...
...
@@ -1343,13 +1344,7 @@ const resetclick = () => {
endDateTime
.
value
=
newTimeRange
[
1
];
selectedEndTime
.
value
=
now
;
// 滑块在100%位置对应当前时间
//变更为实时模式时重新建立链接获取开始和结束时间
if
(
wsTimeInstance
)
{
wsTimeInstance
.
close
()
}
createWebSocket
();
// console.log();
wsTimeInstance
=
getTimewss
()
// 更新 timeline 和选中时间显示
wsTimeInstanceOpen
(
true
);
nextTick
(()
=>
{
updateTimeline
();
updateSelectedTimes
();
...
...
@@ -1367,7 +1362,7 @@ const resetclick = () => {
window
.
ue5
(
"RemoveSat"
,
String
(
JSON
.
stringify
({
Sat
:
false
,
})))
console
.
log
(
"实时模式切换:发送UE5消息"
);
console
.
log
(
"实时模式切换:发送UE5消息"
,
"callBackTimeFn"
);
}
// 向后端发送实时模式消息
...
...
@@ -1379,17 +1374,45 @@ const resetclick = () => {
taskCode
:
String
(
taskCode_everyChange
.
value
)
===
""
?
useAppStoreInstance
.
globalRecordMainSysTaskCode
||
(
useAppStoreInstance
.
globalSubsystemTaskCode
)
:
String
(
taskCode_everyChange
.
value
),
});
}
const
wsTimeInstanceOpen
=
(
bool
)
=>
{
if
((
wsTimeInstance
.
value
).
readyState
===
WebSocket
.
OPEN
)
{
// 如果连接已打开,直接发送数据
(
wsTimeInstance
.
value
).
send
(
JSON
.
stringify
({
type
:
"SET_PUSH_STATUS"
,
status
:
bool
}));
// console.warn('WebSocket 已连接,无法发送数据:', data);
}
else
if
((
wsTimeInstance
.
value
).
readyState
===
WebSocket
.
CLOSED
)
{
const
oldUrl
=
(
wsTimeInstance
.
value
).
apiUrl
;
// 保存 URL
(
wsTimeInstance
.
value
)
=
new
WebSocket
(
oldUrl
);
// 重连时重新注册消息处理器
wsTimeInstanceFn
();
(
wsTimeInstance
.
value
).
onopen
=
()
=>
{
(
wsTimeInstance
.
value
).
send
(
JSON
.
stringify
({
type
:
"SET_PUSH_STATUS"
,
status
:
bool
}));
};
console
.
log
(
"发送数据1111"
);
}
else
{
// 否则等待连接打开后再发送
(
wsTimeInstance
.
value
).
onopen
=
()
=>
{
(
wsTimeInstance
.
value
).
send
(
JSON
.
stringify
({
type
:
"SET_PUSH_STATUS"
,
status
:
bool
}));
console
.
log
(
"发送数据2222"
);
};
}
};
const
tempDateTime
=
ref
(
new
Date
(
useAppStoreInstance
.
globalTimeLineEndSelectTime
))
onMounted
(()
=>
{
createWebSocket
();
// console.log();
wsTimeInstance
=
getTimewss
()
wsTimeInstanceFn
();
//接受实时模式下的数据
wssMessageHandle
();
// 只在初始化时注册一次消息处理器
//进入前时间
tempDateTime
.
value
=
""
console
.
log
(
useAppStoreInstance
.
footerTimeHasedSelectTimeToSub
,
'逻辑对比'
);
console
.
log
(
localStorage
.
getItem
(
"is_flag_isRealtime"
),
'跳转前模式'
);
console
.
log
(
localStorage
.
getItem
(
"is_flag_isRealtime"
),
'跳转前模式'
,
useAppStoreInstance
.
footerTimeHasedSelectTimeToSub
);
if
(
useAppStoreInstance
.
footerTimeHasedSelectTimeToSub
)
{
//判断是实时模式还是历史模式
is_flag_isRealtime
.
value
=
localStorage
.
getItem
(
"is_flag_isRealtime"
)
===
"true"
;
...
...
@@ -1401,6 +1424,8 @@ onMounted(() => {
if
(
!
is_flag_isRealtime
.
value
)
{
dateRange
.
value
=
[
new
Date
((
new
Date
(
useAppStoreInstance
.
globalSubsystemSelectedStartTime
[
0
]))).
toISOString
(),
new
Date
((
new
Date
(
useAppStoreInstance
.
globalSubsystemSelectedStartTime
[
1
]))).
toISOString
()]
pick_select_date
.
value
=
[
new
Date
(
dateRange
.
value
[
0
]).
toString
(),
new
Date
(
dateRange
.
value
[
1
]).
toString
()]
}
else
{
wsTimeInstanceOpen
(
false
);
}
{
//跳出判断,一直执行
...
...
@@ -1447,6 +1472,12 @@ onMounted(() => {
}
else
{
//实时模式
updateTimeline
();
wsTimeInstanceOpen
(
true
);
wsTimeInstanceFn
();
//接受实时模式下的数据
console
.
log
(
"初始化走下面"
);
if
(
window
.
ue5
)
{
window
.
ue5
(
"callBackTimeFn"
,
String
(
JSON
.
stringify
({
...
...
@@ -1455,13 +1486,12 @@ onMounted(() => {
speed
:
playbackSpeed
.
value
,
// status: isPlaying.value ? "continue" : "stop",
})))
console
.
log
(
"走了这里1"
);
console
.
log
(
"走了这里1"
,
"callBackTimeFn"
);
}
}
// useAppStoreInstance.setGlobalisFromTosub(false)
// ⚠️ 如果是从分系统返回,上面已经在 nextTick 里恢复了滑块和 wssOpenHandle
// 不能再调 realTimeData(),否则会生成新 taskCode、重置 WS,把之前的恢复全部覆盖
if
(
useAppStoreInstance
.
footerTimeHasedSelectTimeToSub
)
{
return
;
}
...
...
@@ -1505,7 +1535,7 @@ const realTimeData = () => {
//时间参数
})))
console
.
log
(
"走了这里2"
);
console
.
log
(
"走了这里2"
,
"callBackTimeFn"
);
}
...
...
@@ -1586,7 +1616,7 @@ onUnmounted(() => {
useAppStoreInstance
.
setGlobalIsRealtimeBeforeSub
(
is_flag_isRealtime
.
value
);
useAppStoreInstance
.
setGlobalSubsystemSelectedTimeRange
(
getDayRangeFromTime
(
useAppStoreInstance
.
globalTimeLineEndSelectTime
));
console
.
log
(
is_flag_isRealtime
.
value
,
'判断状态'
);
wsTimeInstance
.
close
()
//
wsTimeInstance.close()
// is_flag_isRealtime--true代表实时模式,false--代表历史模式
//console.log("jieshuli 1,组件卸载时要发暂停",getDayRangeFromTime(useAppStoreInstance.globalTimeLineEndSelectTime)[0],getDayRangeFromTime(useAppStoreInstance.globalTimeLineEndSelectTime)[1]);
// 储存跳转前的模式--实时模式-true,还是历史模式-false
...
...
src/utils/requestSocektTime.js
浏览文件 @
367404c5
...
...
@@ -6,51 +6,53 @@ let Timewss = null;
let
timer
=
null
;
const
appStore
=
useAppStore
();
function
createWebSocket
(
options
=
{}
)
{
if
(
Timewss
&&
Timewss
.
readyState
===
WebSocket
.
OPEN
)
{
console
.
log
(
'TimeWebSocket已连接,无需重复创建'
);
// 如果有新传入的 onmessage,更新它
if
(
options
.
onmessage
)
{
Timewss
.
onmessage
=
options
.
onmessage
;
}
return
Timewss
;
}
function
createWebSocket
()
{
//
if (Timewss && Timewss.readyState === WebSocket.OPEN) {
//
console.log('TimeWebSocket已连接,无需重复创建');
//
// 如果有新传入的 onmessage,更新它
//
if (options.onmessage) {
//
Timewss.onmessage = options.onmessage;
//
}
//
return Timewss;
//
}
Timewss
=
new
WebSocket
(
apiUrl
);
Timewss
.
onopen
=
()
=>
{
console
.
log
(
'TimeWebSocket已连接'
);
options
.
onopen
?.();
};
Timewss
.
onmessage
=
(
event
)
=>
{
console
.
log
(
'Time接收到消息:'
,
event
.
data
);
options
.
onmessage
?.(
event
);
//
options.onmessage?.(event);
};
Timewss
.
onerror
=
(
error
)
=>
{
console
.
error
(
'WebSocket错误:'
,
error
);
options
.
onerror
?.(
error
);
//
options.onerror?.(error);
};
Timewss
.
onclose
=
()
=>
{
console
.
log
(
'连接关闭,1秒后重连...'
);
timer
=
setTimeout
(()
=>
{
createWebSocket
(
options
);
// 重新创建连接,保留回调
Timewss
=
createWebSocket
(
);
// 重新创建连接,保留回调
clearTimeout
(
timer
);
timer
=
null
;
},
1000
);
};
return
Timewss
;
//
return Timewss;
}
// 获取当前 WebSocket 实例
function
getTimewss
()
{
return
Timewss
;
// 初始化连接
if
(
!
Timewss
||
Timewss
.
readyState
===
WebSocket
.
CLOSED
)
{
createWebSocket
();
}
export
{
createWebSocket
,
getTimewss
};
\ No newline at end of file
// 获取当前 WebSocket 实例
// function getTimewss() {
// return Timewss;
// }
export
default
Timewss
;
// export {
// createWebSocket,
// getTimewss
// };
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论