This commit is contained in:
guanj
2025-09-23 08:44:17 +08:00
parent 50bc0f9396
commit 2e58e58c73
4 changed files with 1660 additions and 1594 deletions

View File

@@ -4,10 +4,10 @@ import { ElLoading, ElMessage, ElNotification, type LoadingOptions } from 'eleme
import { refreshToken } from '@/api/user-boot/user'
import router from '@/router/index'
import { useAdminInfo } from '@/stores/adminInfo'
import { set } from 'lodash'
window.requests = []
window.tokenRefreshing = false
let loginExpireTimer:any=null
const pendingMap = new Map()
const loadingInstance: LoadingInstance = {
target: null,
@@ -143,14 +143,29 @@ function createAxios<Data = any, T = ApiPromise<Data>>(
})
}
} else if (response.data.code == 'A0024') {
// 登录失效
ElMessage({
// // 登录失效
// 清除上一次的定时器
if (loginExpireTimer) {
clearTimeout(loginExpireTimer)
}
loginExpireTimer = setTimeout(() => {
ElNotification({
type: 'error',
message: response.data.message
})
adminInfo.removeToken()
router.push({ name: 'login' })
loginExpireTimer = null // 执行后清空定时器
}, 100) // 可根据实际情况调整延迟时间
return Promise.reject(response.data)
// // 登录失效
// ElMessage({
// type: 'error',
// message: response.data.message
// })
// adminInfo.removeToken()
// router.push({ name: 'login' })
// return Promise.reject(response.data)
} else {
if (options.showCodeMessage) {
if (response.config.url == '/access-boot/device/wlRegister') {

View File

@@ -173,6 +173,17 @@ const connectMqtt = () => {
const handleSearch = () => {
getMakeUpDataList(route.value)
}
function parseStringToObject(str:string) {
const content = str.replace(/^{|}$/g, '')
const pairs = content.split(',')
const result:any = {}
pairs.forEach(pair => {
const [key, value] = pair.split(':')
// 尝试将数字转换为Number类型
result[key.trim()] = isNaN(Number(value)) ? value.trim() : Number(value)
})
return result
}
connectMqtt()
mqttRef.value.on('connect', () => {
// ElMessage.success('连接mqtt服务器成功!')
@@ -188,10 +199,7 @@ mqttRef.value.on('message', (topic: any, message: any) => {
let str = JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))
let regex1 = /allStep:(.*?),nowStep/
let regex2 = /nowStep:(.*?)}/
mqttMessage.value = {
allStep: str.match(regex1)[1],
nowStep: str.match(regex2)[1]
}
mqttMessage.value = parseStringToObject(str)
// console.log(mqttMessage.value)
let checkedList = tableRef.value.getCheckboxRecords().map((item: any) => {
return item.name

View File

@@ -8,8 +8,12 @@
<div class="right_nav">
<div class="menu" v-if="activePathList.length != 0">
<el-breadcrumb separator="/">
<el-breadcrumb-item v-for="(item, index) in activePathList" style="cursor: pointer" :key="index"
@click="handleIntoByPath(item)">
<el-breadcrumb-item
v-for="(item, index) in activePathList"
style="cursor: pointer"
:key="index"
@click="handleIntoByPath(item)"
>
<span>{{ outPutPath(item, index) }}</span>
</el-breadcrumb-item>
</el-breadcrumb>
@@ -20,14 +24,27 @@
</div>
<div class="filter" v-if="activePathList.length != 0">
<el-input maxlength="32" show-word-limit style="width: 200px; height: 32px" placeholder="请输入文件或文件夹名称"
clearable v-model.trim="filterText" type="text"></el-input>
<el-input
maxlength="32"
show-word-limit
style="width: 200px; height: 32px"
placeholder="请输入文件或文件夹名称"
clearable
v-model.trim="filterText"
type="text"
></el-input>
<el-button type="primary" @click="handleSearch" :icon="Search">搜索</el-button>
<!-- <el-button @click="handleRefresh" :icon="Refresh">重置</el-button> -->
<el-upload v-if="activePath != '/'" action="" :auto-upload="false" :show-file-list="false" :on-change="(file: any, fileList: any) => {
<el-upload
v-if="activePath != '/'"
action=""
:auto-upload="false"
:show-file-list="false"
:on-change="(file: any, fileList: any) => {
handleUpload(file, fileList, activePath)
}
">
"
>
<el-button>
文件上传
<el-icon class="el-icon--right">
@@ -45,14 +62,24 @@
</div>
<!-- 以列表形式展示 -->
<div :style="tableHeight">
<vxe-table style="margin-top: 10px" border auto-resize height="auto" :data="dirList"
v-bind="defaultAttribute">
<vxe-table
style="margin-top: 10px"
border
auto-resize
height="auto"
:data="dirList"
v-bind="defaultAttribute"
>
<vxe-column type="seq" title="序号" width="80"></vxe-column>
<vxe-column field="prjDataPath" align="center" title="名称" #default="{ row }">
<span style="cursor: pointer; color: #551a8b" :style="{
<span
style="cursor: pointer; color: #551a8b"
:style="{
'text-decoration': row.type == 'dir' ? 'underline' : 'none',
color: row.type == 'dir' ? '#551a8b' : '#000'
}" @click="handleIntoDir(row)">
}"
@click="handleIntoDir(row)"
>
{{
row &&
row?.prjDataPath &&
@@ -83,8 +110,13 @@
<vxe-column title="操作" width="200px">
<template #default="{ row }">
<el-button link size="small" type="danger" @click="handleDelDirOrFile(row)">删除</el-button>
<el-button v-if="row.type == 'file'" link size="small" type="primary"
@click="handleDownLoad(row)">
<el-button
v-if="row.type == 'file'"
link
size="small"
type="primary"
@click="handleDownLoad(row)"
>
下载
</el-button>
</template>
@@ -95,8 +127,13 @@
<div class="list" v-if="dirList.length != 0 && !loading" style="display: none">
<div class="list_item" v-for="(item, index) in dirList" :key="index">
<div class="item_download">
<el-button v-if="activePath && activePath != '/'" type="danger" size="small"
@click="handleDelDirOrFile(item)" circle>
<el-button
v-if="activePath && activePath != '/'"
type="danger"
size="small"
@click="handleDelDirOrFile(item)"
circle
>
<el-icon>
<Delete />
</el-icon>
@@ -108,8 +145,12 @@
</el-button>
</div>
<img v-if="item?.type == 'dir'" @click="handleIntoDir(item)" src="@/assets/img/wenjianjia.svg" />
<img class="img_file" @click="handleIntoDir(item)" v-if="item?.type == 'file'"
src="@/assets/img/wenjian.svg" />
<img
class="img_file"
@click="handleIntoDir(item)"
v-if="item?.type == 'file'"
src="@/assets/img/wenjian.svg"
/>
<!-- <span v-if="!item.type">暂无数据</span> -->
<p>
{{
@@ -126,9 +167,18 @@
<!-- <el-empty v-if="dirList.length === 0" /> -->
</div>
<popup ref="fileRef"></popup>
<el-dialog v-model.trim="addDeviceDirOpen" :destroy-on-close="true" title="新建文件夹目录" width="500" @closed="close">
<el-form ref="formRef" :model="form"
:rules="{ path: [{ required: true, message: '请输入文件夹名称', trigger: 'blur' }] }">
<el-dialog
v-model.trim="addDeviceDirOpen"
:destroy-on-close="true"
title="新建文件夹目录"
width="500"
@closed="close"
>
<el-form
ref="formRef"
:model="form"
:rules="{ path: [{ required: true, message: '请输入文件夹名称', trigger: 'blur' }] }"
>
<el-form-item label="文件夹名称" prop="path">
<el-input maxlength="32" show-word-limit v-model.trim="form.path" placeholder="请输入文件夹名称" />
</el-form-item>
@@ -251,18 +301,16 @@ const handleRestartDevice = () => {
customClass: 'customInput',
inputType: 'text',
beforeClose: (action, instance, done) => {
if (action === 'confirm') {
if (instance.inputValue == null) {
return ElMessage.warning('请输入密码')
} else if (instance.inputValue?.length > 32) {
return ElMessage.warning('密码长度不能超过32位,当前密码长度为' + instance.inputValue.length)
} else {
done();
done()
}
} else {
done();
done()
}
}
})
@@ -439,18 +487,16 @@ const handleDelDirOrFile = (row: any) => {
customClass: 'customInput',
inputType: 'text',
beforeClose: (action, instance, done) => {
if (action === 'confirm') {
if (instance.inputValue == null) {
return ElMessage.warning('请输入密码')
} else if (instance.inputValue?.length > 32) {
return ElMessage.warning('密码长度不能超过32位,当前密码长度为' + instance.inputValue.length)
} else {
done();
done()
}
} else {
done();
done()
}
}
}).then(({ value }) => {
@@ -550,23 +596,29 @@ mqttRef.value.on('connect', (e: any) => {
})
const mqttMessage = ref<any>({})
const status: any = ref()
function parseStringToObject(str:string) {
const content = str.replace(/^{|}$/g, '')
const pairs = content.split(',')
const result:any = {}
pairs.forEach(pair => {
const [key, value] = pair.split(':')
// 尝试将数字转换为Number类型
result[key.trim()] = isNaN(Number(value)) ? value.trim() : Number(value)
})
return result
}
mqttRef.value.on('message', (topic: any, message: any) => {
// console.log('mqtt接收到消息', JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message)))))
let str = JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))
let regex = /fileName:(.*?),allStep/
let regex1 = /allStep:(.*?),nowStep/
let regex2 = /nowStep:(.*?),userId/
let regex3 = /userId:(.*?)}/
mqttMessage.value = {
fileName: str.match(regex)[1],
allStep: str.match(regex1)[1],
nowStep: str.match(regex2)[1],
userId: str.match(regex3)[1]
}
mqttMessage.value = parseStringToObject(str)
// console.log("🚀 ~ str.match(regex3)[1]:", str.match(regex3)[1])
status.value = parseInt(Number((mqttMessage.value.nowStep / mqttMessage.value.allStep) * 100))
fileRef.value.setStatus(mqttMessage.value)
@@ -591,7 +643,6 @@ onMounted(() => {
changeType.value = localStorage.getItem('changeType') ? localStorage.getItem('changeType') : ''
})
onBeforeUnmount(() => {
console.log(6666);
if (mqttRef.value) {
mqttRef.value.end()
}

View File

@@ -107,13 +107,9 @@ const editd = (e: any) => {
}
// 设计
const Aclick = (e: any) => {
window.open(window.location.origin + `/zutai/?id=${e.id}&&name=decodeURI(${e.name})&&flag=false`)
// const link = document.createElement("a"); //创建下载a标签
// link.target = `_blank`;
// link.href = `http://192.168.1.128:3001/zutai/?id=${e.id}&&name=decodeURI(${e.name})&&flag=false`;
// link.style.display = "none"; //默认隐藏元素
// document.body.appendChild(link); // body中添加元素
// link.click(); // 执行点击事件
window.open(window.location.origin + `/zutai/?id=${e.id}&&name=${e.name}&&preview=false`)
// window.open('http://192.168.1.128:4001' + `/zutai/?id=${e.id}&&name=${e.name}&&preview=false`)
}
const shejid = (e: any) => { }
// 删除
@@ -148,13 +144,9 @@ const deleted = (e: any) => {
}
const imgData = (e: any) => {
window.open(window.location.origin + `/zutai/?id=${e.id}&&name=decodeURI(${e.name})&&flag=true`)
// const link = document.createElement("a"); //创建下载a标签
// link.target = `_blank`;
// link.href = `http://192.168.1.128:3001/zutai/#/?id=${e.id}&&name=decodeURI(${e.name})&&flag=true`;
// link.style.display = "none"; //默认隐藏元素
// document.body.appendChild(link); // body中添加元素
// link.click(); // 执行点击事件
window.open(window.location.origin + `/zutai/?id=${e.id}&&name=${e.name}&&preview=true#/preview`)
// window.open('http://192.168.1.128:4001' + `/zutai/?id=${e.id}&&name=${e.name}&&preview=true#/preview`)
}
const onTableSizeChange = (val: number) => {