优化UI+适配

This commit is contained in:
renna 2025-06-13 14:12:32 +08:00
parent 4f66210e77
commit e1e4233c1e
84 changed files with 1580 additions and 6254 deletions

View File

@ -5,14 +5,13 @@ VITE_APP_ENV = 'development'
# base_url
# VITE_APP_BASE_URL='/api'
VITE_APP_BASE_URL='https://apifoxmock.com/m1/4400256-4044831-default'
VITE_APP_BASE_API='http://10.0.202:9123'
#可安可I接口地址
VITE_APP_CONCOAI_API='https://rest.concoai.com'
#孪生UI接口地址
VITE_APP_TWIN_URL='https://apifoxmock.com/m1/4400256-4044831-default'
# MQTT
VITE_APP_MQTT_URL='ws://127.0.0.1:8083/mqtt'
VITE_APP_TITLE='可安可机器人'

View File

@ -6,15 +6,11 @@ VITE_APP_ENV = 'production'
# 地址替换时间20250427
# base_url
# VITE_APP_BASE_URL='http://192.168.20.251'
VITE_APP_BASE_URL='http://180.51.12.4'
VITE_APP_BASE_API='http://10.0.202:9123'
# 可安可
VITE_APP_CONCOAI_API='https://rest.concoai.com'
# MQTT
# VITE_APP_MQTT_URL='ws://192.168.20.251:30099/mqtt'
VITE_APP_MQTT_URL='ws://180.51.12.4:30099/mqtt'
#孪生UI接口地址
# VITE_APP_TWIN_URL='http://192.168.20.251'
VITE_APP_TWIN_URL='http://180.51.12.4'
VITE_APP_TITLE='可安可机器人'

View File

@ -86,19 +86,6 @@ npm run build
2. 项目使用 Vue 3 Composition API需要相应的开发工具支持
3. 建议使用 VSCode 进行开发,并安装 Volar 插件
## 样式规范
- 主要颜色:
- 背景色rgba(0, 21, 31, 0.3)
- 边框色rgba(0, 206, 234, 0.7)
- 文字色:#B9E8FF
- 告警红色:#F33F3F
- 正常绿色:#00FF84
- 布局:
- 采用 flex 和 grid 布局
- 响应式设计,适配不同尺寸屏幕
- 统一的间距和边框圆角
## 更新日志
@ -108,13 +95,3 @@ npm run build
- 完成告警管理系统
- 支持多路视频监控
{
"clientip": "{\"osName\":\"Windows\",\"osVersion\":\"10\",\"browserName\":\"Chrome\",\"browserVersion\":\"137.0.0.0\",\"SDK_VERSION\":\"1.0.9\"}",
"sdp": "v=0\r\no=...", // SDP内容
"streamurl": "webrtc://qvs-live.thirdmonitor.concoai.com:447/2xenzwqy2ppcl/31011500991180041301_34020000001320000001"
}
计划修改:
CarouselVideoPlayer修改逻辑 找不到流的时候 页面显示空状态 也进行轮播 而不是找不到匹配的视角或视角没有流,找第一个有效视角

48
package-lock.json generated
View File

@ -18,6 +18,7 @@
"devDependencies": {
"@vitejs/plugin-vue": "^4.2.3",
"dotenv": "^16.5.0",
"postcss-px-to-viewport": "^1.1.1",
"sass": "^1.89.0",
"vite": "^4.4.5"
}
@ -1419,10 +1420,19 @@
"dev": true,
"optional": true
},
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmmirror.com/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/picocolors": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ=="
"version": "1.1.1",
"resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.1.1.tgz",
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="
},
"node_modules/picomatch": {
"version": "2.3.1",
@ -1475,6 +1485,16 @@
"node": "^10 || ^12 || >=14"
}
},
"node_modules/postcss-px-to-viewport": {
"version": "1.1.1",
"resolved": "https://registry.npmmirror.com/postcss-px-to-viewport/-/postcss-px-to-viewport-1.1.1.tgz",
"integrity": "sha512-2x9oGnBms+e0cYtBJOZdlwrFg/mLR4P1g2IFu7jYKvnqnH/HLhoKyareW2Q/x4sg0BgklHlP1qeWo2oCyPm8FQ==",
"dev": true,
"dependencies": {
"object-assign": ">=4.0.1",
"postcss": ">=5.0.2"
}
},
"node_modules/process": {
"version": "0.11.10",
"resolved": "https://registry.npmmirror.com/process/-/process-0.11.10.tgz",
@ -2548,10 +2568,16 @@
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmmirror.com/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
"dev": true
},
"picocolors": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ=="
"version": "1.1.1",
"resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.1.1.tgz",
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="
},
"picomatch": {
"version": "2.3.1",
@ -2578,6 +2604,16 @@
"source-map-js": "^1.0.2"
}
},
"postcss-px-to-viewport": {
"version": "1.1.1",
"resolved": "https://registry.npmmirror.com/postcss-px-to-viewport/-/postcss-px-to-viewport-1.1.1.tgz",
"integrity": "sha512-2x9oGnBms+e0cYtBJOZdlwrFg/mLR4P1g2IFu7jYKvnqnH/HLhoKyareW2Q/x4sg0BgklHlP1qeWo2oCyPm8FQ==",
"dev": true,
"requires": {
"object-assign": ">=4.0.1",
"postcss": ">=5.0.2"
}
},
"process": {
"version": "0.11.10",
"resolved": "https://registry.npmmirror.com/process/-/process-0.11.10.tgz",

View File

@ -21,6 +21,7 @@
"devDependencies": {
"@vitejs/plugin-vue": "^4.2.3",
"dotenv": "^16.5.0",
"postcss-px-to-viewport": "^1.1.1",
"sass": "^1.89.0",
"vite": "^4.4.5"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 MiB

After

Width:  |  Height:  |  Size: 389 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 468 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 534 B

View File

Before

Width:  |  Height:  |  Size: 329 B

After

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 559 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 368 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 852 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 711 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 795 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1,145 +0,0 @@
<!-- AlarmActions.vue -->
<template>
<div class="alarm-actions-container">
<!-- 左侧标签 -->
<div class="alarm-tabs-overview">
<div
class="tab-item"
:class="{ active: modelValue === 'pending' }"
@click="updateTab('pending')"
>
未处理 <span class="tab-count">({{ pendingCount }})</span>
</div>
<div
class="tab-item"
:class="{ active: modelValue === 'done' }"
@click="updateTab('done')"
>
已处理 <span class="tab-count">({{ doneCount }})</span>
</div>
</div>
<!-- 右侧按钮 -->
<div class="alarm-actions">
<button v-if="showViewAll" class="view-all-btn" @click="$emit('viewAll')">
查看全部
<span v-if="unreadCount > 0" class="badge">{{ unreadCount }}</span>
</button>
<button class="process-all-btn" @click="$emit('processAll')">
一键处理
</button>
</div>
</div>
</template>
<script setup>
defineProps({
modelValue: {
type: String,
required: true
},
pendingCount: {
type: Number,
default: 0
},
doneCount: {
type: Number,
default: 0
},
unreadCount: {
type: Number,
default: 0
},
showViewAll: {
type: Boolean,
default: true
}
});
const emit = defineEmits(['update:modelValue', 'viewAll', 'processAll']);
const updateTab = (tab) => {
emit('update:modelValue', tab);
};
</script>
<style scoped>
.alarm-actions-container {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
}
.alarm-tabs-overview {
display: flex;
gap: 10px;
}
.alarm-tabs-overview .tab-item {
padding: 6px 16px;
font-size: 14px;
cursor: pointer;
border-radius: 2px 2px 0 0;
color: #b9e8ff;
background: none;
border-bottom: 2px solid transparent;
transition: all 0.2s;
}
.alarm-tabs-overview .tab-item.active {
color: #00ffff;
border-bottom: 2px solid #00ffff;
background: url("../assets/img/alarm_tri.png") no-repeat;
background-size: 100% 100%;
}
.tab-count {
color: #00ffff;
font-weight: bold;
}
.alarm-actions {
display: flex;
align-items: center;
gap: 10px;
}
.view-all-btn {
position: relative;
background: rgba(0, 145, 169, 0.2);
color: #b9e8ff;
border: 1px solid #0091A9;
border-radius: 2px;
padding: 2px 14px;
font-size: 13px;
cursor: pointer;
margin-right: 2px;
}
.badge {
position: absolute;
top: -6px;
right: -10px;
background: #ff4d4f;
color: #fff;
border-radius: 10px;
padding: 0 6px;
font-size: 12px;
font-weight: bold;
line-height: 18px;
min-width: 18px;
text-align: center;
box-shadow: 0 0 4px #ff4d4f99;
}
.process-all-btn {
background: #0091A9;
color: #b9e8ff;
border: none;
border-radius: 2px;
padding: 2px 14px;
font-size: 13px;
cursor: pointer;
}
</style>

View File

@ -69,23 +69,31 @@ const updateTab = (tab) => {
align-items: center;
justify-content: space-between;
width: 100%;
padding: 0 0.26vw; /* 0 5px at 1920px width */
flex-wrap: nowrap;
min-width: 0;
}
.alarm-tabs-overview {
display: flex;
gap: 10px;
gap: 0.26vw; /* 5px at 1920px width */
flex-wrap: nowrap;
min-width: 0;
}
.alarm-tabs-overview .tab-item {
padding: 6px 16px;
font-size: 14px;
padding: 0.313vw 0.52vw; /* 6px 10px at 1920px width */
font-size: var(--fsize3);
cursor: pointer;
border-radius: 2px 2px 0 0;
border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
color: #b9e8ff;
background: none;
border-bottom: 2px solid transparent;
border-bottom: 1px solid transparent;
transition: all 0.3s ease;
user-select: none;
min-width: 3.646vw; /* 70px at 1920px width */
text-align: center;
white-space: nowrap;
}
.alarm-tabs-overview .tab-item:hover {
@ -95,7 +103,7 @@ const updateTab = (tab) => {
.alarm-tabs-overview .tab-item.active {
color: #00ffff;
border-bottom: 2px solid #00ffff;
border-bottom: 1px solid #00ffff;
background: url("../assets/img/alarm_tri.png") no-repeat;
background-size: 100% 100%;
}
@ -108,7 +116,14 @@ const updateTab = (tab) => {
.alarm-actions {
display: flex;
align-items: center;
gap: 10px;
gap: 0.52vw; /* 10px at 1920px width */
flex-wrap: nowrap;
min-width: 0;
}
.view-all-btn, .process-all-btn {
min-width: 3.646vw; /* 70px at 1920px width */
white-space: nowrap;
}
.view-all-btn {
@ -116,11 +131,11 @@ const updateTab = (tab) => {
background: rgba(0, 145, 169, 0.2);
color: #b9e8ff;
border: 1px solid #0091A9;
border-radius: 2px;
padding: 2px 14px;
font-size: 13px;
border-radius: var(--border-radius-sm);
padding: 0.104vw 0.729vw; /* 2px 14px at 1920px width */
font-size: 0.677vw; /* 13px at 1920px width */
cursor: pointer;
margin-right: 2px;
margin-right: 0.104vw; /* 2px at 1920px width */
transition: all 0.3s ease;
outline: none;
}
@ -136,30 +151,29 @@ const updateTab = (tab) => {
.badge {
position: absolute;
top: -6px;
right: -10px;
top: -0.313vw; /* -6px at 1920px width */
right: -0.521vw; /* -10px at 1920px width */
background: #ff4d4f;
color: #fff;
border-radius: 10px;
padding: 0 6px;
font-size: 12px;
border-radius: 0.521vw; /* 10px at 1920px width */
padding: 0 0.313vw; /* 0 6px at 1920px width */
font-size: var(--fsize4);
font-weight: bold;
line-height: 18px;
min-width: 18px;
line-height: 0.938vw; /* 18px at 1920px width */
min-width: 0.938vw; /* 18px at 1920px width */
text-align: center;
box-shadow: 0 0 4px #ff4d4f99;
box-shadow: 0 0 0.208vw #ff4d4f99; /* 4px at 1920px width */
}
.process-all-btn {
background: #0091A9;
background: #00a7c4;
color: #b9e8ff;
border: none;
border-radius: 2px;
padding: 2px 14px;
font-size: 13px;
border: 1px solid #0091A9;
border-radius: var(--border-radius-sm);
padding: 0.104vw 0.729vw; /* 2px 14px at 1920px width */
font-size: 0.677vw; /* 13px at 1920px width */
cursor: pointer;
transition: all 0.3s ease;
outline: none;
}
.process-all-btn:hover {
@ -170,4 +184,5 @@ const updateTab = (tab) => {
background: #007d91;
transform: scale(0.98);
}
</style>

View File

@ -1,403 +0,0 @@
<template>
<div class="alarm-statistics">
<div class="time-filter">
<div
v-for="period in periods"
:key="period.value"
:class="['filter-item', { active: currentPeriod === period.value }]"
@click="handleManualSelect(period.value)"
>
{{ period.label }}
</div>
</div>
<div class="chart-container" ref="chartRef"></div>
</div>
</template>
<script setup>
import { ref, onMounted, onUnmounted, watch, computed } from "vue";
import * as echarts from "echarts";
import { homeApi } from '../api/index';
import emptyList from '../assets/img/empty_list.png';
const chartRef = ref(null);
let chart = null;
let autoSwitchTimer = null;
let checkInterval = null;
const isLoading = ref(false);
const isManualMode = ref(false); //
//
const eventTypeMap = {
'0': '读表告警',
'1': '高温感知报警',
'2': '吸烟报警',
'3': '长时间滞留报警',
'4': '空气质量报警',
'5': '急停按下',
'6': '语音未接通',
'7': '日常巡检'
};
// API
const apiData = ref({
'1': [], //
'7': [], //
'30': [], //
});
//
const hasData = computed(() => {
return apiData.value[currentPeriod.value] && apiData.value[currentPeriod.value].length > 0;
});
// API
const transformData = (data) => {
const xAxisData = [];
const seriesData = [];
if (!data || data.length === 0) {
return { xAxis: [], series: [] };
}
//
data.forEach(item => {
const eventTypeName = eventTypeMap[item.eventType] || `未知类型(${item.eventType})`;
xAxisData.push(eventTypeName);
seriesData.push(item.count);
});
return {
xAxis: xAxisData,
series: seriesData
};
};
const periods = [
{ label: "天", value: "1" },
{ label: "周", value: "7" },
{ label: "月", value: "30" },
];
const currentPeriod = ref("1");
//
const fetchAlarmStatistics = async (day) => {
console.log(`获取${day}天的数据`);
isLoading.value = true;
try {
const res = await homeApi.getAlarmStatistics(day);
if (res.code === 200) {
apiData.value[day] = res.data || [];
console.log(`获取${day}天告警统计数据成功:`, res.data);
} else {
console.error(`获取${day}天告警统计数据失败:`, res);
apiData.value[day] = [];
}
} catch (err) {
console.error(`获取${day}天告警统计数据错误:`, err);
apiData.value[day] = [];
} finally {
isLoading.value = false;
//
if (currentPeriod.value === day) {
updateChart();
}
}
};
//
const updateChart = () => {
if (!chartRef.value || !chart) return;
console.log(`更新图表数据,当前时间段: ${currentPeriod.value}`);
//
const chartData = transformData(apiData.value[currentPeriod.value]);
//
const option = {
grid: {
top: "10%",
left: "5%",
right: "4%",
bottom: "15%",
containLabel: true,
},
xAxis: {
type: "category",
// 使
data: chartData.xAxis.length > 0 ? chartData.xAxis : ['暂无数据'],
axisLine: {
show: true,
lineStyle: {
color: "rgba(185, 232, 255, 0.1)",
},
},
axisTick: {
show: false,
},
axisLabel: {
color: "#B9E8FF",
fontSize: 12,
interval: 0,
rotate: 45,
},
},
yAxis: {
type: "value",
name: "数量: 次",
nameTextStyle: {
color: "#B9E8FF",
fontSize: 12,
padding: [0, 30, 0, 0],
},
splitLine: {
show: true,
lineStyle: {
color: "rgba(185, 232, 255, 0.1)",
type: "dashed",
},
},
axisLine: {
show: false,
},
axisTick: {
show: false,
},
axisLabel: {
color: "#B9E8FF",
fontSize: 12,
},
},
series: [
{
//
data: chartData.series.length > 0 ? chartData.series : [0],
type: "line",
smooth: true,
symbol: "circle",
symbolSize: 8,
itemStyle: {
color: "#FF8A00",
},
lineStyle: {
color: {
type: "linear",
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
color: "#FF8A00",
},
{
offset: 1,
color: "rgba(255, 138, 0, 0)",
},
],
},
width: 3,
},
areaStyle: {
color: {
type: "linear",
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
color: "rgba(255, 138, 0, 0.3)",
},
{
offset: 1,
color: "rgba(255, 138, 0, 0)",
},
],
},
},
label: {
show: true,
position: 'top',
color: '#FF8A00',
fontSize: 14,
fontWeight: 'bold',
},
},
],
};
console.log('设置图表选项');
chart.setOption(option, true); // 使true
};
//
const initChart = () => {
if (!chartRef.value) return;
if (chart) {
chart.dispose();
}
chart = echarts.init(chartRef.value);
updateChart(); //
};
//
const startAutoSwitch = () => {
stopAutoSwitch(); //
autoSwitchTimer = setInterval(async () => {
//
if (isManualMode.value) return;
const currentIndex = periods.findIndex(p => p.value === currentPeriod.value);
const nextIndex = (currentIndex + 1) % periods.length;
const nextPeriod = periods[nextIndex].value;
console.log(`自动切换到: ${periods[nextIndex].label}(${nextPeriod})`);
//
currentPeriod.value = nextPeriod;
//
await fetchAlarmStatistics(nextPeriod);
}, 10000); // 10
};
//
const stopAutoSwitch = () => {
if (autoSwitchTimer) {
clearInterval(autoSwitchTimer);
autoSwitchTimer = null;
}
};
//
const handleManualSelect = async (period) => {
console.log(`手动选择时间段: ${period}`);
//
isManualMode.value = true;
//
if (currentPeriod.value === period) return;
//
currentPeriod.value = period;
//
await fetchAlarmStatistics(period);
// 5
setTimeout(() => {
console.log('恢复自动模式');
isManualMode.value = false;
}, 30000); // 30
};
//
const handleResize = () => {
chart && chart.resize();
};
//
watch(currentPeriod, (newPeriod) => {
console.log(`当前选中时间段变为: ${newPeriod}`);
});
onMounted(async () => {
console.log('组件挂载');
// 1
await fetchAlarmStatistics('1');
//
Promise.all([
fetchAlarmStatistics('7'),
fetchAlarmStatistics('30')
]);
initChart();
window.addEventListener("resize", handleResize);
//
console.log('开始自动轮播');
startAutoSwitch();
//
checkInterval = setInterval(() => {
if (!autoSwitchTimer) {
console.log('检测到轮播已停止,重新启动');
startAutoSwitch();
}
}, 20000); // 20
});
onUnmounted(() => {
//
stopAutoSwitch();
if (checkInterval) {
clearInterval(checkInterval);
checkInterval = null;
}
//
if (chart) {
chart.dispose();
chart = null;
}
window.removeEventListener("resize", handleResize);
console.log('组件卸载,停止自动轮播');
});
</script>
<style scoped>
.alarm-statistics {
width: 100%;
height: 100%;
position: relative;
}
.chart-container {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
z-index: 1;
}
.time-filter {
display: flex;
justify-content: flex-end;
gap: 5px;
padding: 0 10px;
position: relative;
z-index: 3;
}
.filter-item {
color: #b9e8ff;
cursor: pointer;
padding: 2px 10px;
border-radius: 2px;
transition: all 0.3s;
}
.filter-item.active {
padding: 2px 10px;
background: url("../assets/img/alarm_tri.png") no-repeat;
background-size: 100% 100%;
color: #00ffff;
}
</style>

View File

@ -121,9 +121,9 @@ const updateChart = () => {
//
const option = {
grid: {
top: "10%",
top: "15%",
left: "5%",
right: "4%",
right: "5%",
bottom: "15%",
containLabel: true,
},
@ -142,9 +142,9 @@ const updateChart = () => {
},
axisLabel: {
color: "#B9E8FF",
fontSize: 12,
fontSize: 12 * (window.innerWidth / 1920), //
interval: 0,
rotate: 45,
rotate: 25,
},
},
yAxis: {
@ -152,7 +152,7 @@ const updateChart = () => {
name: "数量: 次",
nameTextStyle: {
color: "#B9E8FF",
fontSize: 12,
fontSize: 12 * (window.innerWidth / 1920), //
padding: [0, 30, 0, 0],
},
splitLine: {
@ -170,7 +170,7 @@ const updateChart = () => {
},
axisLabel: {
color: "#B9E8FF",
fontSize: 12,
fontSize: 12 * (window.innerWidth / 1920), //
},
},
series: [
@ -179,7 +179,7 @@ const updateChart = () => {
type: "line",
smooth: false,
symbol: "circle",
symbolSize: 8,
symbolSize: 8 * (window.innerWidth / 1920), //
itemStyle: {
color: "#fff", //
borderColor: '#FF8A00', //
@ -187,7 +187,7 @@ const updateChart = () => {
},
lineStyle: {
color: "#FF8A00", // 线
width: 3,
width: 3 * (window.innerWidth / 1920), // 线
},
areaStyle: {
color: {
@ -206,7 +206,7 @@ const updateChart = () => {
show: true,
position: 'top',
color: '#FF8A00',
fontSize: 14,
fontSize: 14 * (window.innerWidth / 1920), //
fontWeight: 'bold',
},
},
@ -358,22 +358,23 @@ onUnmounted(() => {
.time-filter {
display: flex;
justify-content: flex-end;
gap: 5px;
padding: 0 10px;
gap: 0.26vw; /* 5px at 1920px width */
padding: 0 0.52vw; /* 0 10px at 1920px width */
position: relative;
z-index: 3;
font-size: 16px;
}
.filter-item {
color: #b9e8ff;
cursor: pointer;
padding: 2px 10px;
border-radius: 2px;
padding: 0.1vw 0.52vw; /* 2px 10px at 1920px width */
border-radius: var(--border-radius-sm);
transition: all 0.3s;
}
.filter-item.active {
padding: 2px 10px;
padding: 0.1vw 0.52vw; /* 2px 10px at 1920px width */
background: url("../assets/img/alarm_tri.png") no-repeat;
background-size: 100% 100%;
color: #00ffff;

View File

@ -21,9 +21,9 @@
<div class="loading-text">数据加载中...</div>
</div>
<!-- 空状态展示 -->
<!-- 空状态展示只在数据加载完成且为空时显示 -->
<EmptyState
v-else-if="(currentTab === 'pending' && pendingAlarmsCount === 0) || (currentTab === 'done' && doneAlarmsCount === 0)"
v-else-if="!isLoading && ((currentTab === 'pending' && pendingAlarmsCount === 0) || (currentTab === 'done' && doneAlarmsCount === 0))"
:iconSrc="emptyList"
title="暂无告警事件"
subtitle="所有告警已处理完成"
@ -40,10 +40,12 @@
<div v-for="(item, index) in filteredObstacleAlarms" :key="'obstacle-'+item.id+index" class="alarm-item" @click="showAlarmDetail(item)">
<div class="item-event">{{ item.event }}</div>
<div class="item-robot-id">{{ item.robotId }}</div>
<div class="item-time">{{ item.time }}</div>
<div class="item-time">
<span>{{ item.time.split(' ')[0] }}</span><span class="time-sep"> </span><span>{{ item.time.split(' ')[1] }}</span>
</div>
<div class="item-status">
<button v-if="!item.handled" class="handle-btn" @click.stop="handleAlarm(item)">处理</button>
<span v-else class="handle-btn">已处理</span>
<span v-else class="handled-text">已处理</span>
</div>
</div>
</div>
@ -57,7 +59,9 @@
<div v-for="(item, index) in filteredTemperatureAlarms" :key="'temp-'+item.id+index" class="alarm-item" @click="showAlarmDetail(item)">
<div class="item-event">{{ item.event }}</div>
<div class="item-robot-id">{{ item.robotId }}</div>
<div class="item-time">{{ item.time }}</div>
<div class="item-time">
<span>{{ item.time.split(' ')[0] }}</span><span class="time-sep"> </span><span>{{ item.time.split(' ')[1] }}</span>
</div>
<div class="item-status">
<button v-if="!item.handled" class="handle-btn" @click.stop="handleAlarm(item)">处理</button>
<span v-else class="handled-text">已处理</span>
@ -74,7 +78,9 @@
<div v-for="(item, index) in filteredRoutineAlarms" :key="'routine-'+item.id+index" class="alarm-item" @click="showAlarmDetail(item)">
<div class="item-event">{{ item.event }}</div>
<div class="item-robot-id">{{ item.robotId }}</div>
<div class="item-time">{{ item.time }}</div>
<div class="item-time">
<span>{{ item.time.split(' ')[0] }}</span><span class="time-sep"> </span><span>{{ item.time.split(' ')[1] }}</span>
</div>
<div class="item-status">
<button v-if="!item.handled" class="handle-btn" @click.stop="handleAlarm(item)">处理</button>
<span v-else class="handled-text">已处理</span>
@ -521,7 +527,8 @@ const handleReport = async (data) => {
//
watch(currentTab, (newValue) => {
console.log('标签页切换:', newValue);
isLoading.value = true; // 1. loading
alarmData.value = { obstacle: [], temperature: [], routine: [] }; // 2.
if (newValue === 'pending') {
fetchUnhandledAlarms();
} else if (newValue === 'done') {
@ -550,18 +557,19 @@ onUnmounted(() => {
width: 100%;
height: 100%;
/* background: rgba(0, 21, 31, 0.3); */
border-radius: 4px;
border-radius: var(--border-radius-sm);
overflow: hidden;
color: #B9E8FF;
display: flex;
flex-direction: column;
cursor: pointer;
}
.alarm-header {
display: flex;
padding: 10px;
padding: 1.25vw 0.52vw; /* 24px 10px at 1920px width */
border-bottom: 1px solid rgba(185, 232, 255, 0.1);
font-size: 12px;
font-size: var(--fsize4);
color: #fff;
}
@ -593,7 +601,7 @@ onUnmounted(() => {
}
.alarm-list::-webkit-scrollbar {
width: 4px;
width: 0.21vw; /* 4px at 1920px width */
display: none;
}
@ -607,20 +615,20 @@ onUnmounted(() => {
.alarm-list::-webkit-scrollbar-thumb {
background: rgba(185, 232, 255, 0.3);
border-radius: 2px;
border-radius: var(--border-radius-sm);
}
.alarm-category {
margin-bottom: 5px;
margin-bottom: 0.26vw; /* 5px at 1920px width */
}
.category-header {
display: inline-flex;
align-items: center;
padding: 5px 10px ;
padding: 0.26vw 0.52vw; /* 5px 10px at 1920px width */
background: rgba(0, 145, 169, 0.2);
border: 1px solid rgba(0, 145, 169, 0.4);
border-radius: 2px;
border-radius: var(--border-radius-sm);
width: fit-content;
}
@ -628,31 +636,33 @@ onUnmounted(() => {
background: rgba(82, 33, 60, 1);
border: 1px solid rgba(203, 26, 73, 0.4);
}
.category-icon{
width: 4px;
height: 4px;
width: 0.21vw; /* 4px at 1920px width */
height: 0.21vw; /* 4px at 1920px width */
background:#fff;
border-radius: 2px;
margin-right: 5px;
border-radius: var(--border-radius-sm);
margin-right: 0.26vw; /* 5px at 1920px width */
}
.category-name {
font-size: 14px;
font-size: var(--fsize3);
color: #FFF;
white-space: nowrap;
}
.alarm-item {
display: flex;
padding: 10px;
padding: 0.52vw; /* 10px at 1920px width */
/* border-bottom: 1px solid rgba(185, 232, 255, 0.1); */
/* background: rgba(0, 21, 31, 0.2); */
font-size: 13px;
font-size: 0.677vw; /* 13px at 1920px width */
align-items: center;
}
.item-event {
flex: 2;
color: #FF8A00;
color: #FF8A48;
}
.item-robot-id {
@ -673,22 +683,22 @@ onUnmounted(() => {
.handled-text {
color: #00ffff;
font-size: 12px;
font-size: var(--fsize4);
}
.loading-state {
display: flex;
justify-content: center;
align-items: center;
height: 100px;
height: 5.208vw; /* 100px at 1920px width */
width: 100%;
}
.loading-text {
font-size: 14px;
font-size: var(--fsize3);
color: #B9E8FF;
position: relative;
padding-left: 24px;
padding-left: 1.25vw; /* 24px at 1920px width */
}
.loading-text:before {
@ -697,10 +707,10 @@ onUnmounted(() => {
left: 0;
top: 50%;
transform: translateY(-50%);
width: 16px;
height: 16px;
border: 2px solid rgba(42, 185, 208, 0.5);
border-top: 2px solid #2AB9D0;
width: 0.833vw; /* 16px at 1920px width */
height: 0.833vw; /* 16px at 1920px width */
border: 1px solid rgba(42, 185, 208, 0.5);
border-top: 1px solid #2AB9D0;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@ -714,9 +724,26 @@ onUnmounted(() => {
background: #52213C;
border: 1px solid #CB1A49;
color: white;
border-radius: 2px;
padding: 2px 10px;
font-size: 12px;
border-radius: var(--border-radius-sm);
padding: 0.1vw 0.52vw; /* 2px 10px at 1920px width */
font-size: var(--fsize4);
cursor: pointer;
}
/* @media (max-width: 1600px) {
.item-time span {
display: block;
}
.item-time .time-sep {
display: none;
}
.alarm-item{
font-size: var(--fsize5);
}
.handle-btn{
font-size: var(--fsize5) !important;
padding: 0.05vw 0.42vw !important;
cursor: pointer;
}
} */
</style>

View File

@ -53,9 +53,13 @@
<BatteryIndicator :battery="item.battery" />
<div class="robot-status" :class="item.status.toLowerCase().replace(/\s+/g, '-')">{{ item.status }}</div>
</div>
<div v-if="item.tag" class="alarm-wrapper">
<div v-if="item.tags=== 1" class="alarm-wrapper">
<img src="../assets/img/tip.png" alt="告警" class="alarm-tip" />
<span class="alarm-text">{{ item.tag }}</span>
<span class="alarm-text">告警</span>
</div>
<div v-if="item.tags=== 2" class="alarm-wrapper">
<img src="../assets/img/ossTip.png" alt="告警" class="alarm-tip" />
<span class="alarm-text">紧急</span>
</div>
</div>
</div>
@ -72,9 +76,11 @@ import BatteryIndicator from './common/BatteryIndicator.vue'
import CustomSelect from './common/CustomSelect.vue'
import EmptyState from './common/EmptyState.vue'
import { homeApi } from '../api/index'
import { robotApi } from '../api/detail'
import emptyRobot from '../assets/img/empty_robot.png'
const router = useRouter()
const emit = defineEmits(['outdoor-robots-update'])
//
const debounce = (fn, delay) => {
@ -97,6 +103,9 @@ const robotList = ref([])
const loading = ref(false)
const error = ref(null)
//
const alertStatusMap = ref({})
//
const fetchRobotList = async (searchNumber = null) => {
loading.value = true
@ -126,7 +135,8 @@ const fetchRobotList = async (searchNumber = null) => {
battery: parseInt(robot.robotInfo?.power || 0),
status: getStatusText(robot.onlineStatus, robot.status),
type: getGroupType(groupName),
tag: robot.onlineStatus === '1' && robot.status === '3' ? '故障' : null
tag: robot.onlineStatus === '1' && robot.status === '3' ? '故障' : null,
tags: robot.tags
}
allRobots.push(robotData)
@ -282,22 +292,24 @@ const searchRobots = () => {
console.log('搜索机器人:', searchText.value)
fetchRobotList(searchText.value)
}
</script>
<style scoped>
.robot-status-list {
width: 100%;
height: 54vh;
border-radius: 4px;
border-radius: var(--border-radius-sm);
overflow: hidden;
color: #B9E8FF;
}
.list-header {
width: 100%;
padding: 5px 10px;
height: 40px;
margin-bottom:20px;
padding: 0.26vw 0.52vw; /* 5px 10px at 1920px width */
height: 2.083vw; /* 40px at 1920px width */
margin-bottom: 1.042vw; /* 20px at 1920px width */
display: flex;
align-items: center;
justify-content: space-between;
@ -308,25 +320,24 @@ const searchRobots = () => {
align-items: center;
justify-content: space-between;
width: 100%;
gap: 10px;
gap: 0.52vw; /* 10px at 1920px width */
}
.search-box {
height: 34px;
height: 1.771vw; /* 34px at 1920px width */
position: relative;
flex: 1;
}
.search-box input {
width: 100%;
height: 34px;
height: 1.771vw; /* 34px at 1920px width */
background-color: #00273A;
border: 1px solid rgba(185, 232, 255, 0.2);
border-radius: 4px;
border-radius: var(--border-radius-sm);
color: #B9E8FF;
font-size: 13px;
padding: 0 30px 0 10px;
font-size: 0.677vw; /* 13px at 1920px width */
padding: 0 1.563vw 0 0.52vw; /* 0 30px 0 10px at 1920px width */
}
.search-box input::placeholder {
@ -336,18 +347,18 @@ const searchRobots = () => {
.search-icon {
position: absolute;
right: 10px;
right: 0.52vw; /* 10px at 1920px width */
top: 50%;
transform: translateY(-50%);
width: 16px;
height: 16px;
width: 0.833vw; /* 16px at 1920px width */
height: 0.833vw; /* 16px at 1920px width */
}
.list-title {
display: flex;
padding: 10px;
padding: 0.52vw; /* 10px at 1920px width */
color: rgba(185, 232, 255, 0.7);
font-size: 13px;
font-size: 0.677vw; /* 13px at 1920px width */
border-bottom: 1px solid rgba(185, 232, 255, 0.1);
}
@ -360,13 +371,13 @@ const searchRobots = () => {
}
.list-content {
height: calc(100% - 90px);
height: calc(100% - 4.688vw); /* 90px at 1920px width */
overflow-y: auto;
overflow-x: hidden;
}
.robot-category {
margin-bottom: 5px;
margin-bottom: 0.26vw; /* 5px at 1920px width */
}
.category-header {
@ -375,44 +386,44 @@ const searchRobots = () => {
/* padding: 8px 10px;
background: rgba(0, 145, 169, 0.2);
border: 1px solid rgba(0, 145, 169, 0.4); */
border-radius: 2px;
border-radius: var(--border-radius-sm);
width: fit-content;
margin: 5px 10px;
margin: 0.26vw 0.52vw; /* 5px 10px at 1920px width */
}
.category-icon {
width: 6px;
height: 6px;
width: 0.313vw; /* 6px at 1920px width */
height: 0.313vw; /* 6px at 1920px width */
border-radius: 50%;
background-color: #E4F2FF;
/* border:1px solid red; */
margin-right: 8px;
margin-right: 0.417vw; /* 8px at 1920px width */
}
.category-title {
font-size: 13px;
font-size: 0.677vw; /* 13px at 1920px width */
color: #FFF;
white-space: nowrap;
}
.list-item {
padding: 5px 10px;
padding: 0.26vw 0.52vw; /* 5px 10px at 1920px width */
}
.list-item-content {
display: flex;
align-items: center;
padding: 10px 15px;
padding: 0.52vw 0.781vw; /* 10px 15px at 1920px width */
background: url("../assets/img/event_tri.png") no-repeat;
background-size: 100% 100%;
position: relative;
min-height: 50px;
min-height: 2.604vw; /* 50px at 1920px width */
cursor: pointer;
}
.robot-id {
flex: 2;
color: #B9E8FF;
font-size: 13px;
font-size: 0.677vw; /* 13px at 1920px width */
}
.robot-info {
@ -420,16 +431,15 @@ const searchRobots = () => {
display: flex;
align-items: center;
justify-content: flex-start;
gap: 20px;
padding-right: 30px;
gap: 2.042vw; /* 20px at 1920px width */
padding-right: 1.563vw; /* 30px at 1920px width */
}
.robot-status {
padding: 3px 8px;
border-radius: 5px;
font-size: 12px;
min-width: 40px;
padding: 0.156vw 0.417vw; /* 3px 8px at 1920px width */
border-radius: var(--border-radius-sm);
font-size: var(--fsize4);
min-width: 2.083vw; /* 40px at 1920px width */
text-align: center;
}
@ -452,16 +462,16 @@ const searchRobots = () => {
position: absolute;
top: 0;
right: 0;
width: 42px;
height: 24px;
width: 2.188vw; /* 42px at 1920px width */
height: 1.25vw; /* 24px at 1920px width */
display: flex;
align-items: center;
justify-content: center;
}
.alarm-tip {
width: 42px;
height: 24px;
width: 2.188vw; /* 42px at 1920px width */
height: 1.25vw; /* 24px at 1920px width */
position: absolute;
top: 0;
right: 0;
@ -469,18 +479,18 @@ const searchRobots = () => {
.alarm-text {
position: absolute;
top:0;
left:10px;
font-size: 12px;
top: 0;
left: 0.52vw; /* 10px at 1920px width */
font-size: var(--fsize4);
color: #000;
text-align: center;
z-index: 1;
line-height: 18px;
line-height: 0.938vw; /* 18px at 1920px width */
}
/* 自定义滚动条 */
.list-content::-webkit-scrollbar {
width: 4px;
width: 0.208vw; /* 4px at 1920px width */
display: none;
}
@ -494,7 +504,7 @@ const searchRobots = () => {
.list-content::-webkit-scrollbar-thumb {
background: rgba(185, 232, 255, 0.3);
border-radius: 2px;
border-radius: var(--border-radius-sm);
}
.loading-state,
@ -509,13 +519,13 @@ const searchRobots = () => {
}
.loading-spinner {
width: 40px;
height: 40px;
border: 3px solid rgba(185, 232, 255, 0.2);
border-top: 3px solid #B9E8FF;
width: 2.083vw; /* 40px at 1920px width */
height: 2.083vw; /* 40px at 1920px width */
border: 1px solid rgba(185, 232, 255, 0.2);
border-top: 1px solid #B9E8FF;
border-radius: 50%;
animation: spin 1s linear infinite;
margin-bottom: 10px;
margin-bottom: 0.52vw; /* 10px at 1920px width */
}
@keyframes spin {
@ -526,20 +536,20 @@ const searchRobots = () => {
.loading-text,
.error-text,
.empty-text {
font-size: 14px;
margin-top: 10px;
font-size: var(--fsize3);
margin-top: 0.52vw; /* 10px at 1920px width */
}
.error-icon,
.empty-icon {
font-size: 24px;
width: 40px;
height: 40px;
font-size: var(--fsize2);
width: 2.083vw; /* 40px at 1920px width */
height: 2.083vw; /* 40px at 1920px width */
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 10px;
margin-bottom: 0.52vw; /* 10px at 1920px width */
}
.error-icon {
@ -548,11 +558,11 @@ const searchRobots = () => {
}
.retry-button {
margin-top: 15px;
padding: 5px 15px;
margin-top: 0.781vw; /* 15px at 1920px width */
padding: 0.26vw 0.781vw; /* 5px 15px at 1920px width */
background-color: rgba(0, 145, 169, 0.2);
border: 1px solid #0091A9;
border-radius: 4px;
border-radius: var(--border-radius-sm);
color: #B9E8FF;
cursor: pointer;
transition: all 0.3s;
@ -564,22 +574,27 @@ const searchRobots = () => {
.robot-status.故障 {
color: #ff4d4f;
background: rgba(230, 0, 0, 0.2);
}
.robot-status.离线 {
color: #faad14;
color: #fff;
background: rgba(228, 242, 255, 0.2);
}
.robot-status.运行中 {
color: #52c41a;
color: #70FFBA;
background: rgba(0, 234, 168, 0.2);
}
.robot-status.充电中 {
color: #1890ff;
color: #70FFBA;
background: rgba(0, 234, 168, 0.2);
}
.robot-status.待机中 {
color: #00ffff;
color: #fff;
background: rgba(228, 242, 255, 0.2);
}
.empty-state-container {
@ -587,14 +602,63 @@ const searchRobots = () => {
display: flex;
align-items: center;
justify-content: center;
}
:deep(.empty-icon) {
width: 213px !important;
height: 150px !important;
width: 11.094vw !important; /* 213px at 1920px width */
height: 7.813vw !important; /* 150px at 1920px width */
}
:deep(.empty-subtitle) {
color: #fff!important;
font-size: 16px!important;
color: #fff !important;
font-size: var(--fsize) !important;
}
.robot-alert-tag-wrapper {
display: inline-flex;
align-items: center;
margin-left: 1vw;
}
.robot-alert-tag {
display: inline-block;
min-width: 2.5vw;
padding: 0.1vw 0.7vw;
font-size: 14px;
font-weight: bold;
border-radius: 0.5vw 0.5vw 0 0.5vw;
color: #fff;
text-align: center;
margin-left: 0.3vw;
}
.robot-alert-tag.urgent {
background: #FF4D4F;
}
.robot-alert-tag.warning {
position: relative;
background: #FF9800;
padding: 0 1.2vw;
border-radius: 0.5vw 0.5vw 0 0.5vw;
min-width: 2.5vw;
height: 1.5vw;
display: inline-flex;
align-items: center;
justify-content: center;
}
.robot-alert-tag.warning .tag-text {
position: relative;
z-index: 1;
font-size: 14px;
font-weight: bold;
color: #fff;
text-align: center;
line-height: 1.5vw;
}
.robot-alert-tag.warning .tag-tip-corner {
position: absolute;
top: -0.4vw;
right: -0.4vw;
width: 1.1vw;
height: 1.1vw;
z-index: 2;
}
</style>

View File

@ -30,10 +30,10 @@ defineProps({
<style scoped>
.statistic-card {
display: flex;
align-items: center;
gap: 10px;
justify-content: center;
gap: var(--spacing-xs);
cursor: pointer;
transition: all 0.3s;
}
@ -43,8 +43,12 @@ defineProps({
} */
.icon {
width: 84px;
height: 64px;
max-width: 4.375vw; /* 84px at 1920px width */
min-width: 1.667vw; /* 32px at 1920px width */
height: auto;
aspect-ratio: 84/64;
max-height: 3.333vw; /* 64px at 1920px width */
min-height: 1.25vw; /* 24px at 1920px width */
display: flex;
justify-content: center;
align-items: center;
@ -59,7 +63,7 @@ defineProps({
.info {
display: flex;
flex-direction: column;
gap: 5px;
gap: var(--spacing-xs);
}
.value {
@ -73,4 +77,12 @@ defineProps({
color: #ffffff;
opacity: 0.8;
}
/* @media (max-width: 1366px) {
.icon {
max-width: 3.333vw;
min-width: 1.25vw;
}
} */
</style>

View File

@ -6,7 +6,7 @@
v-if="currentStream"
:streamUrl="currentStream"
:title="title"
fillMode="stretch-height"
fillMode="cover"
/>
<EmptyState
v-else
@ -16,7 +16,7 @@
/>
<!-- 左右箭头 -->
<div class="carousel-arrows" v-if="hasValidViews">
<div class="carousel-arrows" v-if="hasValidViews && validViews.length > 1">
<div class="arrow left-arrow" @click="prevView">
<i class="arrow-icon left"></i>
</div>
@ -26,7 +26,7 @@
</div>
<!-- 视角指示器 -->
<!-- <div class="view-indicators" v-if="hasValidViews">
<div class="view-indicators" v-if="hasValidViews && validViews.length > 1">
<div
v-for="(view, index) in validViews"
:key="index"
@ -34,7 +34,7 @@
:class="{ active: currentViewIndex === validViewsIndices[index] }"
@click="setView(validViewsIndices[index])"
></div>
</div> -->
</div>
</div>
</div>
</template>

View File

@ -14,7 +14,7 @@
/>
<!-- 左右箭头 -->
<div class="carousel-arrows" v-if="hasValidViews">
<div class="carousel-arrows" v-if="hasValidViews && validViews.length > 1">
<div class="arrow left-arrow" @click="prevView">
<i class="arrow-icon left"></i>
</div>
@ -24,7 +24,7 @@
</div>
<!-- 视角指示器 -->
<!-- <div class="view-indicators" v-if="hasValidViews">
<div class="view-indicators" v-if="hasValidViews && validViews.length > 1">
<div
v-for="(view, index) in validViews"
:key="index"
@ -32,7 +32,7 @@
:class="{ active: currentViewIndex === validViewsIndices[index] }"
@click="setView(validViewsIndices[index])"
></div>
</div> -->
</div>
</div>
</div>
</template>

View File

@ -82,15 +82,14 @@ const selectOption = (option) => {
.type-select {
display: flex;
align-items: center;
font-size: v-bind("font === 'small' ? '12px' : '14px'");
font-size: v-bind("font === 'small' ? 'var(--fsize4)' : 'var(--fsize3)'");
color: #B9E8FF;
/* background: rgba(0, 21, 31, 0.3) ; */
background-color: #00273A;
border: v-bind("variant === 'search' ? '1px solid rgba(185, 232, 255, 0.2)' : '1px solid rgba(0, 206, 234, 0.7)'");
border-radius: 2px;
padding: 3px 8px;
height: v-bind("size === 'small' ? '24px' : size === 'medium' ? '34px' : '28px'");
border-radius: var(--border-radius-sm);
padding: 0.156vw 0.417vw; /* 3px 8px at 1920px width */
height: v-bind("size === 'small' ? '1.25vw' : size === 'medium' ? '1.771vw' : '1.458vw'"); /* 24px, 34px, 28px at 1920px width */
}
.select-label {
@ -99,20 +98,20 @@ const selectOption = (option) => {
.select-divider {
color: #00ffff;
margin: 0 10px;
margin: 0 0.52vw; /* 0 10px at 1920px width */
}
.select-wrapper {
position: relative;
cursor: pointer;
min-width: v-bind("size === 'small' ? '60px' : size === 'medium' ? '100px' : '80px'");
min-width: v-bind("size === 'small' ? '3.125vw' : size === 'medium' ? '5.208vw' : '4.167vw'"); /* 60px, 100px, 80px at 1920px width */
outline: none;
}
.select-text {
color: #B9E8FF;
margin-right: 25px;
font-size: v-bind("font === 'small' ? '12px' : '14px'");
margin-right: 1.302vw; /* 25px at 1920px width */
font-size: v-bind("font === 'small' ? 'var(--fsize4)' : 'var(--fsize3)'");
}
.arrow-icon {
@ -120,34 +119,47 @@ const selectOption = (option) => {
right: 0;
top: 50%;
transform: translateY(-50%);
width: 16px;
height: 16px;
width: 0.833vw; /* 16px at 1920px width */
height: 0.833vw; /* 16px at 1920px width */
}
.select-dropdown {
position: absolute;
top: 100%;
right: 0;
top: 140%;
right: -8px;
background: #00273A;
border: 1px solid rgba(0, 206, 234, 0.7);
border-radius: 2px;
margin-top: 5px;
padding: 5px 0;
min-width: 100%;
border:1px solid #335261;
border-radius: 6px;
padding: 0;
min-width: 118%;
z-index: 10;
white-space: nowrap;
}
.select-dropdown li {
padding: v-bind("size === 'small' ? '2px 12px' : '4px 12px'");
padding: 0 0.625vw; /* 左右有间距,上下无间距 */
color: #B9E8FF;
background: #00273A;
cursor: pointer;
white-space: nowrap;
font-size: v-bind("font === 'small' ? '12px' : '12px'");
line-height: v-bind("size === 'small' ? '18px' : '20px'");
font-size: v-bind("font === 'small' ? 'var(--fsize4)' : 'var(--fsize4)'");
line-height: v-bind("size === 'small' ? '1.2vw' : '1.5vw'"); /* 18px or 20px at 1920px width */
}
.select-dropdown li:first-child {
border-radius: 6px 6px 0 0;
}
.select-dropdown li:hover,
.select-dropdown li:last-child {
border-radius: 0 0 6px 6px;
}
.select-dropdown li.active {
background: rgba(0, 206, 234, 0.2);
background: #0091A9;
color: #fff;
}
.select-dropdown li:hover {
background: #005C71;
color: #fff;
}
</style>

View File

@ -366,6 +366,7 @@ onUnmounted(() => {
height: 100%;
overflow: hidden;
background-color: #033347;
border-radius: 8px;
}
.player-container {

View File

@ -222,7 +222,7 @@ onUnmounted(() => {
.video-element {
width: 100%;
height: 100%;
height: 135px;
}
.video-fill {
@ -231,6 +231,9 @@ onUnmounted(() => {
.video-cover {
object-fit: cover; /* 保持比例填充,可能会裁剪 */
width: 100%;
height: 100%;
aspect-ratio: 16/9;
}
.video-stretch-height {

View File

@ -18,6 +18,7 @@ const props = defineProps({
<style scoped>
/* 累计数据 */
.stats-grid {
display: flex;
/* grid-template-columns: repeat(3, 1fr); */
justify-content: space-evenly;
@ -26,10 +27,9 @@ const props = defineProps({
}
.stat-card {
width: 92px;
width: 110px;
height: 60px;
/* padding:0 10px; */
/* background: rgba(0, 21, 31, 0.3); */
border-radius: 4px;
/* padding: 10px; */
@ -37,7 +37,6 @@ const props = defineProps({
flex-direction: column;
align-items: center;
justify-content: space-around;
background: url("../../assets/img/data_bg.png") no-repeat;
background-size: 100% 100%;
}
@ -46,7 +45,7 @@ const props = defineProps({
font-size: 18px;
font-weight: bold;
margin-bottom: 2px;
color: E6F5FA;
color: #E6F5FA;
}
.stat-label {

View File

@ -1,740 +0,0 @@
<template>
<div class="webrtc-player" :class="{ 'is-loading': loading, 'has-error': error }">
<video ref="videoRef" autoplay playsinline muted controls></video>
<div v-if="loading" class="loading-overlay">
<span>加载中...</span>
<div class="loading-spinner"></div>
</div>
<div v-if="error" class="error-overlay">
<span>{{ error }}</span>
<button v-if="error" @click="retry" class="retry-btn">重试</button>
</div>
<div v-if="debug && status" class="status-indicator" :class="status">
{{ statusText }}
</div>
<!-- 调试面板 -->
<div v-if="debug && showDebugPanel" class="debug-panel">
<div class="debug-header">
<span>WebRTC调试信息</span>
<button class="close-btn" @click="showDebugPanel = false">×</button>
</div>
<div class="debug-content">
<div class="debug-section">
<h4>连接信息</h4>
<p><strong>状态:</strong> {{ status }}</p>
<p><strong>重试次数:</strong> {{ retryCount }}/{{ MAX_RETRY }}</p>
<p><strong>请求URL:</strong> {{ debugInfo.requestUrl }}</p>
<p><strong>流ID:</strong> {{ debugInfo.streamId }}</p>
</div>
<div v-if="debugInfo.codecs.video.length || debugInfo.codecs.audio.length" class="debug-section">
<h4>编解码器信息</h4>
<div v-if="debugInfo.codecs.video.length">
<strong>视频:</strong> {{ debugInfo.codecs.video.join(', ') }}
</div>
<div v-if="debugInfo.codecs.audio.length">
<strong>音频:</strong> {{ debugInfo.codecs.audio.join(', ') }}
</div>
</div>
<div v-if="sdpInfo.offer || sdpInfo.answer" class="debug-section">
<h4>SDP信息</h4>
<div v-if="sdpInfo.offer" class="sdp-box">
<strong>Offer SDP:</strong>
<pre>{{ sdpInfo.offer }}</pre>
</div>
<div v-if="sdpInfo.answer" class="sdp-box">
<strong>Answer SDP:</strong>
<pre>{{ sdpInfo.answer }}</pre>
</div>
</div>
<div v-if="iceCandidates.length > 0" class="debug-section">
<h4>ICE候选者 ({{ iceCandidates.length }})</h4>
<div class="sdp-box">
<pre>{{ iceCandidates.join('\n') }}</pre>
</div>
</div>
</div>
</div>
<!-- 调试按钮 -->
<button v-if="debug && !showDebugPanel" class="debug-toggle-btn" @click="showDebugPanel = true">
调试
</button>
</div>
</template>
<script setup>
import { ref, onMounted, onUnmounted, watch, computed } from 'vue';
import 'webrtc-adapter';
const props = defineProps({
// https://qvs-live.thirdmonitor.concoai.com:447/rtc/v1/play
url: {
type: String,
required: true
},
// webrtc://qvs-live.thirdmonitor.concoai.com:447/2xenzwqy2ppcl/31011500991180041301_34020000001320000001
streamUrl: {
type: String,
default: ''
},
//
clientInfo: {
type: Object,
default: () => ({})
},
//
debug: {
type: Boolean,
default: false
}
});
const videoRef = ref(null);
const loading = ref(true);
const error = ref('');
const status = ref(''); // connecting, connected, failed, closed
let client = null;
let retryCount = ref(0);
const MAX_RETRY = 3;
let retryTimer = null;
//
const showDebugPanel = ref(false);
const sdpInfo = ref({
offer: '',
answer: ''
});
const iceCandidates = ref([]);
const debugInfo = ref({
requestUrl: '',
streamId: '',
appName: '',
codecs: {
video: [],
audio: []
}
});
//
const statusText = computed(() => {
switch (status.value) {
case 'connecting': return '连接中...';
case 'connected': return '已连接';
case 'failed': return '连接失败';
case 'closed': return '已关闭';
default: return '';
}
});
// axios使JSON
const overrideZLMRTCClientAxios = () => {
if (!window.ZLMRTCClient || !window.ZLMRTCClient.Endpoint) {
console.error('ZLMRTCClient未加载无法重写axios方法');
return;
}
// axios
const originalAxios = window.axios;
// axioswindow便
window._originalAxios = originalAxios;
//
const wrappedAxios = (config) => {
// WebRTCSDP
if (config.url && config.url.includes('/rtc/v1/play') && config.data && typeof config.data === 'string') {
if (props.debug) {
console.log('[CustomWebRTCPlayer] 拦截到WebRTC请求转换为JSON格式');
}
//
const browserInfo = props.clientInfo.osName ? props.clientInfo : {
osName: navigator.platform.indexOf('Win') > -1 ? 'Windows' :
navigator.platform.indexOf('Mac') > -1 ? 'MacOS' :
navigator.platform.indexOf('Linux') > -1 ? 'Linux' : 'Unknown',
osVersion: navigator.userAgent.includes('Windows NT 10.0') ? '10' :
navigator.userAgent.includes('Windows NT 6.1') ? '7' : 'Unknown',
browserName: navigator.userAgent.includes('Chrome') ? 'Chrome' :
navigator.userAgent.includes('Firefox') ? 'Firefox' :
navigator.userAgent.includes('Safari') ? 'Safari' : 'Unknown',
browserVersion: navigator.userAgent.match(/Chrome\/([0-9.]+)/)?.[1] ||
navigator.userAgent.match(/Firefox\/([0-9.]+)/)?.[1] ||
navigator.userAgent.match(/Version\/([0-9.]+)/)?.[1] || 'Unknown',
SDK_VERSION: '1.0.9'
};
// JSON
const jsonData = {
clientip: JSON.stringify(browserInfo),
sdp: config.data, // SDP
streamurl: props.streamUrl
};
//
config.data = JSON.stringify(jsonData);
config.headers = {
...config.headers,
'Content-Type': 'application/json'
};
if (props.debug) {
console.log('[CustomWebRTCPlayer] 转换后的请求数据:', config.data);
}
}
// axios
const originalRequest = originalAxios(config);
//
return originalRequest.then(response => {
if (config.url && config.url.includes('/rtc/v1/play') && props.debug) {
console.log('[CustomWebRTCPlayer] 收到响应:', response);
}
return response;
}).catch(error => {
if (config.url && config.url.includes('/rtc/v1/play')) {
console.error('[CustomWebRTCPlayer] 请求失败:', error);
//
if (error.response) {
console.error('[CustomWebRTCPlayer] 错误响应:', {
status: error.response.status,
statusText: error.response.statusText,
data: error.response.data
});
}
}
return Promise.reject(error);
});
};
// window.axios
window.axios = wrappedAxios;
};
const initPlayer = async () => {
//
sdpInfo.value = {
offer: '',
answer: ''
};
iceCandidates.value = [];
debugInfo.value = {
requestUrl: '',
streamId: '',
appName: '',
codecs: {
video: [],
audio: []
}
};
if (!props.url) {
error.value = '无效的视频流地址';
loading.value = false;
status.value = 'failed';
return;
}
try {
loading.value = true;
error.value = '';
status.value = 'connecting';
// ZLMRTCClient
if (!window.ZLMRTCClient || !window.ZLMRTCClient.Endpoint) {
error.value = 'ZLMRTCClient未加载请刷新页面';
loading.value = false;
status.value = 'failed';
return;
}
// streamUrlID
let streamId = '';
let appName = '';
if (props.streamUrl) {
try {
// streamUrl
const streamUrlObj = new URL(props.streamUrl.replace(/^webrtc:/, 'https:'));
const pathParts = streamUrlObj.pathname.split('/').filter(part => part);
if (pathParts.length >= 2) {
appName = pathParts[0];
streamId = pathParts[pathParts.length - 1];
}
} catch (err) {
console.error('[CustomWebRTCPlayer] 解析streamUrl失败:', err);
}
}
//
debugInfo.value.requestUrl = props.url;
debugInfo.value.streamId = streamId;
debugInfo.value.appName = appName;
if (props.debug) {
console.log('[CustomWebRTCPlayer] 请求URL:', props.url);
console.log('[CustomWebRTCPlayer] 流地址:', props.streamUrl);
console.log('[CustomWebRTCPlayer] 应用名称:', appName);
console.log('[CustomWebRTCPlayer] 流ID:', streamId);
}
// axios
overrideZLMRTCClientAxios();
// Endpoint
client = new window.ZLMRTCClient.Endpoint({
element: videoRef.value,
debug: props.debug,
zlmsdpUrl: props.url,
simulcast: false,
useCamera: false,
audioEnable: true, //
videoEnable: true,
recvOnly: true,
// WebRTC
rtcConfiguration: {
iceServers: [
{
urls: [
'stun:stun.l.google.com:19302',
'stun:stun1.l.google.com:19302',
'stun:stun2.l.google.com:19302'
]
}
],
iceTransportPolicy: 'all',
bundlePolicy: 'max-bundle',
rtcpMuxPolicy: 'require',
sdpSemantics: 'unified-plan' // 使SDP
},
// SDP
customizeSDPHandler: (sdp) => {
if (props.debug) {
console.log('[CustomWebRTCPlayer] 原始SDP:', sdp);
}
// SDP
if (!sdp) {
console.error('[CustomWebRTCPlayer] SDP为空');
return sdp;
}
// 1. 使 recvonly (使sendonly)
sdp = sdp.replace(/a=sendonly/g, 'a=recvonly');
// 2.
const sections = sdp.split('m=');
const header = sections[0];
const audio = sections.find(s => s.startsWith('audio'));
const video = sections.find(s => s.startsWith('video'));
let processedSdp = sdp;
if (audio && video) {
processedSdp = `${header}m=${audio}m=${video}`;
}
// 3. DTLS
processedSdp = processedSdp.replace(/a=setup:actpass/g, 'a=setup:active');
if (props.debug) {
console.log('[CustomWebRTCPlayer] 处理后SDP:', processedSdp);
}
return processedSdp;
}
});
//
client.on('WEBRTC_NOT_SUPPORT', () => {
error.value = '浏览器不支持WebRTC';
loading.value = false;
status.value = 'failed';
});
client.on('WEBRTC_ICE_CANDIDATE_ERROR', (err) => {
console.error('[CustomWebRTCPlayer] ICE候选者错误:', err);
setTimeout(() => {
if (!videoRef.value.srcObject) {
error.value = 'ICE连接失败请检查网络';
loading.value = false;
status.value = 'failed';
//
if (retryCount.value < MAX_RETRY) {
console.log('[CustomWebRTCPlayer] ICE连接失败自动重试...');
retry();
}
}
}, 5000);
});
// SDP
client.on('WEBRTC_SDP_OFFER_CREATED', (offer) => {
if (props.debug) {
console.log('[CustomWebRTCPlayer] 创建SDP Offer:', offer.sdp);
sdpInfo.value.offer = offer.sdp;
}
});
client.on('WEBRTC_SDP_ANSWER_RECEIVED', (answer) => {
if (props.debug) {
console.log('[CustomWebRTCPlayer] 收到SDP Answer:', answer.sdp);
// answer.sdp
if (answer && answer.sdp) {
sdpInfo.value.answer = answer.sdp;
// SDP
const videoCodecs = [];
const audioCodecs = [];
//
const videoSection = answer.sdp.split('m=video')[1];
if (videoSection) {
const rtpmapRegex = /a=rtpmap:(\d+) ([^/]+)/g;
let match;
while ((match = rtpmapRegex.exec(videoSection)) !== null) {
videoCodecs.push(`${match[2]} (${match[1]})`);
}
}
//
const audioSection = answer.sdp.split('m=audio')[1];
if (audioSection && audioSection.split('m=')[0]) {
const rtpmapRegex = /a=rtpmap:(\d+) ([^/]+)/g;
let match;
while ((match = rtpmapRegex.exec(audioSection.split('m=')[0])) !== null) {
audioCodecs.push(`${match[2]} (${match[1]})`);
}
}
//
debugInfo.value.codecs.video = videoCodecs;
debugInfo.value.codecs.audio = audioCodecs;
}
}
});
// ICE
client.on('WEBRTC_ICE_CANDIDATE', (candidate) => {
if (props.debug && candidate && candidate.candidate) {
iceCandidates.value.push(candidate.candidate);
}
});
client.on('WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED', (err) => {
console.error('[CustomWebRTCPlayer] 信令交换失败:', err);
error.value = '信令交换失败,请重试';
loading.value = false;
status.value = 'failed';
//
if (retryCount.value < MAX_RETRY) {
console.log('[CustomWebRTCPlayer] 信令交换失败,自动重试...');
retry();
}
});
client.on('WEBRTC_ON_REMOTE_STREAMS', (stream) => {
if (videoRef.value && stream) {
console.log('[CustomWebRTCPlayer] 收到远程流');
videoRef.value.srcObject = stream;
loading.value = false;
error.value = '';
status.value = 'connected';
//
retryCount.value = 0;
}
});
client.on('WEBRTC_ON_CONNECTION_STATE_CHANGE', (state) => {
if (props.debug) {
console.log('[CustomWebRTCPlayer] 连接状态变化:', state);
}
if (state === 'connected') {
status.value = 'connected';
} else if (state === 'failed' || state === 'disconnected') {
if (!videoRef.value.srcObject) {
error.value = '连接已断开';
loading.value = false;
status.value = 'failed';
if (retryCount.value < MAX_RETRY) {
console.log('[CustomWebRTCPlayer] 连接断开,自动重试...');
retry();
}
}
} else if (state === 'closed') {
status.value = 'closed';
}
});
//
if (props.debug) {
console.log('[CustomWebRTCPlayer] 开始接收流...');
}
await client.receive();
} catch (err) {
console.error('[CustomWebRTCPlayer] 播放器初始化失败:', err);
error.value = err.message || '播放器初始化失败';
loading.value = false;
status.value = 'failed';
if (err.name === 'AxiosError' && err.message === 'Network Error') {
if (retryCount.value < MAX_RETRY) {
console.log('[CustomWebRTCPlayer] 网络错误,自动重试...');
retry();
}
}
}
};
const retry = async () => {
//
if (retryTimer) {
clearTimeout(retryTimer);
retryTimer = null;
}
if (retryCount.value >= MAX_RETRY) {
error.value = `重试次数过多(${retryCount.value}/${MAX_RETRY}),请刷新页面`;
return;
}
retryCount.value++;
console.log(`[CustomWebRTCPlayer] 第${retryCount.value}次重试`);
//
cleanupResources();
//
retryTimer = setTimeout(async () => {
await initPlayer();
}, 2000);
};
//
const cleanupResources = () => {
if (client) {
try {
client.close();
} catch (err) {
console.error('[CustomWebRTCPlayer] 关闭client出错:', err);
}
client = null;
}
if (videoRef.value && videoRef.value.srcObject) {
try {
const tracks = videoRef.value.srcObject.getTracks();
tracks.forEach(track => track.stop());
videoRef.value.srcObject = null;
} catch (err) {
console.error('[CustomWebRTCPlayer] 释放媒体流资源出错:', err);
}
}
};
// URL streamUrl
watch([() => props.url, () => props.streamUrl], async ([newUrl, newStreamUrl], [oldUrl, oldStreamUrl]) => {
if (newUrl !== oldUrl || newStreamUrl !== oldStreamUrl) {
console.log('[CustomWebRTCPlayer] URL或流地址变化重新初始化播放器');
cleanupResources();
retryCount.value = 0;
await initPlayer();
}
});
onMounted(async () => {
console.log('[CustomWebRTCPlayer] 组件挂载,初始化播放器');
await initPlayer();
});
onUnmounted(() => {
console.log('[CustomWebRTCPlayer] 组件卸载,清理资源');
//
if (retryTimer) {
clearTimeout(retryTimer);
retryTimer = null;
}
// axios
if (window._originalAxios) {
console.log('[CustomWebRTCPlayer] 恢复原始axios');
window.axios = window._originalAxios;
window._originalAxios = null;
}
cleanupResources();
});
</script>
<style scoped>
.webrtc-player {
width: 100%;
height: 100%;
position: relative;
background: #000;
}
.webrtc-player video {
width: 100%;
height: 100%;
object-fit: contain;
}
.loading-overlay,
.error-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: rgba(0, 0, 0, 0.7);
color: #fff;
}
.loading-spinner {
width: 40px;
height: 40px;
margin-top: 10px;
border: 4px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top-color: #00ffff;
animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.retry-btn {
margin-top: 10px;
padding: 5px 15px;
border: none;
border-radius: 4px;
background: #0091A9;
color: #fff;
cursor: pointer;
}
.retry-btn:hover {
background: #007a8f;
}
.status-indicator {
position: absolute;
top: 10px;
right: 10px;
padding: 5px 10px;
border-radius: 4px;
font-size: 12px;
background: rgba(0, 0, 0, 0.5);
}
.status-indicator.connecting {
color: #ffff00;
}
.status-indicator.connected {
color: #00ff00;
}
.status-indicator.failed {
color: #ff0000;
}
.status-indicator.closed {
color: #888888;
}
.debug-panel {
position: absolute;
top: 10px;
right: 10px;
padding: 10px;
border-radius: 4px;
background: rgba(0, 0, 0, 0.7);
color: #fff;
width: 300px;
max-height: 400px;
overflow-y: auto;
z-index: 100;
font-size: 12px;
}
.debug-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
padding-bottom: 5px;
}
.close-btn {
background: none;
border: none;
color: #fff;
font-size: 16px;
cursor: pointer;
}
.debug-content {
display: flex;
flex-direction: column;
}
.debug-section {
margin-bottom: 10px;
}
.debug-section h4 {
margin: 5px 0;
color: #00ffff;
}
.sdp-box {
background: rgba(255, 255, 255, 0.1);
padding: 5px;
border-radius: 4px;
margin-bottom: 5px;
overflow-x: auto;
}
.sdp-box pre {
margin: 0;
white-space: pre-wrap;
word-break: break-all;
font-family: monospace;
font-size: 10px;
}
.debug-toggle-btn {
position: absolute;
top: 10px;
left: 10px;
padding: 5px 10px;
border: none;
border-radius: 4px;
background: rgba(0, 0, 0, 0.5);
color: #00ffff;
cursor: pointer;
z-index: 100;
font-size: 12px;
}
.debug-toggle-btn:hover {
background: rgba(0, 0, 0, 0.8);
}
</style>

View File

@ -25,19 +25,25 @@ const props = defineProps({
display: flex;
align-items: stretch;
justify-content: space-between;
height: 80px;
/* height: 80px; */
}
.group-info-col {
flex: 1;
display: flex;
align-items: center;
justify-content: space-evenly;
justify-content: center;
}
.group-info-col img {
width: 2.25rem;
height: 2.25rem;
margin-right: 10px;
width: 2.5vw;
height: 2.5vw;
min-width: 28px;
min-height: 28px;
max-width: 36px;
max-height: 36px;
}
.group-info-divider {
@ -63,9 +69,10 @@ const props = defineProps({
font-size: var(--fsize3);
color: #b9e8ff;
font-weight: bold;
white-space: nowrap;
}
@media (max-width: 900px) {
/* @media (max-width: 900px) {
.group-info-row {
flex-direction: column;
height: auto;
@ -75,5 +82,13 @@ const props = defineProps({
height: 1px;
margin: 0 0 8px 0;
}
}
.group-info-col img {
width: 36px;
height: 36px;
min-width: 24px;
min-height: 24px;
max-width: 36px;
max-height: 36px;
}
} */
</style>

View File

@ -31,16 +31,18 @@ const props = defineProps({
padding: 10px;
width: 100%;
min-width: 140px;
}
.robot-image {
flex-shrink: 0;
margin-right: 20px;
/* margin-right: 20px; */
padding: 4px 2px;
min-width: 140px;
width: 140px;
display: flex;
align-items: center;
justify-content: center;
background: url("../../assets/img/border_img.png") no-repeat;
background-size: 100% 100%;
}
@ -49,17 +51,21 @@ const props = defineProps({
max-width: 100%;
max-height: 100%;
display: block;
}
}
.info-list {
flex-grow: 1;
display: flex;
display: flex;
flex-direction: column;
justify-content: space-around;
color: #a0aec0;
padding: 0 10px;
/* background: linear-gradient(to bottom, #00273A 10%, #00273A 80%); */
/* border:1px solid red; */
}
.info-item {
.info-item {
display: flex;
justify-content: space-between;
align-items: center;
@ -85,6 +91,7 @@ const props = defineProps({
width: 8px;
height: 8px;
background: url("../../assets/img/bt.png");
background-size: 100% 100%;
border-radius: 50%;
margin-right: 10px;
}
@ -93,7 +100,7 @@ const props = defineProps({
font-size: 16px;
}
@media (max-width: 640px) {
/* @media (max-width: 640px) {
.basic-info-card {
flex-direction: column;
width: 90%;
@ -116,5 +123,5 @@ const props = defineProps({
.info-value {
font-size: 16px;
}
}
} */
</style>

View File

@ -1,846 +0,0 @@
<template>
<div class="webrtc-player" :class="{ 'is-loading': loading, 'has-error': error }">
<video ref="videoRef" autoplay playsinline muted controls></video>
<div v-if="loading" class="loading-overlay">
<span>加载中...</span>
<div class="loading-spinner"></div>
</div>
<div v-if="error" class="error-overlay">
<span>{{ error }}</span>
<button v-if="error" @click="retry" class="retry-btn">重试</button>
</div>
<div v-if="debug && status" class="status-indicator" :class="status">
{{ statusText }}
</div>
<!-- 调试面板 -->
<div v-if="debug && showDebugPanel" class="debug-panel">
<div class="debug-header">
<span>WebRTC调试信息</span>
<button class="close-btn" @click="showDebugPanel = false">×</button>
</div>
<div class="debug-content">
<div class="debug-section">
<h4>连接信息</h4>
<p><strong>状态:</strong> {{ status }}</p>
<p><strong>重试次数:</strong> {{ retryCount }}/{{ MAX_RETRY }}</p>
<p><strong>请求URL:</strong> {{ debugInfo.requestUrl }}</p>
<p><strong>应用名称:</strong> {{ debugInfo.appName }}</p>
<p><strong>流ID:</strong> {{ debugInfo.streamId }}</p>
</div>
<div v-if="debugInfo.codecs.video.length || debugInfo.codecs.audio.length" class="debug-section">
<h4>编解码器信息</h4>
<div v-if="debugInfo.codecs.video.length">
<strong>视频:</strong> {{ debugInfo.codecs.video.join(', ') }}
</div>
<div v-if="debugInfo.codecs.audio.length">
<strong>音频:</strong> {{ debugInfo.codecs.audio.join(', ') }}
</div>
</div>
<div v-if="sdpInfo.offer || sdpInfo.answer" class="debug-section">
<h4>SDP信息</h4>
<div v-if="sdpInfo.offer" class="sdp-box">
<strong>Offer SDP:</strong>
<pre>{{ sdpInfo.offer }}</pre>
</div>
<div v-if="sdpInfo.answer" class="sdp-box">
<strong>Answer SDP:</strong>
<pre>{{ sdpInfo.answer }}</pre>
</div>
</div>
<div v-if="iceCandidates.length > 0" class="debug-section">
<h4>ICE候选者 ({{ iceCandidates.length }})</h4>
<div class="sdp-box">
<pre>{{ iceCandidates.join('\n') }}</pre>
</div>
</div>
</div>
</div>
<!-- 调试按钮 -->
<button v-if="debug && !showDebugPanel" class="debug-toggle-btn" @click="showDebugPanel = true">
调试
</button>
</div>
</template>
<script setup>
import { ref, onMounted, onUnmounted, watch, computed } from 'vue';
import 'webrtc-adapter';
// axios使JSON
const overrideZLMRTCClientAxios = () => {
if (!window.ZLMRTCClient || !window.ZLMRTCClient.Endpoint) {
console.error('ZLMRTCClient未加载无法重写axios方法');
return;
}
// axios
const originalAxios = window.axios;
// axioswindow便
window._originalAxios = originalAxios;
//
const wrappedAxios = (config) => {
// WebRTCSDP
if (config.url && config.url.includes('/rtc/v1/play') && config.data && typeof config.data === 'string') {
console.log('[WebRTCPlayer] 拦截到WebRTC请求转换为JSON格式');
//
const browserInfo = {
osName: navigator.platform.indexOf('Win') > -1 ? 'Windows' :
navigator.platform.indexOf('Mac') > -1 ? 'MacOS' :
navigator.platform.indexOf('Linux') > -1 ? 'Linux' : 'Unknown',
osVersion: navigator.userAgent.includes('Windows NT 10.0') ? '10' :
navigator.userAgent.includes('Windows NT 6.1') ? '7' : 'Unknown',
browserName: navigator.userAgent.includes('Chrome') ? 'Chrome' :
navigator.userAgent.includes('Firefox') ? 'Firefox' :
navigator.userAgent.includes('Safari') ? 'Safari' : 'Unknown',
browserVersion: navigator.userAgent.match(/Chrome\/([0-9.]+)/)?.[1] ||
navigator.userAgent.match(/Firefox\/([0-9.]+)/)?.[1] ||
navigator.userAgent.match(/Version\/([0-9.]+)/)?.[1] || 'Unknown',
SDK_VERSION: '1.0.9'
};
// URLstreamurl
const streamUrl = localStorage.getItem('current_stream_url') || '';
// JSON
const jsonData = {
clientip: JSON.stringify(browserInfo),
sdp: config.data, // SDP
streamurl: streamUrl
};
//
config.data = JSON.stringify(jsonData);
config.headers = {
...config.headers,
'Content-Type': 'application/json'
};
console.log('[WebRTCPlayer] 转换后的请求数据:', config.data);
}
// axios
const originalRequest = originalAxios(config);
//
return originalRequest.then(response => {
if (config.url && config.url.includes('/rtc/v1/play')) {
console.log('[WebRTCPlayer] 收到响应:', response);
}
return response;
}).catch(error => {
if (config.url && config.url.includes('/rtc/v1/play')) {
console.error('[WebRTCPlayer] 请求失败:', error);
//
if (error.response) {
console.error('[WebRTCPlayer] 错误响应:', {
status: error.response.status,
statusText: error.response.statusText,
data: error.response.data
});
}
}
return Promise.reject(error);
});
};
// window.axios
window.axios = wrappedAxios;
};
const props = defineProps({
url: {
type: String,
required: true
},
debug: {
type: Boolean,
default: false
}
});
const videoRef = ref(null);
const loading = ref(true);
const error = ref('');
const status = ref(''); // connecting, connected, failed, closed
let client = null;
let retryCount = ref(0);
const MAX_RETRY = 3;
let retryTimer = null;
//
const showDebugPanel = ref(false);
const sdpInfo = ref({
offer: '',
answer: ''
});
const iceCandidates = ref([]);
const debugInfo = ref({
requestUrl: '',
streamId: '',
appName: '',
codecs: {
video: [],
audio: []
}
});
//
const statusText = computed(() => {
switch (status.value) {
case 'connecting': return '连接中...';
case 'connected': return '已连接';
case 'failed': return '连接失败';
case 'closed': return '已关闭';
default: return '';
}
});
const initPlayer = async () => {
//
sdpInfo.value = {
offer: '',
answer: ''
};
iceCandidates.value = [];
debugInfo.value = {
requestUrl: '',
streamId: '',
appName: '',
codecs: {
video: [],
audio: []
}
};
if (!props.url) {
error.value = '无效的视频流地址';
loading.value = false;
status.value = 'failed';
return;
}
try {
loading.value = true;
error.value = '';
status.value = 'connecting';
// ZLMRTCClient
if (!window.ZLMRTCClient || !window.ZLMRTCClient.Endpoint) {
error.value = 'ZLMRTCClient未加载请刷新页面';
loading.value = false;
status.value = 'failed';
return;
}
//
const browserInfo = {
osName: navigator.platform.indexOf('Win') > -1 ? 'Windows' :
navigator.platform.indexOf('Mac') > -1 ? 'MacOS' :
navigator.platform.indexOf('Linux') > -1 ? 'Linux' : 'Unknown',
osVersion: navigator.userAgent.includes('Windows NT 10.0') ? '10' :
navigator.userAgent.includes('Windows NT 6.1') ? '7' : 'Unknown',
browserName: navigator.userAgent.includes('Chrome') ? 'Chrome' :
navigator.userAgent.includes('Firefox') ? 'Firefox' :
navigator.userAgent.includes('Safari') ? 'Safari' : 'Unknown',
browserVersion: navigator.userAgent.match(/Chrome\/([0-9.]+)/)?.[1] ||
navigator.userAgent.match(/Firefox\/([0-9.]+)/)?.[1] ||
navigator.userAgent.match(/Version\/([0-9.]+)/)?.[1] || 'Unknown',
SDK_VERSION: '1.0.9'
};
// URL
let server = props.url;
let streamId = '';
let appName = '';
// URL
if (!server.startsWith('http')) {
if (server.startsWith('webrtc:')) {
server = server.replace(/webrtc:/, 'https:');
} else {
server = `https://${server}`;
}
}
const urlObj = new URL(server);
// URL
const pathParts = urlObj.pathname.split('/').filter(part => part);
// URL
if (pathParts.length >= 2) {
// /appName/streamId
appName = pathParts[0];
streamId = pathParts[pathParts.length - 1]; // ID
}
// URL - /rtc/v1/playID
const zlmsdpUrl = `https://${urlObj.host}/rtc/v1/play`;
//
debugInfo.value.requestUrl = zlmsdpUrl;
debugInfo.value.streamId = streamId;
debugInfo.value.appName = appName;
console.log('[WebRTCPlayer] zlmsdpUrl:', zlmsdpUrl);
console.log('[WebRTCPlayer] 原始URL:', props.url);
console.log('[WebRTCPlayer] 提取的应用名称:', appName);
console.log('[WebRTCPlayer] 提取的流ID:', streamId);
// URLlocalStorage使
localStorage.setItem('current_stream_url', props.url);
// axios
overrideZLMRTCClientAxios();
// Endpoint
client = new window.ZLMRTCClient.Endpoint({
element: videoRef.value,
debug: props.debug,
zlmsdpUrl,
simulcast: false,
useCamera: false,
audioEnable: true, //
videoEnable: true,
recvOnly: true,
// WebRTC
rtcConfiguration: {
iceServers: [
{
urls: [
'stun:stun.l.google.com:19302',
'stun:stun1.l.google.com:19302',
'stun:stun2.l.google.com:19302'
]
}
],
iceTransportPolicy: 'all',
bundlePolicy: 'max-bundle',
rtcpMuxPolicy: 'require',
sdpSemantics: 'unified-plan' // 使SDP
},
// SDP
customizeSDPHandler: (sdp) => {
if (props.debug) {
console.log('[WebRTCPlayer] 原始SDP:', sdp);
}
// SDP
if (!sdp) {
console.error('[WebRTCPlayer] SDP为空');
return sdp;
}
// 1. 使 recvonly (使sendonly)
sdp = sdp.replace(/a=sendonly/g, 'a=recvonly');
// 2.
const sections = sdp.split('m=');
const header = sections[0];
const audio = sections.find(s => s.startsWith('audio'));
const video = sections.find(s => s.startsWith('video'));
let processedSdp = sdp;
if (audio && video) {
processedSdp = `${header}m=${audio}m=${video}`;
}
// 3. DTLS
// SDP使passive使active
processedSdp = processedSdp.replace(/a=setup:actpass/g, 'a=setup:active');
// 4. rtcp-fb
// SDPSDP
// 5. 使
// SDPH264使
if (props.debug) {
console.log('[WebRTCPlayer] 处理后SDP:', processedSdp);
}
return processedSdp;
}
});
//
client.on('WEBRTC_NOT_SUPPORT', () => {
error.value = '浏览器不支持WebRTC';
loading.value = false;
status.value = 'failed';
});
client.on('WEBRTC_ICE_CANDIDATE_ERROR', (err) => {
console.error('[WebRTCPlayer] ICE候选者错误:', err);
setTimeout(() => {
if (!videoRef.value.srcObject) {
error.value = 'ICE连接失败请检查网络';
loading.value = false;
status.value = 'failed';
//
if (retryCount.value < MAX_RETRY) {
console.log('[WebRTCPlayer] ICE连接失败自动重试...');
retry();
}
}
}, 5000);
});
// SDP
client.on('WEBRTC_SDP_OFFER_CREATED', (offer) => {
if (props.debug) {
console.log('[WebRTCPlayer] 创建SDP Offer:', offer.sdp);
console.log('[WebRTCPlayer] Offer类型:', offer.type);
sdpInfo.value.offer = offer.sdp;
}
});
client.on('WEBRTC_SDP_ANSWER_RECEIVED', (answer) => {
if (props.debug) {
console.log('[WebRTCPlayer] 收到SDP Answer:', answer.sdp);
console.log('[WebRTCPlayer] Answer类型:', answer.type);
console.log('[WebRTCPlayer] 完整响应:', answer);
// answer.sdp
if (answer && answer.sdp) {
sdpInfo.value.answer = answer.sdp;
// SDP
const videoCodecs = [];
const audioCodecs = [];
//
const videoSection = answer.sdp.split('m=video')[1];
if (videoSection) {
const rtpmapRegex = /a=rtpmap:(\d+) ([^/]+)/g;
let match;
while ((match = rtpmapRegex.exec(videoSection)) !== null) {
videoCodecs.push(`${match[2]} (${match[1]})`);
}
}
//
const audioSection = answer.sdp.split('m=audio')[1];
if (audioSection && audioSection.split('m=')[0]) {
const rtpmapRegex = /a=rtpmap:(\d+) ([^/]+)/g;
let match;
while ((match = rtpmapRegex.exec(audioSection.split('m=')[0])) !== null) {
audioCodecs.push(`${match[2]} (${match[1]})`);
}
}
//
debugInfo.value.codecs.video = videoCodecs;
debugInfo.value.codecs.audio = audioCodecs;
console.log('[WebRTCPlayer] 协商的视频编解码器:', videoCodecs);
console.log('[WebRTCPlayer] 协商的音频编解码器:', audioCodecs);
} else {
console.error('[WebRTCPlayer] 收到的SDP Answer为空或格式不正确');
}
}
});
// ICE
client.on('WEBRTC_ICE_CANDIDATE', (candidate) => {
if (props.debug) {
console.log('[WebRTCPlayer] ICE候选者:', candidate);
if (candidate && candidate.candidate) {
// ICE
const candidateType = candidate.candidate.split('typ ')[1]?.split(' ')[0];
console.log('[WebRTCPlayer] ICE候选者类型:', candidateType);
iceCandidates.value.push(candidate.candidate);
}
}
});
// ICE
client.on('WEBRTC_ICE_CONNECTION_STATE_CHANGE', (state) => {
if (props.debug) {
console.log('[WebRTCPlayer] ICE连接状态变化:', state);
}
});
client.on('WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED', (err) => {
console.error('[WebRTCPlayer] 信令交换失败:', err);
error.value = '信令交换失败,请重试';
loading.value = false;
status.value = 'failed';
//
if (retryCount.value < MAX_RETRY) {
console.log('[WebRTCPlayer] 信令交换失败,自动重试...');
retry();
}
});
//
client.on('WEBRTC_REQUEST_BEFORE_SEND', (request) => {
if (props.debug) {
console.log('[WebRTCPlayer] 发送请求前:', request);
// 便
try {
if (request && request.data) {
const requestData = typeof request.data === 'string' ? JSON.parse(request.data) : request.data;
console.log('[WebRTCPlayer] 请求体解析:', {
url: request.url,
method: request.method,
clientip: requestData.clientip ? '已设置' : '未设置',
sdp: requestData.sdp ? '已设置' : '未设置',
streamurl: requestData.streamurl
});
}
} catch (err) {
console.error('[WebRTCPlayer] 解析请求体失败:', err);
}
}
});
client.on('WEBRTC_REQUEST_AFTER_RESPONSE', (response) => {
if (props.debug) {
console.log('[WebRTCPlayer] 收到响应后:', response);
//
if (response && response.status) {
console.log('[WebRTCPlayer] 响应状态码:', response.status);
//
if (response.status !== 200) {
console.error('[WebRTCPlayer] 请求失败:', {
status: response.status,
statusText: response.statusText,
data: response.data
});
}
}
}
});
client.on('WEBRTC_ON_REMOTE_STREAMS', (stream) => {
if (videoRef.value && stream) {
console.log('[WebRTCPlayer] 收到远程流');
videoRef.value.srcObject = stream;
loading.value = false;
error.value = '';
status.value = 'connected';
//
retryCount.value = 0;
//
videoRef.value.onplaying = () => {
console.log('[WebRTCPlayer] 视频开始播放');
};
//
videoRef.value.onerror = (e) => {
console.error('[WebRTCPlayer] 视频播放错误:', e);
error.value = '视频播放错误';
status.value = 'failed';
};
}
});
client.on('WEBRTC_ON_CONNECTION_STATE_CHANGE', (state) => {
console.log('[WebRTCPlayer] 连接状态变化:', state);
if (state === 'connected') {
status.value = 'connected';
} else if (state === 'failed' || state === 'disconnected') {
if (!videoRef.value.srcObject) {
error.value = '连接已断开';
loading.value = false;
status.value = 'failed';
if (retryCount.value < MAX_RETRY) {
console.log('[WebRTCPlayer] 连接断开,自动重试...');
retry();
}
}
} else if (state === 'closed') {
status.value = 'closed';
}
});
//
console.log('[WebRTCPlayer] 开始接收流...');
await client.receive();
} catch (err) {
console.error('[WebRTCPlayer] 播放器初始化失败:', err);
error.value = err.message || '播放器初始化失败';
loading.value = false;
status.value = 'failed';
if (err.name === 'AxiosError' && err.message === 'Network Error') {
if (retryCount.value < MAX_RETRY) {
console.log('[WebRTCPlayer] 网络错误,自动重试...');
retry();
}
}
}
};
const retry = async () => {
//
if (retryTimer) {
clearTimeout(retryTimer);
retryTimer = null;
}
if (retryCount.value >= MAX_RETRY) {
error.value = `重试次数过多(${retryCount.value}/${MAX_RETRY}),请刷新页面`;
return;
}
retryCount.value++;
console.log(`[WebRTCPlayer] 第${retryCount.value}次重试`);
//
cleanupResources();
//
if (props.debug) {
console.log('[WebRTCPlayer] 重试信息:', {
url: props.url,
retryCount: retryCount.value,
maxRetry: MAX_RETRY
});
}
//
retryTimer = setTimeout(async () => {
await initPlayer();
}, 2000);
};
//
const cleanupResources = () => {
if (client) {
try {
client.close();
} catch (err) {
console.error('[WebRTCPlayer] 关闭client出错:', err);
}
client = null;
}
if (videoRef.value && videoRef.value.srcObject) {
try {
const tracks = videoRef.value.srcObject.getTracks();
tracks.forEach(track => track.stop());
videoRef.value.srcObject = null;
} catch (err) {
console.error('[WebRTCPlayer] 释放媒体流资源出错:', err);
}
}
};
// URL
watch(() => props.url, async (newUrl, oldUrl) => {
if (newUrl !== oldUrl) {
console.log('[WebRTCPlayer] URL变化重新初始化播放器');
cleanupResources();
retryCount.value = 0;
await initPlayer();
}
});
onMounted(async () => {
console.log('[WebRTCPlayer] 组件挂载,初始化播放器');
await initPlayer();
});
onUnmounted(() => {
console.log('[WebRTCPlayer] 组件卸载,清理资源');
//
if (retryTimer) {
clearTimeout(retryTimer);
retryTimer = null;
}
// axios
if (window._originalAxios) {
console.log('[WebRTCPlayer] 恢复原始axios');
window.axios = window._originalAxios;
window._originalAxios = null;
}
// localStorageURL
localStorage.removeItem('current_stream_url');
cleanupResources();
});
</script>
<style scoped>
.webrtc-player {
width: 100%;
height: 100%;
position: relative;
background: #000;
}
.webrtc-player video {
width: 100%;
height: 100%;
object-fit: contain;
}
.loading-overlay,
.error-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: rgba(0, 0, 0, 0.7);
color: #fff;
}
.loading-spinner {
width: 40px;
height: 40px;
margin-top: 10px;
border: 4px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top-color: #00ffff;
animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.retry-btn {
margin-top: 10px;
padding: 5px 15px;
border: none;
border-radius: 4px;
background: #0091A9;
color: #fff;
cursor: pointer;
}
.retry-btn:hover {
background: #007a8f;
}
.status-indicator {
position: absolute;
top: 10px;
right: 10px;
padding: 5px 10px;
border-radius: 4px;
font-size: 12px;
background: rgba(0, 0, 0, 0.5);
}
.status-indicator.connecting {
color: #ffff00;
}
.status-indicator.connected {
color: #00ff00;
}
.status-indicator.failed {
color: #ff0000;
}
.status-indicator.closed {
color: #888888;
}
.debug-panel {
position: absolute;
top: 10px;
right: 10px;
padding: 10px;
border-radius: 4px;
background: rgba(0, 0, 0, 0.7);
color: #fff;
width: 300px;
max-height: 400px;
overflow-y: auto;
z-index: 100;
font-size: 12px;
}
.debug-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
padding-bottom: 5px;
}
.close-btn {
background: none;
border: none;
color: #fff;
font-size: 16px;
cursor: pointer;
}
.debug-content {
display: flex;
flex-direction: column;
}
.debug-section {
margin-bottom: 10px;
}
.debug-section h4 {
margin: 5px 0;
color: #00ffff;
}
.sdp-box {
background: rgba(255, 255, 255, 0.1);
padding: 5px;
border-radius: 4px;
margin-bottom: 5px;
overflow-x: auto;
}
.sdp-box pre {
margin: 0;
white-space: pre-wrap;
word-break: break-all;
font-family: monospace;
font-size: 10px;
}
.debug-toggle-btn {
position: absolute;
top: 10px;
left: 10px;
padding: 5px 10px;
border: none;
border-radius: 4px;
background: rgba(0, 0, 0, 0.5);
color: #00ffff;
cursor: pointer;
z-index: 100;
font-size: 12px;
}
.debug-toggle-btn:hover {
background: rgba(0, 0, 0, 0.8);
}
</style>

View File

@ -1,846 +0,0 @@
<template>
<div class="webrtc-player" :class="{ 'is-loading': loading, 'has-error': error }">
<video ref="videoRef" autoplay playsinline muted controls></video>
<div v-if="loading" class="loading-overlay">
<span>加载中...</span>
<div class="loading-spinner"></div>
</div>
<div v-if="error" class="error-overlay">
<span>{{ error }}</span>
<button v-if="error" @click="retry" class="retry-btn">重试</button>
</div>
<div v-if="debug && status" class="status-indicator" :class="status">
{{ statusText }}
</div>
<!-- 调试面板 -->
<div v-if="debug && showDebugPanel" class="debug-panel">
<div class="debug-header">
<span>WebRTC调试信息</span>
<button class="close-btn" @click="showDebugPanel = false">×</button>
</div>
<div class="debug-content">
<div class="debug-section">
<h4>连接信息</h4>
<p><strong>状态:</strong> {{ status }}</p>
<p><strong>重试次数:</strong> {{ retryCount }}/{{ MAX_RETRY }}</p>
<p><strong>请求URL:</strong> {{ debugInfo.requestUrl }}</p>
<p><strong>应用名称:</strong> {{ debugInfo.appName }}</p>
<p><strong>流ID:</strong> {{ debugInfo.streamId }}</p>
</div>
<div v-if="debugInfo.codecs.video.length || debugInfo.codecs.audio.length" class="debug-section">
<h4>编解码器信息</h4>
<div v-if="debugInfo.codecs.video.length">
<strong>视频:</strong> {{ debugInfo.codecs.video.join(', ') }}
</div>
<div v-if="debugInfo.codecs.audio.length">
<strong>音频:</strong> {{ debugInfo.codecs.audio.join(', ') }}
</div>
</div>
<div v-if="sdpInfo.offer || sdpInfo.answer" class="debug-section">
<h4>SDP信息</h4>
<div v-if="sdpInfo.offer" class="sdp-box">
<strong>Offer SDP:</strong>
<pre>{{ sdpInfo.offer }}</pre>
</div>
<div v-if="sdpInfo.answer" class="sdp-box">
<strong>Answer SDP:</strong>
<pre>{{ sdpInfo.answer }}</pre>
</div>
</div>
<div v-if="iceCandidates.length > 0" class="debug-section">
<h4>ICE候选者 ({{ iceCandidates.length }})</h4>
<div class="sdp-box">
<pre>{{ iceCandidates.join('\n') }}</pre>
</div>
</div>
</div>
</div>
<!-- 调试按钮 -->
<button v-if="debug && !showDebugPanel" class="debug-toggle-btn" @click="showDebugPanel = true">
调试
</button>
</div>
</template>
<script setup>
import { ref, onMounted, onUnmounted, watch, computed } from 'vue';
import 'webrtc-adapter';
// axios使JSON
const overrideZLMRTCClientAxios = () => {
if (!window.ZLMRTCClient || !window.ZLMRTCClient.Endpoint) {
console.error('ZLMRTCClient未加载无法重写axios方法');
return;
}
// axios
const originalAxios = window.axios;
// axioswindow便
window._originalAxios = originalAxios;
//
const wrappedAxios = (config) => {
// WebRTCSDP
if (config.url && config.url.includes('/rtc/v1/play') && config.data && typeof config.data === 'string') {
console.log('[WebRTCPlayer] 拦截到WebRTC请求转换为JSON格式');
//
const browserInfo = {
osName: navigator.platform.indexOf('Win') > -1 ? 'Windows' :
navigator.platform.indexOf('Mac') > -1 ? 'MacOS' :
navigator.platform.indexOf('Linux') > -1 ? 'Linux' : 'Unknown',
osVersion: navigator.userAgent.includes('Windows NT 10.0') ? '10' :
navigator.userAgent.includes('Windows NT 6.1') ? '7' : 'Unknown',
browserName: navigator.userAgent.includes('Chrome') ? 'Chrome' :
navigator.userAgent.includes('Firefox') ? 'Firefox' :
navigator.userAgent.includes('Safari') ? 'Safari' : 'Unknown',
browserVersion: navigator.userAgent.match(/Chrome\/([0-9.]+)/)?.[1] ||
navigator.userAgent.match(/Firefox\/([0-9.]+)/)?.[1] ||
navigator.userAgent.match(/Version\/([0-9.]+)/)?.[1] || 'Unknown',
SDK_VERSION: '1.0.9'
};
// URLstreamurl
const streamUrl = localStorage.getItem('current_stream_url') || '';
// JSON
const jsonData = {
clientip: JSON.stringify(browserInfo),
sdp: config.data, // SDP
streamurl: streamUrl
};
//
config.data = JSON.stringify(jsonData);
config.headers = {
...config.headers,
'Content-Type': 'application/json'
};
console.log('[WebRTCPlayer] 转换后的请求数据:', config.data);
}
// axios
const originalRequest = originalAxios(config);
//
return originalRequest.then(response => {
if (config.url && config.url.includes('/rtc/v1/play')) {
console.log('[WebRTCPlayer] 收到响应:', response);
}
return response;
}).catch(error => {
if (config.url && config.url.includes('/rtc/v1/play')) {
console.error('[WebRTCPlayer] 请求失败:', error);
//
if (error.response) {
console.error('[WebRTCPlayer] 错误响应:', {
status: error.response.status,
statusText: error.response.statusText,
data: error.response.data
});
}
}
return Promise.reject(error);
});
};
// window.axios
window.axios = wrappedAxios;
};
const props = defineProps({
url: {
type: String,
required: true
},
debug: {
type: Boolean,
default: false
}
});
const videoRef = ref(null);
const loading = ref(true);
const error = ref('');
const status = ref(''); // connecting, connected, failed, closed
let client = null;
let retryCount = ref(0);
const MAX_RETRY = 3;
let retryTimer = null;
//
const showDebugPanel = ref(false);
const sdpInfo = ref({
offer: '',
answer: ''
});
const iceCandidates = ref([]);
const debugInfo = ref({
requestUrl: '',
streamId: '',
appName: '',
codecs: {
video: [],
audio: []
}
});
//
const statusText = computed(() => {
switch (status.value) {
case 'connecting': return '连接中...';
case 'connected': return '已连接';
case 'failed': return '连接失败';
case 'closed': return '已关闭';
default: return '';
}
});
const initPlayer = async () => {
//
sdpInfo.value = {
offer: '',
answer: ''
};
iceCandidates.value = [];
debugInfo.value = {
requestUrl: '',
streamId: '',
appName: '',
codecs: {
video: [],
audio: []
}
};
if (!props.url) {
error.value = '无效的视频流地址';
loading.value = false;
status.value = 'failed';
return;
}
try {
loading.value = true;
error.value = '';
status.value = 'connecting';
// ZLMRTCClient
if (!window.ZLMRTCClient || !window.ZLMRTCClient.Endpoint) {
error.value = 'ZLMRTCClient未加载请刷新页面';
loading.value = false;
status.value = 'failed';
return;
}
//
const browserInfo = {
osName: navigator.platform.indexOf('Win') > -1 ? 'Windows' :
navigator.platform.indexOf('Mac') > -1 ? 'MacOS' :
navigator.platform.indexOf('Linux') > -1 ? 'Linux' : 'Unknown',
osVersion: navigator.userAgent.includes('Windows NT 10.0') ? '10' :
navigator.userAgent.includes('Windows NT 6.1') ? '7' : 'Unknown',
browserName: navigator.userAgent.includes('Chrome') ? 'Chrome' :
navigator.userAgent.includes('Firefox') ? 'Firefox' :
navigator.userAgent.includes('Safari') ? 'Safari' : 'Unknown',
browserVersion: navigator.userAgent.match(/Chrome\/([0-9.]+)/)?.[1] ||
navigator.userAgent.match(/Firefox\/([0-9.]+)/)?.[1] ||
navigator.userAgent.match(/Version\/([0-9.]+)/)?.[1] || 'Unknown',
SDK_VERSION: '1.0.9'
};
// URL
let server = props.url;
let streamId = '';
let appName = '';
// URL
if (!server.startsWith('http')) {
if (server.startsWith('webrtc:')) {
server = server.replace(/webrtc:/, 'https:');
} else {
server = `https://${server}`;
}
}
const urlObj = new URL(server);
// URL
const pathParts = urlObj.pathname.split('/').filter(part => part);
// URL
if (pathParts.length >= 2) {
// /appName/streamId
appName = pathParts[0];
streamId = pathParts[pathParts.length - 1]; // ID
}
// URL - /rtc/v1/playID
const zlmsdpUrl = `https://${urlObj.host}/rtc/v1/play`;
//
debugInfo.value.requestUrl = zlmsdpUrl;
debugInfo.value.streamId = streamId;
debugInfo.value.appName = appName;
console.log('[WebRTCPlayer] zlmsdpUrl:', zlmsdpUrl);
console.log('[WebRTCPlayer] 原始URL:', props.url);
console.log('[WebRTCPlayer] 提取的应用名称:', appName);
console.log('[WebRTCPlayer] 提取的流ID:', streamId);
// URLlocalStorage使
localStorage.setItem('current_stream_url', props.url);
// axios
overrideZLMRTCClientAxios();
// Endpoint
client = new window.ZLMRTCClient.Endpoint({
element: videoRef.value,
debug: props.debug,
zlmsdpUrl,
simulcast: false,
useCamera: false,
audioEnable: true, //
videoEnable: true,
recvOnly: true,
// WebRTC
rtcConfiguration: {
iceServers: [
{
urls: [
'stun:stun.l.google.com:19302',
'stun:stun1.l.google.com:19302',
'stun:stun2.l.google.com:19302'
]
}
],
iceTransportPolicy: 'all',
bundlePolicy: 'max-bundle',
rtcpMuxPolicy: 'require',
sdpSemantics: 'unified-plan' // 使SDP
},
// SDP
customizeSDPHandler: (sdp) => {
if (props.debug) {
console.log('[WebRTCPlayer] 原始SDP:', sdp);
}
// SDP
if (!sdp) {
console.error('[WebRTCPlayer] SDP为空');
return sdp;
}
// 1. 使 recvonly (使sendonly)
sdp = sdp.replace(/a=sendonly/g, 'a=recvonly');
// 2.
const sections = sdp.split('m=');
const header = sections[0];
const audio = sections.find(s => s.startsWith('audio'));
const video = sections.find(s => s.startsWith('video'));
let processedSdp = sdp;
if (audio && video) {
processedSdp = `${header}m=${audio}m=${video}`;
}
// 3. DTLS
// SDP使passive使active
processedSdp = processedSdp.replace(/a=setup:actpass/g, 'a=setup:active');
// 4. rtcp-fb
// SDPSDP
// 5. 使
// SDPH264使
if (props.debug) {
console.log('[WebRTCPlayer] 处理后SDP:', processedSdp);
}
return processedSdp;
}
});
//
client.on('WEBRTC_NOT_SUPPORT', () => {
error.value = '浏览器不支持WebRTC';
loading.value = false;
status.value = 'failed';
});
client.on('WEBRTC_ICE_CANDIDATE_ERROR', (err) => {
console.error('[WebRTCPlayer] ICE候选者错误:', err);
setTimeout(() => {
if (!videoRef.value.srcObject) {
error.value = 'ICE连接失败请检查网络';
loading.value = false;
status.value = 'failed';
//
if (retryCount.value < MAX_RETRY) {
console.log('[WebRTCPlayer] ICE连接失败自动重试...');
retry();
}
}
}, 5000);
});
// SDP
client.on('WEBRTC_SDP_OFFER_CREATED', (offer) => {
if (props.debug) {
console.log('[WebRTCPlayer] 创建SDP Offer:', offer.sdp);
console.log('[WebRTCPlayer] Offer类型:', offer.type);
sdpInfo.value.offer = offer.sdp;
}
});
client.on('WEBRTC_SDP_ANSWER_RECEIVED', (answer) => {
if (props.debug) {
console.log('[WebRTCPlayer] 收到SDP Answer:', answer.sdp);
console.log('[WebRTCPlayer] Answer类型:', answer.type);
console.log('[WebRTCPlayer] 完整响应:', answer);
// answer.sdp
if (answer && answer.sdp) {
sdpInfo.value.answer = answer.sdp;
// SDP
const videoCodecs = [];
const audioCodecs = [];
//
const videoSection = answer.sdp.split('m=video')[1];
if (videoSection) {
const rtpmapRegex = /a=rtpmap:(\d+) ([^/]+)/g;
let match;
while ((match = rtpmapRegex.exec(videoSection)) !== null) {
videoCodecs.push(`${match[2]} (${match[1]})`);
}
}
//
const audioSection = answer.sdp.split('m=audio')[1];
if (audioSection && audioSection.split('m=')[0]) {
const rtpmapRegex = /a=rtpmap:(\d+) ([^/]+)/g;
let match;
while ((match = rtpmapRegex.exec(audioSection.split('m=')[0])) !== null) {
audioCodecs.push(`${match[2]} (${match[1]})`);
}
}
//
debugInfo.value.codecs.video = videoCodecs;
debugInfo.value.codecs.audio = audioCodecs;
console.log('[WebRTCPlayer] 协商的视频编解码器:', videoCodecs);
console.log('[WebRTCPlayer] 协商的音频编解码器:', audioCodecs);
} else {
console.error('[WebRTCPlayer] 收到的SDP Answer为空或格式不正确');
}
}
});
// ICE
client.on('WEBRTC_ICE_CANDIDATE', (candidate) => {
if (props.debug) {
console.log('[WebRTCPlayer] ICE候选者:', candidate);
if (candidate && candidate.candidate) {
// ICE
const candidateType = candidate.candidate.split('typ ')[1]?.split(' ')[0];
console.log('[WebRTCPlayer] ICE候选者类型:', candidateType);
iceCandidates.value.push(candidate.candidate);
}
}
});
// ICE
client.on('WEBRTC_ICE_CONNECTION_STATE_CHANGE', (state) => {
if (props.debug) {
console.log('[WebRTCPlayer] ICE连接状态变化:', state);
}
});
client.on('WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED', (err) => {
console.error('[WebRTCPlayer] 信令交换失败:', err);
error.value = '信令交换失败,请重试';
loading.value = false;
status.value = 'failed';
//
if (retryCount.value < MAX_RETRY) {
console.log('[WebRTCPlayer] 信令交换失败,自动重试...');
retry();
}
});
//
client.on('WEBRTC_REQUEST_BEFORE_SEND', (request) => {
if (props.debug) {
console.log('[WebRTCPlayer] 发送请求前:', request);
// 便
try {
if (request && request.data) {
const requestData = typeof request.data === 'string' ? JSON.parse(request.data) : request.data;
console.log('[WebRTCPlayer] 请求体解析:', {
url: request.url,
method: request.method,
clientip: requestData.clientip ? '已设置' : '未设置',
sdp: requestData.sdp ? '已设置' : '未设置',
streamurl: requestData.streamurl
});
}
} catch (err) {
console.error('[WebRTCPlayer] 解析请求体失败:', err);
}
}
});
client.on('WEBRTC_REQUEST_AFTER_RESPONSE', (response) => {
if (props.debug) {
console.log('[WebRTCPlayer] 收到响应后:', response);
//
if (response && response.status) {
console.log('[WebRTCPlayer] 响应状态码:', response.status);
//
if (response.status !== 200) {
console.error('[WebRTCPlayer] 请求失败:', {
status: response.status,
statusText: response.statusText,
data: response.data
});
}
}
}
});
client.on('WEBRTC_ON_REMOTE_STREAMS', (stream) => {
if (videoRef.value && stream) {
console.log('[WebRTCPlayer] 收到远程流');
videoRef.value.srcObject = stream;
loading.value = false;
error.value = '';
status.value = 'connected';
//
retryCount.value = 0;
//
videoRef.value.onplaying = () => {
console.log('[WebRTCPlayer] 视频开始播放');
};
//
videoRef.value.onerror = (e) => {
console.error('[WebRTCPlayer] 视频播放错误:', e);
error.value = '视频播放错误';
status.value = 'failed';
};
}
});
client.on('WEBRTC_ON_CONNECTION_STATE_CHANGE', (state) => {
console.log('[WebRTCPlayer] 连接状态变化:', state);
if (state === 'connected') {
status.value = 'connected';
} else if (state === 'failed' || state === 'disconnected') {
if (!videoRef.value.srcObject) {
error.value = '连接已断开';
loading.value = false;
status.value = 'failed';
if (retryCount.value < MAX_RETRY) {
console.log('[WebRTCPlayer] 连接断开,自动重试...');
retry();
}
}
} else if (state === 'closed') {
status.value = 'closed';
}
});
//
console.log('[WebRTCPlayer] 开始接收流...');
await client.receive();
} catch (err) {
console.error('[WebRTCPlayer] 播放器初始化失败:', err);
error.value = err.message || '播放器初始化失败';
loading.value = false;
status.value = 'failed';
if (err.name === 'AxiosError' && err.message === 'Network Error') {
if (retryCount.value < MAX_RETRY) {
console.log('[WebRTCPlayer] 网络错误,自动重试...');
retry();
}
}
}
};
const retry = async () => {
//
if (retryTimer) {
clearTimeout(retryTimer);
retryTimer = null;
}
if (retryCount.value >= MAX_RETRY) {
error.value = `重试次数过多(${retryCount.value}/${MAX_RETRY}),请刷新页面`;
return;
}
retryCount.value++;
console.log(`[WebRTCPlayer] 第${retryCount.value}次重试`);
//
cleanupResources();
//
if (props.debug) {
console.log('[WebRTCPlayer] 重试信息:', {
url: props.url,
retryCount: retryCount.value,
maxRetry: MAX_RETRY
});
}
//
retryTimer = setTimeout(async () => {
await initPlayer();
}, 2000);
};
//
const cleanupResources = () => {
if (client) {
try {
client.close();
} catch (err) {
console.error('[WebRTCPlayer] 关闭client出错:', err);
}
client = null;
}
if (videoRef.value && videoRef.value.srcObject) {
try {
const tracks = videoRef.value.srcObject.getTracks();
tracks.forEach(track => track.stop());
videoRef.value.srcObject = null;
} catch (err) {
console.error('[WebRTCPlayer] 释放媒体流资源出错:', err);
}
}
};
// URL
watch(() => props.url, async (newUrl, oldUrl) => {
if (newUrl !== oldUrl) {
console.log('[WebRTCPlayer] URL变化重新初始化播放器');
cleanupResources();
retryCount.value = 0;
await initPlayer();
}
});
onMounted(async () => {
console.log('[WebRTCPlayer] 组件挂载,初始化播放器');
await initPlayer();
});
onUnmounted(() => {
console.log('[WebRTCPlayer] 组件卸载,清理资源');
//
if (retryTimer) {
clearTimeout(retryTimer);
retryTimer = null;
}
// axios
if (window._originalAxios) {
console.log('[WebRTCPlayer] 恢复原始axios');
window.axios = window._originalAxios;
window._originalAxios = null;
}
// localStorageURL
localStorage.removeItem('current_stream_url');
cleanupResources();
});
</script>
<style scoped>
.webrtc-player {
width: 100%;
height: 100%;
position: relative;
background: #000;
}
.webrtc-player video {
width: 100%;
height: 100%;
object-fit: contain;
}
.loading-overlay,
.error-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: rgba(0, 0, 0, 0.7);
color: #fff;
}
.loading-spinner {
width: 40px;
height: 40px;
margin-top: 10px;
border: 4px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top-color: #00ffff;
animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.retry-btn {
margin-top: 10px;
padding: 5px 15px;
border: none;
border-radius: 4px;
background: #0091A9;
color: #fff;
cursor: pointer;
}
.retry-btn:hover {
background: #007a8f;
}
.status-indicator {
position: absolute;
top: 10px;
right: 10px;
padding: 5px 10px;
border-radius: 4px;
font-size: 12px;
background: rgba(0, 0, 0, 0.5);
}
.status-indicator.connecting {
color: #ffff00;
}
.status-indicator.connected {
color: #00ff00;
}
.status-indicator.failed {
color: #ff0000;
}
.status-indicator.closed {
color: #888888;
}
.debug-panel {
position: absolute;
top: 10px;
right: 10px;
padding: 10px;
border-radius: 4px;
background: rgba(0, 0, 0, 0.7);
color: #fff;
width: 300px;
max-height: 400px;
overflow-y: auto;
z-index: 100;
font-size: 12px;
}
.debug-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
padding-bottom: 5px;
}
.close-btn {
background: none;
border: none;
color: #fff;
font-size: 16px;
cursor: pointer;
}
.debug-content {
display: flex;
flex-direction: column;
}
.debug-section {
margin-bottom: 10px;
}
.debug-section h4 {
margin: 5px 0;
color: #00ffff;
}
.sdp-box {
background: rgba(255, 255, 255, 0.1);
padding: 5px;
border-radius: 4px;
margin-bottom: 5px;
overflow-x: auto;
}
.sdp-box pre {
margin: 0;
white-space: pre-wrap;
word-break: break-all;
font-family: monospace;
font-size: 10px;
}
.debug-toggle-btn {
position: absolute;
top: 10px;
left: 10px;
padding: 5px 10px;
border: none;
border-radius: 4px;
background: rgba(0, 0, 0, 0.5);
color: #00ffff;
cursor: pointer;
z-index: 100;
font-size: 12px;
}
.debug-toggle-btn:hover {
background: rgba(0, 0, 0, 0.8);
}
</style>

View File

@ -1,78 +0,0 @@
<template>
<div class="example-container">
<h3>WebRTC播放器示例</h3>
<div class="player-container">
<CustomWebRTCPlayer
:url="playUrl"
:streamUrl="streamUrl"
:debug="true"
/>
</div>
<div class="controls">
<button @click="startPlay">开始播放</button>
</div>
</div>
</template>
<script setup>
import { ref } from 'vue';
import CustomWebRTCPlayer from './CustomWebRTCPlayer.vue';
//
const playUrl = ref('https://qvs-live.thirdmonitor.concoai.com:447/rtc/v1/play');
//
const streamUrl = ref('webrtc://qvs-live.thirdmonitor.concoai.com:447/2xenzwqy2ppcl/31011500991180041301_34020000001320000001');
//
const clientInfo = {
osName: 'Windows',
osVersion: '10',
browserName: 'Chrome',
browserVersion: '137.0.0.0',
SDK_VERSION: '1.0.9'
};
//
const startPlay = () => {
console.log('开始播放WebRTC流');
// URL
playUrl.value = 'https://qvs-live.thirdmonitor.concoai.com:447/rtc/v1/play';
streamUrl.value = 'webrtc://qvs-live.thirdmonitor.concoai.com:447/2xenzwqy2ppcl/31011500991180041301_34020000001320000001';
};
</script>
<style scoped>
.example-container {
width: 100%;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
.player-container {
width: 100%;
height: 450px;
margin-bottom: 20px;
border: 1px solid #333;
}
.controls {
display: flex;
justify-content: center;
gap: 10px;
}
button {
padding: 8px 16px;
background-color: #0091A9;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #007a8f;
}
</style>

View File

@ -26,13 +26,14 @@
alt=""
@error="imgLoadError.main = true"
v-show="!imgLoadError.main"
class="monitor-img-rounded"
/>
<EmptyState
v-if="imgLoadError.main"
subtitle="暂无信息"
title=""
iconSrc="empty"
class="video-empty-state"
class="video-empty-state monitor-img-rounded"
/>
</template>
<EmptyState
@ -40,7 +41,7 @@
subtitle="暂无信息"
title=""
:iconSrc="empty"
class="video-empty-state"
class="video-empty-state monitor-img-rounded"
/>
</div>
</div>
@ -60,13 +61,14 @@
alt=""
@error="imgLoadError.sub1 = true"
v-show="!imgLoadError.sub1"
class="monitor-img-rounded"
/>
<EmptyState
v-if="imgLoadError.sub1"
subtitle="暂无信息"
title=""
:iconSrc="empty"
class="video-empty-state"
class="video-empty-state monitor-img-rounded"
/>
</template>
<EmptyState
@ -74,7 +76,7 @@
subtitle="暂无信息"
title=""
:iconSrc="empty"
class="video-empty-state"
class="video-empty-state monitor-img-rounded"
/>
</div>
</div>
@ -93,13 +95,14 @@
alt=""
@error="imgLoadError.sub2 = true"
v-show="!imgLoadError.sub2"
class="monitor-img-rounded"
/>
<EmptyState
v-if="imgLoadError.sub2"
title=""
subtitle="暂无信息"
:iconSrc="empty"
class="video-empty-state"
class="video-empty-state monitor-img-rounded"
/>
</template>
<EmptyState
@ -107,7 +110,7 @@
title=""
subtitle="暂无信息"
:iconSrc="empty"
class="video-empty-state"
class="video-empty-state monitor-img-rounded"
/>
</div>
</div>
@ -127,7 +130,7 @@
</div>
<div class="info-item">
<p class="label">上报时间:</p>
<p class="value">{{ alarmData.time }}</p>
<p class="value">{{ alarmData.time.replace('T', ' ') }}</p>
</div>
<div class="info-item">
<p class="label">机器人名称:</p>
@ -245,6 +248,7 @@ watch(
{ immediate: true }
);
const handleClose = () => {
emit("update:visible", false);
};
@ -337,17 +341,18 @@ const updateRemark = (e) => {
flex-direction: column;
gap: 10px;
padding: 10px;
}
.main-camera {
width: 100%;
}
.camera-wrapper {
position: relative;
min-height: 240px;
/* border: 1px solid rgba(0,206,234,0.7); */
border-radius: 4px;
border-radius: 6px;
background: #033347; /* 设置底部矩形的背景色 */
}
@ -374,7 +379,7 @@ const updateRemark = (e) => {
font-size: 12px;
padding: 4px 8px;
background: rgba(0, 21, 31, 0.5);
border-radius: 2px;
border-radius:6px 6px 0px 0px;
text-align: left;
}
@ -402,12 +407,12 @@ const updateRemark = (e) => {
flex-direction: column;
justify-content: space-between;
gap: 20px;
}
.info-group {
background: rgba(0, 21, 31, 0.5);
background: #00273A;
border-radius: 4px;
border: 1px solid rgba(0, 206, 234, 0.7);
}
@ -419,7 +424,7 @@ const updateRemark = (e) => {
.info-content {
padding: 15px;
background: rgba(0, 21, 31, 0.2);
/* background: rgba(0, 21, 31, 0.2); */
/* border: 1px solid rgba(0,206,234,0.7); */
border-radius: 4px;
}
@ -544,4 +549,8 @@ const updateRemark = (e) => {
letter-spacing: 1px;
margin-top: 5px;
}
.monitor-img-rounded {
border-radius: 6px;
}
</style>

View File

@ -103,9 +103,11 @@ const handleCancel = () => {
display: flex;
justify-content: center;
align-items: center;
width: 48px;
height: 48px;
margin-right: 20px;
width: 2.5vw; /* 48px at 1920px width */
height: 2.5vw; /* 48px at 1920px width */
margin-right: 1.042vw; /* 20px at 1920px width */
min-width: 1.5vw;
min-height: 1.5vw;
}
.confirm-dialog-content {
height: 70%;

View File

@ -341,7 +341,7 @@ const handleReport = () => {
height: 800px;
background: url("../../assets/img/alert2.png") no-repeat;
background-size: 100% 100%;
border-radius: 4px;
border-radius: 6px;
padding: 20px;
display: flex;
flex-direction: column;
@ -389,13 +389,13 @@ const handleReport = () => {
flex-direction: column;
gap: 10px;
border:1px solid rgba(0,206,234,0.7);
border-radius: 4px;
border-radius: 6px;
}
.main-monitor, .monitor-item {
position: relative;
border: 1px solid rgba(0,206,234,0.7);
border-radius: 4px;
/* border: 1px solid rgba(0,206,234,0.7); */
border-radius: 6px;
overflow: hidden;
background: #033347; /* 设置底部矩形的背景色 */
}
@ -445,7 +445,7 @@ const handleReport = () => {
.event-info {
/* background: rgba(0, 21, 31, 0.5); */
border: 1px solid rgba(0,206,234,0.7);
border-radius: 4px;
border-radius: 6px;
}
.info-content {
@ -461,6 +461,7 @@ const handleReport = () => {
.table-header th {
padding:5px;
font-size: 14px;
text-align: center;
font-weight: normal;
border: 1px solid #244C60;
@ -479,11 +480,11 @@ const handleReport = () => {
}
.table-content td.已处理 {
color: #00FF84;
color: #00ffff;
}
.remark-section{
border:1px solid rgba(0,206,234,0.7);
border-radius: 4px;
border-radius: 6px;
height: 116px;
}
.remark-content {
@ -496,7 +497,7 @@ const handleReport = () => {
width: 100%;
min-height: 130px;
/* background: rgba(0, 21, 31, 0.3); */
border-radius: 4px;
border-radius: 6px;
color: #B9E8FF;
padding: 10px;
outline: none;

View File

@ -3,7 +3,7 @@
<div class="modal-content">
<!-- 标题 -->
<div class="modal-header">
<span class="title">机器人总数</span>
<span class="title">机器人统计</span>
<img src="../../assets/img/close.png" class="close-icon" @click="handleClose" />
</div>
@ -40,7 +40,7 @@
class="arrow-icon"
/>
<ul v-if="selectOpen" class="select-dropdown">
<li v-for="type in robotTypes" :key="type" @click.stop="selectType(type)">{{ type }}</li>
<li v-for="type in robotTypes" :key="type" @click.stop="selectType(type)" :class="{ active: selectedType === type }">{{ type }}</li>
</ul>
</div>
</div>
@ -83,6 +83,10 @@ const props = defineProps({
visible: {
type: Boolean,
default: false
},
activeTab: {
type: String,
default: 'all'
}
});
@ -206,7 +210,7 @@ const filteredRobots = computed(() => {
//
if (currentTab.value !== 'all') {
const statusMap = {
online: ['运行中', '待机中'],
online: ['充电中', '待机中', '运行中', '故障'],
offline: ['离线'],
fault: ['故障']
};
@ -228,7 +232,7 @@ const getTabCount = (type) => {
if (type === 'all') return robotList.value.length;
const statusMap = {
online: ['运行中', '待机中'],
online: ['充电中', '待机中', '运行中', '故障'],
offline: ['离线'],
fault: ['故障']
};
@ -237,10 +241,18 @@ const getTabCount = (type) => {
return robotList.value.filter(robot => statusList.includes(robot.status)).length;
};
// activeTabcurrentTab
watch(() => props.activeTab, (newVal) => {
if (newVal && newVal !== currentTab.value) {
currentTab.value = newVal;
}
}, { immediate: true });
//
watch(() => props.visible, (newVal) => {
if (newVal) {
fetchRobotList();
selectedType.value = '全部类型';
}
});
@ -250,6 +262,11 @@ onMounted(() => {
fetchRobotList();
}
});
//
if (robotTypes.value && robotTypes.value.length > 0 && !selectedType.value) {
selectedType.value = robotTypes.value[0];
}
</script>
<style scoped>
@ -263,6 +280,7 @@ onMounted(() => {
align-items: center;
justify-content: center;
z-index: 1000;
background: rgba(0, 0, 0, 0.5);
}
.modal-content {
@ -308,18 +326,20 @@ onMounted(() => {
.filter-tabs {
display: flex;
gap: 0;
background: rgba(0, 21, 31, 0.3);
border: 1px solid rgba(0, 206, 234, 0.7);
/* background: rgba(0, 21, 31, 0.3); */
/* border: 1px solid rgba(0, 206, 234, 0.7); */
border-radius: 2px;
overflow: hidden;
}
.tab-item {
color: #B9E8FF;
font-size: 14px;
font-size: 15px;
cursor: pointer;
padding: 8px 20px;
border-right: 1px solid rgba(0, 206, 234, 0.7);
/* border-right: 1px solid rgba(0, 206, 234, 0.7); */
}
.tab-item:last-child {
@ -327,7 +347,9 @@ onMounted(() => {
}
.tab-item.active {
background: rgba(0, 206, 234, 0.2);
/* background: rgba(0, 206, 234, 0.2); */
background: url("../../assets/img/alarm_tri.png") no-repeat;
background-size: 100% 100%;
}
.type-select {
@ -335,18 +357,18 @@ onMounted(() => {
align-items: center;
font-size: 14px;
color: #B9E8FF;
background: rgba(0, 21, 31, 0.3);
border: 1px solid rgba(0, 206, 234, 0.7);
border-radius: 2px;
background: rgba(33, 99, 131, 0.3);
border: 1px solid #29EBF8;
border-radius: 4px;
padding: 5px 10px;
}
.select-label {
color: #B9E8FF;
color: #FFFFFF;
}
.select-divider {
color: #00ffff;
color: #FFFFFF;
margin: 0 10px;
}
@ -358,7 +380,7 @@ onMounted(() => {
}
.select-text {
color: #B9E8FF;
color: #FFFFFF;
margin-right: 25px;
}
@ -373,29 +395,55 @@ onMounted(() => {
.select-dropdown {
position: absolute;
top: 100%;
right: 0;
top: 135%;
right: -10px;
background: #00273A;
border: 1px solid rgba(0, 206, 234, 0.7);
border-radius: 2px;
margin-top: 5px;
padding: 5px 0;
min-width: 120px;
border-radius: 6px;
border:1px solid #335261;
margin-top: 0;
padding: 0;
width: 140px;
z-index: 10;
}
.select-dropdown li {
padding: 8px 15px;
padding: 0 15px;
color: #B9E8FF;
background: #00273A;
cursor: pointer;
font-size: 13px;
line-height: 34px;
height: 34px;
margin: 0;
border-radius: 0;
}
.select-dropdown li:first-child {
border-radius: 6px 6px 0 0;
}
.select-dropdown li:last-child {
border-radius: 0 0 6px 6px;
}
.select-dropdown li:first-child {
border-radius: 6px 6px 0 0;
}
.select-dropdown li:last-child {
border-radius: 0 0 6px 6px;
}
.select-dropdown li.active {
background: #0091A9;
color: #fff;
}
.select-dropdown li:hover {
background: rgba(0, 206, 234, 0.2);
background: #005C71;
color: #fff;
}
.table-container {
border: 1px solid rgba(0, 206, 234, 0.7);
/* border: 1px solid rgba(0, 206, 234, 0.7); */
border-radius: 4px;
overflow: hidden;
}
@ -407,7 +455,8 @@ onMounted(() => {
}
.robot-table th {
background: rgba(0, 21, 31, 0.3);
font-size: 15px;
/* background: rgba(0, 21, 31, 0.3); */
padding: 12px;
text-align: center;
font-weight: normal;
@ -416,6 +465,7 @@ onMounted(() => {
.robot-table td {
padding: 12px;
font-size: 16px;
text-align: center;
}
@ -437,10 +487,5 @@ onMounted(() => {
color: #FFB800;
}
.battery-wrapper,
.battery-box,
.battery-level,
.battery-text {
/* 这些样式将被删除 */
}
</style>

View File

@ -5,12 +5,29 @@
box-sizing: border-box;
outline: none;
font-family: "微软雅黑";
/* font-size:16px; */
}
body{
width:100vw;
height:100vh;
overflow: hidden;
}
@media (max-width: 1366px) {
body {
height: auto;
overflow: auto;
}
}
/* 针对1920*1080分辨率的优化 */
@media (min-width: 1920px) {
body {
width: 100vw;
height: 100vh;
overflow: hidden;
}
}
:root {
--color1: #fff;
--color2: #76b4ec;;
@ -19,26 +36,39 @@ body{
--bg1: #428ce6;
--bg2: #1574A8;
--bg: linear-gradient(90deg, rgba(91, 150, 226, 1) 0%, rgba(95, 106, 187, 1) 48%, rgba(160, 186, 219, 1) 100%);
--fsize: 16px;
--fsize1: 20px;
--fsize2: 24px;
--fsize3: 14px;
--fsize4: 12px;
--fsize5: 10px;
--fsize6: 28px;
--fsize7: 18px;
/* 基础字体大小 - 适配1920*1080分辨率 */
--fsize: 0.83vw; /* 16px at 1920px width */
--fsize1: 1.04vw; /* 20px at 1920px width */
--fsize2: 1.25vw; /* 24px at 1920px width */
--fsize3: 0.73vw; /* 14px at 1920px width */
--fsize4: 0.625vw; /* 12px at 1920px width */
--fsize5: 0.52vw; /* 10px at 1920px width */
--fsize6: 1.46vw; /* 28px at 1920px width */
--fsize7: 0.94vw; /* 18px at 1920px width */
/* 常用间距 */
--spacing-xs: 0.52vw; /* 10px at 1920px width */
--spacing-sm: 0.83vw; /* 16px at 1920px width */
--spacing-md: 1.25vw; /* 24px at 1920px width */
--spacing-lg: 1.67vw; /* 32px at 1920px width */
--spacing-xl: 2.08vw; /* 40px at 1920px width */
/* 常用组件尺寸 */
--card-padding: 1.04vw; /* 20px at 1920px width */
--border-radius-sm: 0.21vw; /* 4px at 1920px width */
--border-radius-md: 0.42vw; /* 8px at 1920px width */
--icon-size-sm: 1.25vw; /* 24px at 1920px width */
--icon-size-md: 1.67vw; /* 32px at 1920px width */
--icon-size-lg: 2.08vw; /* 40px at 1920px width */
}
.flex-clu-bt{
display:flex;
flex-direction:column;
justify-content:space-between;
}
/* .text-title{
background: linear-gradient(to bottom, #66abe3, #fff);
-webkit-background-clip: text;
color: transparent;
display: inline-block;
} */
.textjb{
background: linear-gradient(to bottom, #00CEEA 50%, #F0FBFF 100%);
-webkit-background-clip: text;
@ -46,12 +76,13 @@ body{
display: inline-block;
}
.handle-btn {
width: 2.5vw; /* 替换固定48px */
background: #52213C;
border: 1px solid #CB1A49!important;
color: white;
border: none;
border-radius: 2px;
padding: 2px 10px;
font-size: 12px;
border-radius: var(--border-radius-sm);
padding: 0.1vw 0.42vw; /* 替换固定2px 8px */
font-size: var(--fsize4);
cursor: pointer;
}

View File

@ -2,13 +2,13 @@ import axios from 'axios'
// 创建 axios 实例
const service = axios.create({
baseURL: import.meta.env.VITE_APP_BASE_API || 'http://10.0.202:9123',
baseURL: import.meta.env.VITE_APP_BASE_API,
timeout: 15000
})
// concoai 接口实例
export const concoaiService = axios.create({
baseURL: import.meta.env.VITE_APP_CONCOAI_API || 'https://rest.concoai.com',
baseURL: import.meta.env.VITE_APP_CONCOAI_API,
timeout: 15000
})

View File

@ -1,463 +0,0 @@
<template>
<div class="main">
<!-- 渐变边框 -->
<div class="border-gradient top"></div>
<div class="border-gradient bottom"></div>
<div class="border-gradient left"></div>
<div class="border-gradient right"></div>
<!-- 顶部组件 -->
<TopHeader />
<!-- 左侧内容 -->
<div class="left_content">
<TitleBlock title="机器人统计">机器人统计</TitleBlock>
<div class="statistics-content">
<div class="statistics-grid">
<StatisticCard
v-for="item in statistics"
:key="item.title"
:iconSrc="item.icon"
:value="item.value"
:title="item.title"
@click="handleStatisticClick(item)"
/>
</div>
</div>
<TitleBlock title="机器人状态列表">机器人状态列表</TitleBlock>
<div class="status-list-content">
<RobotStatusList />
</div>
</div>
<!-- 右侧内容 -->
<div class="right_content">
<TitleBlock title="最新告警">最新告警</TitleBlock>
<div class="alert-content">
<LatestAlarms />
</div>
<TitleBlock title="告警事件统计">告警事件统计</TitleBlock>
<div class="event-list-content">
<AlarmStatistics />
</div>
</div>
<!-- 底部监控区域 -->
<div class="bottom_content">
<TitleBlock title="厂区及机器人实时监控">厂区及机器人实时监控</TitleBlock>
<div class="monitor-content">
<div class="camera-grid">
<div v-for="(camera, index) in cameras" :key="index" class="camera-item">
<div class="camera-header">
<div class="camera-title">
<img :src="camera.src" alt="摄像头" class="camera-icon" />
<p>{{camera.title}}</p>
</div>
<CustomSelect
v-model="selectedViews[camera.title]"
:options="viewOptions"
size="small"
variant="search"
font="small"
@change="handleViewChange(camera.title)"
/>
</div>
<div class="camera-feed">
<VideoPlayer
:streamUrl="camera.streamUrl"
:title="camera.title"
fillMode="stretch-height"
/>
</div>
</div>
</div>
</div>
</div>
<!-- 机器人列表弹窗 -->
<RobotListModal v-model:visible="showRobotListModal" />
</div>
</template>
<script setup>
import { onMounted, ref, computed, watch } from "vue";
import TopHeader from '../components/common/TopHeader.vue'
import TitleBlock from '../components/common/TitleBlock.vue'
import StatisticCard from '../components/StatisticCard.vue'
import RobotStatusList from '../components/RobotStatusList.vue'
import AlarmStatistics from '../components/AlarmStatistics.vue'
import LatestAlarms from '../components/LatestAlarms.vue'
import RobotListModal from '../components/dialog/RobotListModal.vue'
import CustomSelect from '../components/common/CustomSelect.vue'
import VideoPlayer from '../components/common/VideoPlayer.vue'
import { homeApi } from '../api/index'
import Icon1 from '../assets/img/icon1.png'
import Icon2 from '../assets/img/icon2.png'
import Icon3 from '../assets/img/icon3.png'
import Icon4 from '../assets/img/icon4.png'
import jkA from '../assets/img/jkA.png'
import jkRobot from '../assets/img/jkRobot.png'
//
const statistics = ref([
{ icon: Icon1, value: 0, title: '总数量' },
{ icon: Icon2, value: 0, title: '在线数量' },
{ icon: Icon3, value: 0, title: '离线数量' },
{ icon: Icon4, value: 0, title: '故障数量' }
]);
//
const fetchRobotStatistics = async () => {
try {
//
const res = await homeApi.getRobotList({
tenantInfoId: '4fff5d4bcc4b4239941ff077a0da8958', // id
number: null, //
status: null, //
onlineStatus: null // 线
});
if (res.code === 200) {
//
let totalCount = 0;
let onlineCount = 0;
let offlineCount = 0;
let faultCount = 0;
//
Object.entries(res.data).forEach(([groupName, robots]) => {
robots.forEach(robot => {
totalCount++;
if (robot.onlineStatus === '0') {
offlineCount++;
} else {
onlineCount++;
//
if (robot.status === '3') {
faultCount++;
}
}
});
});
//
statistics.value = [
{ icon: Icon1, value: totalCount, title: '总数量' },
{ icon: Icon2, value: onlineCount, title: '在线数量' },
{ icon: Icon3, value: offlineCount, title: '离线数量' },
{ icon: Icon4, value: faultCount, title: '故障数量' }
];
console.log('获取机器人统计数据成功:', statistics.value);
} else {
console.error('获取机器人统计数据失败:', res);
}
} catch (err) {
console.error('获取机器人统计数据错误:', err);
}
};
const cameras = ref([
{ title: 'A区厂区监控', src: jkA, streamUrl: '' },
{ title: 'B区厂区监控', src: jkA, streamUrl: '' },
{ title: '追随机器人监控', src: jkRobot, streamUrl: '' },
{ title: '室外机器人监控', src: jkRobot, streamUrl: '' }
]);
const selectedViews = ref({
'A区厂区监控': '视角1',
'B区厂区监控': '视角1',
'追随机器人监控': '视角1',
'室外机器人监控': '视角1'
});
const viewOptions = ['视角1', '视角2'];
//
const monitorStreams = ref({});
//
const fetchMonitorStreams = async () => {
try {
const res = await homeApi.getFactoryRobotRealTime();
if (res.code === 200) {
monitorStreams.value = res.data || {};
console.log('获取监控视频流成功:', JSON.stringify(monitorStreams.value));
// URL
updateCameraStreams();
} else {
console.error('获取监控视频流失败:', res);
}
} catch (err) {
console.error('获取监控视频流错误:', err);
}
};
// URL
const updateCameraStreams = () => {
cameras.value.forEach(camera => {
const cameraData = monitorStreams.value[camera.title];
console.log(`处理摄像头 ${camera.title}:`, cameraData);
if (cameraData) {
const viewName = selectedViews.value[camera.title];
const newStreamUrl = cameraData[viewName] || '';
console.log(`设置 ${camera.title}${viewName} 流URL:`, newStreamUrl);
camera.streamUrl = newStreamUrl;
} else {
console.warn(`未找到 ${camera.title} 的数据`);
}
});
//
console.log('更新后的摄像头数据:', JSON.stringify(cameras.value));
};
//
watch(selectedViews, (newViews) => {
updateCameraStreams();
}, { deep: true });
const showRobotListModal = ref(false);
const handleStatisticClick = (item) => {
if (item.title === '总数量') {
showRobotListModal.value = true;
}
};
//
const handleViewChange = (cameraTitle) => {
const camera = cameras.value.find(c => c.title === cameraTitle);
if (camera) {
const cameraData = monitorStreams.value[cameraTitle];
if (cameraData) {
const viewName = selectedViews.value[cameraTitle];
camera.streamUrl = cameraData[viewName] || '';
console.log(`切换 ${cameraTitle}${viewName}, URL: ${camera.streamUrl}`);
}
}
};
//
onMounted(() => {
fetchRobotStatistics();
fetchMonitorStreams();
});
</script>
<style scoped>
.main {
width: 100vw;
height: 100vh;
overflow: hidden;
background: url("../assets/img/bg.png") no-repeat;
background-size: 100% 100%;
position: relative;
}
.left_content,
.right_content {
position: absolute;
top: 6.25rem;
width: 400px;
/* height: 85%; */
display: flex;
flex-direction: column;
gap: 20px;
z-index: 1000;
}
.left_content {
left: 32px;
}
.right_content {
right: 32px;
}
.border-gradient {
position: absolute;
pointer-events: none;
z-index: 200;
}
.border-gradient.top {
top: 0;
left: 0;
right: 0;
height: 200px;
background: linear-gradient(to bottom, rgba(0, 21, 31, 0.8), rgba(0, 21, 31, 0));
}
.border-gradient.bottom {
left: 0;
right: 0;
bottom: 0;
height: 300px;
background: linear-gradient(to top, rgba(0, 21, 31, 0.8), rgba(0, 21, 31, 0));
}
.border-gradient.left {
top: 0;
bottom: 0;
left: 0;
width: 35rem;
background: linear-gradient(to right, rgba(0, 21, 31, 0.8), rgba(0, 21, 31, 0));
}
.border-gradient.right {
top: 0;
bottom: 0;
right: 0;
width: 35rem;
background: linear-gradient(to left, rgba(0, 21, 31, 0.8), rgba(0, 21, 31, 0));
}
.statistics-content,
.status-list-content,
.alert-content {
width: 100%;
/* padding: 15px;
border: 1px solid red; */
/* flex: 1; */
}
.statistics-content {
width: 100%;
/* padding: 15px;
background: rgba(0, 21, 31, 0.5);
border-radius: 8px; */
}
.statistics-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 20px;
padding: 10px;
}
.status-list-content {
width: 100%;
height: 400px;
/* background: rgba(0, 21, 31, 0.5); */
border-radius: 8px;
}
.alert-content {
width: 100%;
height: 400px;
border-radius: 8px;
}
.event-list-content {
width: 100%;
height: 20rem;
}
.bottom_content {
position: absolute;
bottom: 32px;
left: 50%;
transform: translateX(-50%);
width: calc(100% - 900px);
z-index: 2;
}
.monitor-title {
position: relative;
height: 40px;
display: flex;
align-items: center;
padding-left: 20px;
}
.title-bg {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
.monitor-title span {
position: relative;
z-index: 1;
color: #B9E8FF;
font-size: 16px;
}
.monitor-content {
margin-top: 10px;
/* background: rgba(0, 21, 31, 0.3); */
border-radius: 4px;
padding: 10px;
}
.camera-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 10px;
}
.camera-item {
background: rgba(0, 21, 31, 0.5);
border-radius: 4px;
overflow: hidden;
position: relative;
/* border: 1px solid rgba(0, 168, 255, 0.2); */
}
.camera-header {
position: absolute;
top: 0;
left: 0;
right: 0;
z-index: 1;
display: flex;
align-items: center;
justify-content: space-between;
padding: 6px 10px;
background: rgba(0, 0, 0, 0.7);
color: #B9E8FF;
font-size: 12px;
}
.camera-title {
display: flex;
align-items: center;
gap: 5px;
}
.camera-title img {
width: 16px;
height: 16px;
}
.camera-title p {
margin: 0;
font-size: 13px;
letter-spacing: 0.5px;
}
.camera-feed {
height: 180px;
overflow: hidden;
/* background: rgba(0, 21, 31, 0.5); */
background: #033347;
border-radius: 4px;
}
.camera-feed img {
width: 100%;
height: 100%;
object-fit: cover;
}
</style>

View File

@ -5,7 +5,20 @@
<div class="border-gradient bottom"></div>
<div class="border-gradient left"></div>
<div class="border-gradient right"></div>
<div class="center_tip">
<div class="center-tip-content">
<template v-for="robot in outdoorRobots" :key="robot.id">
<div class="center-tip-robot" @click="handleRobotClick(robot.id)">
<span class="robot-id">{{ robot.id }}</span>
<span class="divider">|</span>
<span class="robot-power">电量{{ robot.battery }}%</span>
<span class="divider">|</span>
<span class="robot-status">{{ robot.status }}</span>
<span class="alarm-btn">{{ robotAlertMap[robot.id] > 0 ? '有告警' : '无告警' }}</span>
</div>
</template>
</div>
</div>
<!-- 顶部组件 -->
<TopHeader />
@ -27,7 +40,7 @@
<TitleBlock title="机器人状态列表">机器人状态列表</TitleBlock>
<div class="status-list-content">
<RobotStatusList />
<RobotStatusList @outdoor-robots-update="handleOutdoorRobotsUpdate" />
</div>
</div>
@ -49,34 +62,32 @@
<TitleBlock title="厂区及机器人实时监控">厂区及机器人实时监控</TitleBlock>
<div class="monitor-content">
<div class="camera-grid">
<div v-for="(camera, index) in cameras" :key="index" class="camera-item">
<div v-for="category in monitorCategories" :key="category" class="camera-item">
<div class="camera-header">
<div class="camera-title">
<img :src="camera.src" alt="摄像头" class="camera-icon" />
<p>{{camera.title}}</p>
<img :src="category.includes('厂区') ? jkA : jkRobot" alt="摄像头" class="camera-icon" />
<p>{{ category }}</p>
</div>
<CustomSelect
v-model="selectedViews[camera.title]"
:options="getViewOptionsForCamera(camera)"
v-model="selectedSubCategory[category]"
:options="Object.keys(monitorStreams[category] || {})"
size="small"
variant="search"
font="small"
/>
</div>
<div class="camera-feed">
<CarouselVideoPlayer
v-if="!isWebRTCCamera(camera)"
:views="getViewsForCamera(camera)"
:title="camera.title"
<CarouselVideoPlayer
v-if="!isWebRTCCategorySubCategory(category, selectedSubCategory[category])"
:views="getViewsForCategorySubCategory(category, selectedSubCategory[category])"
:title="category"
:interval="10000"
v-model="selectedViews[camera.title]"
/>
<CarouselWebRTCPlayer
<CarouselWebRTCPlayer
v-else
:views="getViewsForCamera(camera)"
:title="camera.title"
:views="getViewsForCategorySubCategory(category, selectedSubCategory[category])"
:title="category"
:interval="10000"
v-model="selectedViews[camera.title]"
/>
</div>
</div>
@ -85,12 +96,13 @@
</div>
<!-- 机器人列表弹窗 -->
<RobotListModal v-model:visible="showRobotListModal" />
<RobotListModal v-model:visible="showRobotListModal" :activeTab="robotListActiveTab" />
</div>
</template>
<script setup>
import { onMounted, ref, computed, watch } from "vue";
import { useRouter } from 'vue-router'
import TopHeader from '../components/common/TopHeader.vue'
import TitleBlock from '../components/common/TitleBlock.vue'
import StatisticCard from '../components/StatisticCard.vue'
@ -102,16 +114,14 @@ import CustomSelect from '../components/common/CustomSelect.vue'
import CarouselVideoPlayer from '../components/common/CarouselVideoPlayer.vue'
import CarouselWebRTCPlayer from '../components/common/CarouselWebRTCPlayer.vue'
import { homeApi } from '../api/index'
import { robotApi } from '../api/detail'
import Icon1 from '../assets/img/icon1.png'
import Icon2 from '../assets/img/icon2.png'
import Icon3 from '../assets/img/icon3.png'
import Icon4 from '../assets/img/icon4.png'
import jkA from '../assets/img/jkA.png'
import jkRobot from '../assets/img/jkRobot.png'
import VideoPlayer from '../components/common/VideoPlayer.vue'
import EmptyState from '../components/common/EmptyState.vue'
import CustomWebRTCPlayer from '../components/common/CustomWebRTCPlayer.vue'
import empty from '../assets/img/empty.png'
//
const statistics = ref([
@ -174,51 +184,29 @@ const fetchRobotStatistics = async () => {
}
};
//
const cameras = ref([
{ title: 'A区厂区监控', src: jkA },
{ title: 'B区厂区监控', src: jkA },
{ title: '追随机器人监控', src: jkRobot },
{ title: '室外机器人监控', src: jkRobot }
]);
//
const selectedViews = ref({
'A区厂区监控': '',
'B区厂区监控': '',
'追随机器人监控': '',
'室外机器人监控': ''
});
//
const getViewOptionsForCamera = (camera) => {
const cameraData = monitorStreams.value[camera.title];
if (!cameraData) return [];
// URL
return Object.keys(cameraData);
};
//
const monitorStreams = ref({});
// key
const monitorCategories = computed(() => Object.keys(monitorStreams.value));
// key
const selectedSubCategory = ref({});
//
const fetchMonitorStreams = async () => {
try {
const res = await homeApi.getFactoryRobotRealTime();
if (res.code === 200) {
monitorStreams.value = res.data || {};
console.log('获取监控视频流成功:', JSON.stringify(monitorStreams.value));
//
cameras.value.forEach(camera => {
const viewOptions = getViewOptionsForCamera(camera);
if (viewOptions.length > 0) {
//
selectedViews.value[camera.title] = viewOptions[0];
}
// selectedSubCategory
const initSelected = {};
Object.entries(monitorStreams.value).forEach(([category, subMap]) => {
const subKeys = Object.keys(subMap);
initSelected[category] = subKeys.length > 0 ? subKeys[0] : '';
});
selectedSubCategory.value = initSelected;
console.log('获取监控视频流成功:', JSON.stringify(monitorStreams.value));
} else {
console.error('获取监控视频流失败:', res);
}
@ -235,16 +223,23 @@ const isWebRTCStream = (url) => {
//
const getViewsForCamera = (camera) => {
const cameraData = monitorStreams.value[camera.title];
if (!cameraData) return [];
const cameraTitle = camera.title;
const selectedSubCamera = selectedViews.value[cameraTitle];
//
return Object.entries(cameraData).map(([viewName, streamUrl]) => {
if (!selectedSubCamera || !monitorStreams.value[cameraTitle] || !monitorStreams.value[cameraTitle][selectedSubCamera]) {
return [];
}
//
const viewsData = monitorStreams.value[cameraTitle][selectedSubCamera];
//
return Object.entries(viewsData).map(([viewName, streamUrl]) => {
return {
name: viewName,
streamUrl: streamUrl || '' // URL"empty"
streamUrl: streamUrl || '' // URL
};
}); // URL
});
};
// 使WebRTC
@ -256,14 +251,74 @@ const isWebRTCCamera = (camera) => {
return views.some(view => isWebRTCStream(view.streamUrl));
};
//
const showRobotListModal = ref(false);
// Tab
const robotListActiveTab = ref('all');
const handleStatisticClick = (item) => {
if (item.title === '总数量') {
showRobotListModal.value = true;
}
// Tab
const tabMap = {
'总数量': 'all',
'在线数量': 'online',
'离线数量': 'offline',
'故障数量': 'fault'
};
robotListActiveTab.value = tabMap[item.title] || 'all';
showRobotListModal.value = true;
};
// [{name, streamUrl}]
const getViewsForCategorySubCategory = (category, subCategory) => {
const streams = monitorStreams.value?.[category]?.[subCategory] || [];
return streams.map((url, idx) => ({ name: `${idx + 1}`, streamUrl: url }));
};
// WebRTC
const isWebRTCCategorySubCategory = (category, subCategory) => {
const streams = monitorStreams.value?.[category]?.[subCategory] || [];
return streams.some(url => isWebRTCStream(url));
};
//
const outdoorRobots = ref([])
//
const robotAlertMap = ref({})
//
async function updateRobotAlerts() {
const promises = outdoorRobots.value.map(async robot => {
try {
const res = await robotApi.getAlarmEventCount({ number: robot.id })
if (res.code === 200) {
robotAlertMap.value[robot.id] = res.data.alert_count || 0
} else {
robotAlertMap.value[robot.id] = 0
}
} catch {
robotAlertMap.value[robot.id] = 0
}
})
await Promise.all(promises)
}
// outdoorRobots
watch(outdoorRobots, () => {
updateRobotAlerts()
}, { immediate: true })
// RobotStatusList
function handleOutdoorRobotsUpdate(list) {
outdoorRobots.value = list
}
const router = useRouter();
function handleRobotClick(id) {
router.push(`/robot/${id}`)
}
//
onMounted(() => {
fetchRobotStatistics();
@ -276,7 +331,7 @@ onMounted(() => {
width: 100vw;
height: 100vh;
overflow: hidden;
background: url("../assets/img/bg.png") no-repeat;
background: url("../assets/img/bg.png") no-repeat;
background-size: 100% 100%;
position: relative;
}
@ -284,22 +339,21 @@ onMounted(() => {
.left_content,
.right_content {
position: absolute;
top: 6.25rem;
top: 6.25vw; /* 120px at 1920px width */
width: 400px;
/* height: 85%; */
display: flex;
flex-direction: column;
gap: 20px;
display: flex;
flex-direction: column;
gap: var(--spacing-md);
z-index: 1000;
}
.left_content {
left: 32px;
left: 1.667vw; /* 32px at 1920px width */
}
.right_content {
right: 32px;
right: 1.667vw; /* 32px at 1920px width */
}
.border-gradient {
@ -312,7 +366,7 @@ onMounted(() => {
top: 0;
left: 0;
right: 0;
height: 200px;
height: 10.417vw; /* 200px at 1920px width */
background: linear-gradient(to bottom, rgba(0, 21, 31, 0.8), rgba(0, 21, 31, 0));
}
@ -320,7 +374,7 @@ onMounted(() => {
left: 0;
right: 0;
bottom: 0;
height: 300px;
height: 15.625vw; /* 300px at 1920px width */
background: linear-gradient(to top, rgba(0, 21, 31, 0.8), rgba(0, 21, 31, 0));
}
@ -328,7 +382,7 @@ onMounted(() => {
top: 0;
bottom: 0;
left: 0;
width: 35rem;
width: 35vw; /* 使用vw替代rem */
background: linear-gradient(to right, rgba(0, 21, 31, 0.8), rgba(0, 21, 31, 0));
}
@ -336,9 +390,9 @@ onMounted(() => {
top: 0;
bottom: 0;
right: 0;
width: 35rem;
width: 35vw; /* 使用vw替代rem */
background: linear-gradient(to left, rgba(0, 21, 31, 0.8), rgba(0, 21, 31, 0));
}
}
.statistics-content,
.status-list-content,
@ -351,51 +405,52 @@ onMounted(() => {
.statistics-content {
width: 100%;
/* padding: 15px;
background: rgba(0, 21, 31, 0.5);
/* padding-left: 15px; */
/* background: rgba(0, 21, 31, 0.5);
border-radius: 8px; */
}
.statistics-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 20px;
padding: 10px;
gap: var(--spacing-xs);
}
.status-list-content {
width: 100%;
height: 400px;
height: 20.833vw; /* 400px at 1920px width */
/* background: rgba(0, 21, 31, 0.5); */
border-radius: 8px;
border-radius: var(--border-radius-md);
}
.alert-content {
width: 100%;
height: 400px;
border-radius: 8px;
}
height: calc(100vh - 32.042vw); /* 500px at 1920px width */
border-radius: var(--border-radius-md);
}
.event-list-content {
width: 100%;
height: 20rem;
height: 20vw; /* 使用vw替代rem */
}
.bottom_content {
width: 51%;
height: auto;
position: absolute;
bottom: 32px;
left: 50%;
transform: translateX(-50%);
width: calc(100% - 900px);
left: 25%;
right: 25%;
bottom: 1.667vw; /* 32px at 1920px width */
z-index: 2;
}
.monitor-title {
border: 1px solid blue;
position: relative;
height: 40px;
height: 2.083vw; /* 40px at 1920px width */
display: flex;
align-items: center;
padding-left: 20px;
padding-left: 1.042vw; /* 20px at 1920px width */
}
.title-bg {
@ -410,27 +465,29 @@ onMounted(() => {
position: relative;
z-index: 1;
color: #B9E8FF;
font-size: 16px;
font-size: var(--fsize);
}
.monitor-content {
margin-top: 10px;
margin-top: var(--spacing-xs);
/* background: rgba(0, 21, 31, 0.3); */
border-radius: 4px;
padding: 10px;
border-radius: var(--border-radius-sm);
padding: var(--spacing-xs);
}
.camera-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 10px;
gap: var(--spacing-xs);
justify-items: center;
}
.camera-item {
background: rgba(0, 21, 31, 0.5);
border-radius: 4px;
border-radius: var(--border-radius-sm);
overflow: hidden;
position: relative;
width: 100%;
/* border: 1px solid rgba(0, 168, 255, 0.2); */
}
@ -443,41 +500,100 @@ onMounted(() => {
display: flex;
align-items: center;
justify-content: space-between;
padding: 6px 10px;
padding: 0.2vw 0.521vw; /* 6px 10px at 1920px width */
background: rgba(0, 0, 0, 0.7);
color: #B9E8FF;
font-size: 12px;
font-size: var(--fsize4);
}
.camera-title {
display: flex;
align-items: center;
gap: 5px;
gap: 0.26vw; /* 5px at 1920px width */
}
.camera-title img {
width: 16px;
height: 16px;
width: 0.833vw; /* 16px at 1920px width */
height: 0.833vw; /* 16px at 1920px width */
}
.camera-title p {
margin: 0;
font-size: 13px;
letter-spacing: 0.5px;
font-size: 0.677vw; /* 13px at 1920px width */
letter-spacing: 0.026vw; /* 0.5px at 1920px width */
}
.camera-feed {
height: 180px;
width: 100%;
height: 143px;
overflow: hidden;
/* background: rgba(0, 21, 31, 0.5); */
background: #033347;
border-radius: 4px;
border-radius: var(--border-radius-sm);
position: relative;
margin: 0 auto;
}
.camera-feed img {
.camera-feed video, .camera-feed img {
width: 100%;
height: 100%;
object-fit: cover;
object-fit: contain;
}
.center_tip {
position: absolute;
top: 42%;
left: 50%;
transform: translateX(-50%);
z-index: 2000;
display: flex;
justify-content: center;
width: auto;
}
.center-tip-content {
display: flex;
align-items: center;
background-color: rgba(0, 0, 0, 0.4);
border-radius: 6px;
padding: 0.5vw 1vw; /* 5px 24px */
font-size: 14px;
color: #B9E8FF;
box-shadow: 0 2px 8px rgba(0,0,0,0.12);
gap: 0.3vw; /* 12px */
}
.center-tip-content .robot-id {
color: #B9E8FF;
}
.center-tip-content .divider {
color: #B9E8FF;
margin: 0 0.417vw;
}
.center-tip-content .robot-power {
color: #B9E8FF;
}
.center-tip-content .robot-status {
color: #B9E8FF;
}
.center-tip-content .alarm-btn {
background: #FF9800;
color: #151515;
border: none;
border-radius: 12px;
padding: 0.1vw 0.3vw; /* 2.5px 19px */
font-size: 12px;
margin-left: 0.625vw;
cursor: pointer;
transition: background 0.2s;
}
.center-tip-robot {
display: inline-flex;
align-items: center;
cursor: pointer;
border-radius: 6px;
padding: 0 0.3vw;
}
</style>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,19 +2,54 @@ import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from "path";
import dotenv from 'dotenv';
import postcsspxtoviewport from 'postcss-px-to-viewport'
// https://vitejs.dev/config/
// 加载环境变量
dotenv.config({
path: process.env.NODE_ENV === 'production' ? '.env.production' : '.env.development',
});
// dotenv.config({
// path: process.env.NODE_ENV === 'production' ? '.env.production' : '.env.development',
// });
export default defineConfig({
base:'./' ,
plugins: [vue()],
resolve: {
//在这配置插件内容
css: {
postcss: {
plugins: [
postcsspxtoviewport({
// 要转化的单位
unitToConvert: 'px',
// UI设计稿的大小
viewportWidth: 1920,
// 转换后的精度
unitPrecision: 6,
// 字体转换后的单位
fontViewportUnit: 'vw',
// 能转换的属性,*表示所有属性,!border表示border不转
propList: ['*'],
// 指定不转换为视窗单位的类名,
selectorBlackList: ['ignore-'],
// 最小转换的值小于等于1不转
minPixelValue: 1,
// 是否在媒体查询的css代码中也进行转换默认false
mediaQuery: false,
// 是否转换后直接更换属性值
replace: true,
// 忽略某些文件夹下的文件或特定文件,例如 'node_modules' 下的文件
exclude: [],
// 包含那些文件或者特定文件
include: [],
// 是否处理横屏情况
landscape: false
}),
]
}
},
resolve: {
alias: {
"@": resolve(__dirname, "./src")
},