Compare commits

1 Commits
main ... main

Author SHA1 Message Date
ced4a5177f 添加 一个设备的控制面板及一些小优化 2026-04-16 10:04:43 +08:00
22 changed files with 2848 additions and 936 deletions

View File

@ -2,10 +2,16 @@
VITE_APP_TITLE = 云平台管理系统
# 生产环境配置 晶全1
VITE_APP_ENV = 'https://www.cnxhyc.com'
VITE_APP_ENV = 'production'
# 生产环境配置 富源晟2
# VITE_APP_ENV = 'https://fuyuanshen.com/backend-fys'
# 应用访问路径 晶全1
VITE_APP_CONTEXT_PATH = '/jingquan/'
VITE_APP_CONTEXT_PATH = '/PC/'
# 高德地图Key
VITE_AMAP_KEY='84a12a692ae378effdf741e16d584cd3'
# 应用访问路径 富源晟2
#VITE_APP_CONTEXT_PATH = '/sys/'
@ -17,7 +23,12 @@ VITE_APP_MONITOR_ADMIN = '/admin/applications'
VITE_APP_SNAILJOB_ADMIN = '/snail-job'
# 生产环境 晶全3 代理访问
VITE_APP_BASE_API = '/jq'
VITE_APP_BASE_API = 'https://www.cnxhyc.com/jq'
# VITE_APP_BASE_API = 'http://139.224.253.23:8000'
# 生产环境 富源晟3
#VITE_APP_BASE_API = '/backend-fys'
# 是否在打包时开启压缩,支持 gzip 和 brotli
VITE_BUILD_COMPRESS = gzip

View File

@ -54,7 +54,7 @@ function SosSetting (data: any) {
// 语音列表
function queryAudioFileList (params: any) {
return request({
url: `/api/video/queryAudioFileList`,
url: `/app/video/queryAudioFileList`,
method: 'get',
params: params
});
@ -62,7 +62,7 @@ function queryAudioFileList (params: any) {
// 提取文本内容
function extractText (data: any) {
return request({
url: `/api/video/extract`,
url: `/app/video/extract`,
method: 'post',
data: data
});
@ -70,7 +70,7 @@ function extractText (data: any) {
// 上传音频文件
function uploadAudioToOss (data: any) {
return request({
url: `/api/video/uploadAudioToOss`,
url: `/app/video/uploadAudioToOss`,
method: 'post',
data: data
});
@ -78,7 +78,7 @@ function uploadAudioToOss (data: any) {
// 文本转语音
export function videTtsToOss(data:any) {
return request({
url: `/api/video/ttsToOss`,
url: `/app/video/ttsToOss`,
method: 'post',
data:data
})
@ -86,7 +86,7 @@ export function videTtsToOss(data:any) {
// 重命名
export function videRenameAudioFile(data:any) {
return request({
url: `/api/video/renameAudioFile`,
url: `/app/video/renameAudioFile`,
method: 'post',
data:data
})
@ -94,7 +94,7 @@ export function videRenameAudioFile(data:any) {
// 删除语音文件列表
export function deviceDeleteAudioFile(params:any) {
return request({
url: `/api/video/deleteAudioFile`,
url: `/app/video/deleteAudioFile`,
method: 'get',
params:params
})
@ -103,7 +103,7 @@ export function deviceDeleteAudioFile(params:any) {
// 更新语音,使用语音
export function deviceUpdateVoice(data:any) {
return request({
url: `/api/hby100j/device/updateVoice`,
url: `/app/hby100j/device/updateVoice`,
method: 'post',
data:data
})
@ -111,7 +111,7 @@ export function deviceUpdateVoice(data:any) {
// 语音播放
export function deviceVoiceBroadcast(data:any) {
return request({
url: `/api/hby100j/device/voiceBroadcast`,
url: `/app/hby100j/device/voiceBroadcast`,
method: 'post',
data:data
})

BIN
src/assets/images/haiba.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1001 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
src/assets/images/jieN.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1014 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 877 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

BIN
src/assets/images/sos.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 849 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 865 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
src/assets/images/work.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 992 B

View File

@ -59,7 +59,7 @@ const props = defineProps({
// 大小限制(MB)
fileSize: propTypes.number.def(200),
// 文件类型, 例如['png', 'jpg', 'jpeg']
fileType: propTypes.array.def(['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf','apk','wgt','html','mp3','mp4']),
fileType: propTypes.array.def(['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf','apk','wgt','html','mp3','mp4','ttf']),
// 是否显示提示
isShowTip: propTypes.bool.def(true),
// 禁用组件(仅查看文件)

View File

@ -19,7 +19,7 @@ const getMqttConfig = () => {
// 检测当前页面协议http: 或 https:
//const isHttps = window.location.protocol === 'https:';
const isHttps = import.meta.env.VITE_APP_ENV === 'production' || window.location.protocol === 'https:';
const isHttps =true;// import.meta.env.VITE_APP_ENV === 'production' || window.location.protocol === 'https:';
console.log(isHttps,'检测环境');
return {
@ -222,9 +222,7 @@ export function useMqtt() {
return;
}
const message = new Paho.Message(
typeof payload === 'string' ? payload : payload.toString()
);
const message = new Paho.Message(payload);
message.destinationName = topic;
message.qos = options.qos;

View File

@ -58,17 +58,16 @@
<div class="current-voice">
<span class="voice-label">当前语音</span>
<div class="voice-select">
<el-input type="text" v-model="currentVoiceId" placeholder="当前语音" style="width: 100%;" :disabled="currentVoiceId"></el-input>
<!-- <el-select v-model="currentVoiceId" placeholder="请选择语音" style="width: 100%;">
<el-select v-model="currentVoiceId" placeholder="请选择语音" style="width: 100%;">
<el-option v-for="item in voiceList" :key="item.id" :label="item.fileNameExt"
:value="item.id" :disabled="item.id !== currentVoiceId">
:value="item.id" ite>
</el-option>
</el-select> -->
</el-select>
</div>
<el-button type="primary" class="play-btn" @click="playCurrentVoice"
v-if="deviceDetail.voiceBroadcast === 0">
<el-button type="primary" class="play-btn" @click="playCurrentVoice(1)"
v-if="deviceDetail.voiceBroadcast !== 1">
播放</el-button>
<el-button v-else type="info" class="play-btn" @click="playCurrentVoice"> 暂停
<el-button v-else type="info" class="play-btn" @click="playCurrentVoice(0)"> 暂停
</el-button>
</div>
<div class="voice-manage-section">
@ -202,7 +201,7 @@
<el-dialog title="上传语音" v-model="uploadVoiceDialog" width="480px" class="voice-dialog" :show-close="true">
<div class="upload-content">
<div class="upload-area" :class="{ dragOver: isDragOver }" @dragover.prevent="isDragOver = true"
@dragleave.prevent="isDragOver = false" @drop.prevent="handleDrop">
@dragleave.prevent="isDragOver = false" @drop.prevent="handleDrop" @click="triggerFileInput">
<div class="upload-icon">
<el-icon>
<Document />
@ -763,7 +762,6 @@ const handleVoiceType = async (targetId: string) => {
try {
const res = await api.SosSetting(params);
if (res.code === 200) proxy?.$modal.msgSuccess(res.msg);
deviceDetail.value.voiceBroadcast = 0;
} catch (error) {
await getList();
}
@ -939,41 +937,41 @@ const lookMap = (row: any) => {
const playCurrentVoice = async () => {
// 1. 报警中场景:播放/切换报警语音
if (deviceDetail.value.voiceStrobeAlarm === 1) {
const targetStatus = deviceDetail.value.voiceBroadcast === 1 ? 0 : 1;
try {
const currentMode = sta_VoiceType.value.find(mode => mode.active)?.id || '0';
const data = {
deviceIds: [route.params.deviceId],
voiceStrobeAlarm: deviceDetail.value.voiceBroadcast == 0 ? 1 : 0,
mode: 7
voiceStrobeAlarm: 1,
mode: currentMode
};
const res = await api.SosSetting(data);
if (res.code === 200) {
deviceDetail.value.voiceBroadcast = targetStatus;
proxy?.$modal.msgSuccess(res.msg);
await getList();
} else {
proxy?.$modal.msgError(res.msg);
}
} catch (err: any) {
// proxy?.$modal.msgError(err.msg);
}
}
// 2. 非报警中场景:单纯播放/暂停语音
else {
const targetStatus = deviceDetail.value.voiceBroadcast === 1 ? 0 : 1;
console.log(targetStatus, 'targetStatustargetStatustargetStatus');
try {
const res = await api.deviceVoiceBroadcast({
deviceId: route.params.deviceId,
voiceBroadcast: deviceDetail.value.voiceBroadcast==0 ? 1 : 0
voiceBroadcast: targetStatus
});
if (res.code === 200) {
deviceDetail.value.voiceBroadcast = targetStatus;
proxy?.$modal.msgSuccess(res.msg);
await getList();
} else {
proxy?.$modal.msgError(res.msg);
}
} catch (err: any) {
// proxy?.$modal.msgError(err.msg);
}
}
};
@ -984,6 +982,12 @@ onMounted(async () => {
});
onUnmounted(() => {
disconnect();
if (recordTimer) clearInterval(recordTimer);
if (mediaRecorder.value && isRecording.value) mediaRecorder.value.stop();
if (audioStream) audioStream.getTracks().forEach(track => track.stop());
// if (ttsAudio) ttsAudio.pause();
if (voiceAudio) voiceAudio.pause();
});
</script>
@ -1412,13 +1416,12 @@ onUnmounted(() => {
// 上传语音弹窗样式
.upload-content {
.upload-area {
// border: 2px dashed #dcdfe6;
border: 2px dashed #dcdfe6;
border-radius: 8px;
padding: 40px 20px;
text-align: center;
transition: all 0.3s;
cursor: pointer;
background: #EFF7FF;
&.dragOver {
border-color: #409eff;

View File

@ -0,0 +1,264 @@
<template>
<div class="text-to-hex">
<canvas
ref="canvasRef"
:width="currentCanvasWidth"
:height="currentCanvasHeight"
class="offscreen-canvas"
></canvas>
</div>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue';
// Props 定义
const props = defineProps({
txts: {
type: Array,
default: () => [],
validator: (value) => value.every(item => typeof item === 'string')
},
fontSize: {
type: Number,
default: 16,
validator: (value) => value > 0 && value <= 100
},
bgColor: {
type: String,
default: "#ffffff"
},
color: {
type: String,
default: "#000000"
},
fontFamily: {
type: String,
default: "PingFang SC, Microsoft YaHei, Arial, sans-serif"
}
});
// 响应式数据
const canvasRef = ref(null);
const currentCanvasWidth = ref(0);
const currentCanvasHeight = ref(0);
let ctx = null;
const canvasWarmed = ref(false);
// 计算属性
const validTxts = computed(() => {
return props.txts.filter(line => line && line.trim() !== '');
});
// 获取字符实际宽度
const getCharWidth = (char) => {
if (!ctx) return props.fontSize * 0.6;
ctx.font = `${props.fontSize}px ${props.fontFamily}`;
return ctx.measureText(char).width;
};
// 计算整行宽度(精确)
const calcLineWidth = (textLine) => {
if (!ctx) return textLine.length * props.fontSize * 0.6;
ctx.font = `${props.fontSize}px ${props.fontFamily}`;
let totalWidth = 0;
for (let i = 0; i < textLine.length; i++) {
totalWidth += ctx.measureText(textLine[i]).width;
}
return Math.ceil(totalWidth);
};
// 清除Canvas内容
const clearCanvas = () => {
if (!ctx) return;
ctx.fillStyle = props.bgColor;
ctx.fillRect(0, 0, currentCanvasWidth.value, currentCanvasHeight.value);
};
// 预热画布
const warmupCanvas = async () => {
if (canvasWarmed.value || !ctx) return;
try {
currentCanvasWidth.value = 16;
currentCanvasHeight.value = 16;
clearCanvas();
ctx.fillStyle = props.color;
ctx.font = `${props.fontSize}px ${props.fontFamily}`;
ctx.textBaseline = 'middle';
ctx.fillText('测', 0, 8);
// 等待字体加载完成
await document.fonts.ready;
// 获取像素数据验证画布可用
const imageData = ctx.getImageData(0, 0, 16, 16);
if (imageData) {
canvasWarmed.value = true;
}
// 额外等待确保字体完全渲染
await new Promise(resolve => setTimeout(resolve, 100));
} catch (ex) {
console.log("画布预热异常:", ex);
canvasWarmed.value = true;
}
};
// 像素数据转16进制矩阵
const convertCharToMatrix = (imageData, width, height) => {
let matrix = [];
const data = imageData.data;
// 只处理16x16的字符矩阵
for (let y = 0; y < 16; y++) {
let byte1 = 0, byte2 = 0;
for (let x = 0; x < 16; x++) {
// 计算实际像素位置需要考虑画布可能比16宽
let actualX = Math.floor(x * width / 16);
let actualY = Math.floor(y * height / 16);
let index = (actualY * width + actualX) * 4;
let red = data[index];
let green = data[index + 1];
let blue = data[index + 2];
// 判断是否为非背景色(根据颜色阈值)
// let isBlack = !(red > 200 && green > 200 && blue > 200);
let gray = (red + green + blue) / 3;
let isBlack = gray < 255 ;
if (x < 8) {
if (isBlack) {
byte1 |= 0x80 >> x;
}
} else {
if (isBlack) {
byte2 |= 0x80 >> (x - 8);
}
}
}
matrix.push('0x' + byte1.toString(16).padStart(2, '0').toUpperCase());
matrix.push('0x' + byte2.toString(16).padStart(2, '0').toUpperCase());
}
return matrix;
};
// 绘制单个字符并获取像素数据
const drawChar = async (char) => {
return new Promise((resolve, reject) => {
try {
// 获取字符宽度
const charWidth = getCharWidth(char);
const canvasWidth = Math.max(16, Math.ceil(charWidth));
// 调整画布尺寸
currentCanvasWidth.value = canvasWidth;
currentCanvasHeight.value = 16;
// 重置画布尺寸
if (canvasRef.value) {
canvasRef.value.width = canvasWidth;
canvasRef.value.height = 16;
}
// 清空画布
clearCanvas();
// 绘制字符
ctx.fillStyle = props.color;
ctx.font = `${props.fontSize}px ${props.fontFamily}`;
ctx.textBaseline = 'middle';
ctx.fillText(char, 0, 8);
// 获取像素数据
const imageData = ctx.getImageData(0, 0, canvasWidth, 16);
resolve({
char: char,
pixelData: imageData,
width: canvasWidth,
height: 16
});
} catch (err) {
reject(err);
}
});
};
// 绘制文本行并获取所有字符的矩阵数据
const drawLine = async (textLine) => {
const charMatrices = [];
for (let i = 0; i < textLine.length; i++) {
const char = textLine[i];
const result = await drawChar(char);
const matrix = convertCharToMatrix(result.pixelData, result.width, result.height);
charMatrices.push(matrix);
}
return charMatrices;
};
// 主方法:处理所有文本并返回十六进制矩阵数组
const drawAndGetPixels = async () => {
// 确保画布已预热
await warmupCanvas();
const result = [];
for (let i = 0; i < validTxts.value.length; i++) {
const line = validTxts.value[i];
const lineMatrices = await drawLine(line);
result.push(lineMatrices);
}
return result;
};
// 获取单个字符的十六进制矩阵(便捷方法)
const getCharHexMatrix = async (char) => {
await warmupCanvas();
const result = await drawChar(char);
return convertCharToMatrix(result.pixelData, result.width, result.height);
};
// 获取文本行的十六进制矩阵(便捷方法)
const getTextLineHexMatrix = async (textLine) => {
await warmupCanvas();
return await drawLine(textLine);
};
// 暴露方法给父组件
defineExpose({
drawAndGetPixels,
getCharHexMatrix,
getTextLineHexMatrix
});
// 生命周期
onMounted(() => {
if (canvasRef.value) {
ctx = canvasRef.value.getContext('2d');
}
});
</script>
<style scoped>
.text-to-hex {
position: relative;
}
.offscreen-canvas {
position: fixed;
left: -9999px;
top: -9999px;
visibility: hidden;
pointer-events: none;
}
</style>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -481,7 +481,11 @@ const { queryParams, form, rules } = toRefs<PageData<deviceForm, deviceQuery>>(d
/** 查询设备列表 */
const getList = async () => {
loading.value = true;
const res = await api.deviceList(proxy?.addDateRange(queryParams.value, dateRange.value));
let paras=Object.assign({},queryParams.value);
paras.deviceMac=paras.deviceMac.replace(/:/g,'').replace(//g,'').replace(/(.{2})/g, '$1:').slice(0, -1);
const res = await api.deviceList(proxy?.addDateRange(paras, dateRange.value));
loading.value = false;
deviceDist.value = res.rows;
total.value = res.total;
@ -501,6 +505,7 @@ const resetQuery = () => {
/** 删除按钮操作 */
const handleDelete = async (row?: deviceVO) => {
debugger;
// 批量删除逻辑
let arrey = ids.value.map((item) => item.id);
if (!row) {