WebSocket代码提交
This commit is contained in:
parent
0ce8d92a5a
commit
245c160d94
@ -3,7 +3,7 @@ window.webConfig = {
|
||||
"VITEAPPBASEWEB": "https://edu.mmhyvision.com/vision",
|
||||
"webApiBaseApp": "https://edu.mmhyvision.com/parent",
|
||||
"mapUrl":"http://192.168.1.208",
|
||||
|
||||
"WebSocketUrl":"ws://192.168.1.208:8087",
|
||||
"title": "文档与数据管理系统",
|
||||
"bgImg": "beijing.jpg",
|
||||
"loginLogo": "uplogo.png",
|
||||
|
@ -18,6 +18,7 @@ export const useUserStore = defineStore('user', () => {
|
||||
const perms = ref<Array<string>>([]); // 用户权限编码集合 → 判断按钮权限
|
||||
const badgeval = ref('')
|
||||
const webApiBaseUrl: any = process.env.NODE_ENV == 'development' ? import.meta.env.VITE_APP_BASE_API : window.webConfig.webApiBaseUrl
|
||||
const WebSocketUrl:any = window.webConfig.WebSocketUrl
|
||||
const webApiBaseHttp: any = process.env.NODE_ENV == 'development' ? import.meta.env.VITE_APP_BASE_WEB : window.webConfig.VITEAPPBASEWEB
|
||||
const mapUrl: any = window.webConfig.mapUrl
|
||||
const webApiBaseApp: any = window.webConfig.webApiBaseApp
|
||||
@ -117,6 +118,7 @@ export const useUserStore = defineStore('user', () => {
|
||||
resetToken,
|
||||
badgeval,
|
||||
webApiBaseUrl,
|
||||
WebSocketUrl,
|
||||
mapUrl,
|
||||
webApiBaseHttp,
|
||||
webApiBaseApp,
|
||||
|
@ -5,14 +5,15 @@ export default {
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, nextTick, defineAsyncComponent } from "vue";
|
||||
import { ref, onMounted, nextTick, defineAsyncComponent,onBeforeUnmount } from "vue";
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { ElMessageBox, ElMessage } from "element-plus";
|
||||
import { Search } from '@element-plus/icons-vue'
|
||||
import Page from '@/components/Pagination/page.vue';
|
||||
import AudioPlayer from '@/components/file/preview/AudioPlayer.vue';
|
||||
import { batchDeleteReq } from "@/api/file-operator";
|
||||
import { projectList, documentUploadById,obtainInformationAsync,getNodesTree, addNodes, updateNodes, deleteNodesById, getFilesPage, addFiles, updateFiles, deleteFilesById, deleteFilesByIds, specialScanById } from "@/api/document";
|
||||
import { projectList, documentUploadById, obtainInformationAsync, getNodesTree, addNodes, updateNodes, deleteNodesById, getFilesPage, addFiles, updateFiles, deleteFilesById, deleteFilesByIds, specialScanById } from "@/api/document";
|
||||
import ZUpload from '@/components/file/ZUpload.vue'
|
||||
import useFileUpload from "@/components/file/file/useFileUpload";
|
||||
import useHeaderStorageList from "@/components/header/useHeaderStorageList";
|
||||
@ -38,10 +39,35 @@ const { dialogVideoVisible, dialogTextVisible, dialogPdfVisible, dialogOfficeVis
|
||||
const { openUploadDialog, openUploadFolderDialog, uploadProgressInfoStatistics, clearALlFinishedUploadFile } = useFileUpload();
|
||||
const { currentStorageKey } = useHeaderStorageList();
|
||||
const { openRow } = useFileData();
|
||||
const userStore = useUserStore();
|
||||
onMounted(() => {
|
||||
getProject()
|
||||
|
||||
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
if (ws1 != null) {
|
||||
ws1.close()
|
||||
}
|
||||
})
|
||||
const projectId = ref()
|
||||
//websocket
|
||||
let ws1
|
||||
function setupWebSocket() {
|
||||
ws1.onopen = () => {
|
||||
console.log('websocket连接成功')
|
||||
};
|
||||
ws1.onerror = (error) => {
|
||||
};
|
||||
ws1.onmessage = (e) => {
|
||||
console.log('websocket接收到消息',e)
|
||||
tonstatus()
|
||||
}
|
||||
ws1.onclose = () => {
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
//拖动条
|
||||
const vMove = {
|
||||
mounted(el: any) {
|
||||
@ -61,7 +87,7 @@ const vMove = {
|
||||
}
|
||||
}
|
||||
//左侧树的选择框
|
||||
const projectId = ref()
|
||||
|
||||
const projectArr = ref([])
|
||||
const projectName = ref('')
|
||||
//获取所有项目
|
||||
@ -70,7 +96,10 @@ function getProject() {
|
||||
projectArr.value = res.data
|
||||
projectId.value = projectArr.value[0].id
|
||||
projectName.value = projectArr.value[0].projectName
|
||||
gettreedata()
|
||||
ws1 = new WebSocket(userStore.WebSocketUrl + '/websocket/' + 'projectId_' + projectId.value )
|
||||
setupWebSocket()
|
||||
tonstatus()
|
||||
// gettreedata()
|
||||
|
||||
})
|
||||
}
|
||||
@ -104,7 +133,7 @@ function gettreedata() {
|
||||
getNodesTree(treeForm.value).then((res: any) => {
|
||||
treedata.value = res.data
|
||||
treeloading.value = false
|
||||
filePath.value = res.data[0].path + res.data[0].nodeName +'/'
|
||||
filePath.value = res.data[0].path + res.data[0].nodeName + '/'
|
||||
if (treedata.value[0]) {
|
||||
pathid.value = treedata.value[0].id
|
||||
nextTick(() => {
|
||||
@ -114,14 +143,14 @@ function gettreedata() {
|
||||
} else {
|
||||
tableData.value.length = 0
|
||||
}
|
||||
tonstatus()
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
const pathid = ref()
|
||||
function handleNodeClick(data: any, node: any) {
|
||||
pathid.value = data.id
|
||||
filePath.value = data.path + data.nodeName +'/'
|
||||
filePath.value = data.path + data.nodeName + '/'
|
||||
getdata()
|
||||
}
|
||||
//子项目配置
|
||||
@ -157,7 +186,7 @@ function addSubItem(row: any) {
|
||||
|
||||
if (row.nodeType == '00') {
|
||||
projectForme.value.parentId = '00'
|
||||
projectForme.value.path = '/'+projectName.value+'/'
|
||||
projectForme.value.path = '/' + projectName.value + '/'
|
||||
} else {
|
||||
projectForme.value.parentId = row.id
|
||||
projectForme.value.path = filePath.value
|
||||
@ -250,7 +279,7 @@ function delSubItem(row: any) {
|
||||
.then(() => {
|
||||
treeloading.value = true
|
||||
loading.value = true
|
||||
deleteNodesById({ id: row.id,path:row.path }).then((res: any) => {
|
||||
deleteNodesById({ id: row.id, path: row.path }).then((res: any) => {
|
||||
if (res.code == 0) {
|
||||
gettreedata()
|
||||
ElMessage({
|
||||
@ -400,14 +429,14 @@ function bytesToMB(bytes: any) {
|
||||
//上传确定
|
||||
|
||||
function submitfile() {
|
||||
if (localStorage.getItem('filepath') == '/temporary'){
|
||||
documentUploadById({fileName:JSON.parse(localStorage.getItem('fileArr'))[0].name,id:projectId.value}).then((res:any)=>{
|
||||
if(res.code == 0){
|
||||
if (localStorage.getItem('filepath') == '/temporary') {
|
||||
documentUploadById({ fileName: JSON.parse(localStorage.getItem('fileArr'))[0].name, id: projectId.value }).then((res: any) => {
|
||||
if (res.code == 0) {
|
||||
tonstatus()
|
||||
upfile.value = false
|
||||
}
|
||||
})
|
||||
}else {
|
||||
} else {
|
||||
if (fileObj.value.id) {
|
||||
updateFiles(fileObj.value).then((res: any) => {
|
||||
if (res.code == 0) {
|
||||
@ -721,31 +750,25 @@ const fileIcon = (row: any) => {
|
||||
// };
|
||||
const tonloading = ref(false)
|
||||
const tonloading1 = ref(false)
|
||||
const buttonmsg1 = ref('上传项目包并扫描')
|
||||
function tonstatus(){
|
||||
const buttonmsg1 = ref('初始化导入项目完整压缩包')
|
||||
function tonstatus() {
|
||||
//sao
|
||||
obtainInformationAsync({id:projectId.value,type:'0'}).then((res:any)=>{
|
||||
if(res.msg == '1'){
|
||||
obtainInformationAsync({ id: projectId.value }).then((res: any) => {
|
||||
if (res.data.status == '1' && res.data.name == '扫描' ) {
|
||||
tonloading.value = false
|
||||
buttonmsg.value = '扫描项目文档'
|
||||
}else{
|
||||
buttonmsg.value = '扫描项目完整路径'
|
||||
} else if(res.data.status == '0' && res.data.name == '扫描') {
|
||||
tonloading.value = true
|
||||
buttonmsg.value = '处理中...'
|
||||
}
|
||||
|
||||
})
|
||||
//chuan
|
||||
obtainInformationAsync({id:projectId.value,type:'1'}).then((res:any)=>{
|
||||
tonloading1.value
|
||||
if(res.msg == '1'){
|
||||
} else if(res.data.status == '1' && res.data.name == '上传'){
|
||||
tonloading1.value = false
|
||||
buttonmsg1.value = '上传项目包并扫描'
|
||||
}else{
|
||||
buttonmsg1.value = '初始化导入项目完整压缩包'
|
||||
}else if(res.data.status == '0' && res.data.name == '上传'){
|
||||
tonloading1.value = true
|
||||
buttonmsg1.value = '处理中...'
|
||||
}
|
||||
})
|
||||
// gettreedata()
|
||||
gettreedata()
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -784,10 +807,12 @@ function tonstatus(){
|
||||
</template>
|
||||
</el-tree>
|
||||
<div>
|
||||
<el-button type="primary" :loading="tonloading" @click="scan()" style="width: 100%;margin-bottom: 5px;">{{ buttonmsg
|
||||
<el-button type="primary" :loading="tonloading1" @click="upfileZip()" :disabled="tonloading"
|
||||
style="width: 100%;margin-bottom: 5px;">{{ buttonmsg1 }}</el-button>
|
||||
<el-button type="primary" :loading="tonloading" @click="scan()" :disabled="tonloading1"
|
||||
style="width: 100%;margin-left: 0px;">{{ buttonmsg
|
||||
}}</el-button>
|
||||
<el-button type="primary" :loading="tonloading1" @click="upfileZip()"
|
||||
style="width: 100%;margin-left: 0px;">{{buttonmsg1}}</el-button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -855,12 +880,13 @@ function tonstatus(){
|
||||
</Page>
|
||||
|
||||
</section>
|
||||
<el-dialog :title="title" v-model="frame" width="30%" :before-close="handleClose" top="30px" draggable :close-on-click-modal="false"
|
||||
destroy-on-close>
|
||||
<el-dialog :title="title" v-model="frame" width="30%" :before-close="handleClose" top="30px" draggable
|
||||
:close-on-click-modal="false" destroy-on-close>
|
||||
<el-form ref="ruleFormRef" style="max-width: 600px" :model="projectForme" :rules="moderules"
|
||||
label-width="auto" class="demo-ruleForm" status-icon>
|
||||
<el-form-item label="节点名称" prop="nodeName">
|
||||
<el-input v-model="projectForme.nodeName" maxlength="40" show-word-limit :disabled="projectForme.id" />
|
||||
<el-input v-model="projectForme.nodeName" maxlength="40" show-word-limit
|
||||
:disabled="projectForme.id" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<div style="width: 100%;display: flex;justify-content: end;">
|
||||
@ -870,8 +896,8 @@ function tonstatus(){
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
<el-dialog :title="title" v-model="upfile" width="50%" :before-close="fileClose" top="30px" draggable :close-on-click-modal="false"
|
||||
destroy-on-close>
|
||||
<el-dialog :title="title" v-model="upfile" width="50%" :before-close="fileClose" top="30px" draggable
|
||||
:close-on-click-modal="false" destroy-on-close>
|
||||
<el-scrollbar :height="judge ? '400px' : ''">
|
||||
<el-form ref="ruleFormRef" style="max-width: 100%" :model="fileObj" :rules="moderqqqules"
|
||||
label-width="auto" class="demo-ruleForm" status-icon>
|
||||
@ -900,12 +926,13 @@ function tonstatus(){
|
||||
</el-dialog>
|
||||
<!-- 组件预览 -->
|
||||
<!-- 视频播放器 -->
|
||||
<el-dialog draggable :close-on-click-modal="false" class="zfile-video-dialog" :destroy-on-close="true" v-model="dialogVideoVisible">
|
||||
<el-dialog draggable :close-on-click-modal="false" class="zfile-video-dialog" :destroy-on-close="true"
|
||||
v-model="dialogVideoVisible">
|
||||
<video-player v-if="dialogVideoVisible" ref="videoPlayer" />
|
||||
</el-dialog>
|
||||
<!-- 文本编辑器 -->
|
||||
<el-dialog draggable :close-on-click-modal="false" class="zfile-text-dialog zfile-dialog-mini-close" :destroy-on-close="true"
|
||||
:title="filePreview.fileName" v-model="dialogTextVisible">
|
||||
<el-dialog draggable :close-on-click-modal="false" class="zfile-text-dialog zfile-dialog-mini-close"
|
||||
:destroy-on-close="true" :title="filePreview.fileName" v-model="dialogTextVisible">
|
||||
<TextViewer :file-name="filePreview.fileName" :file-url="filePreview.url"
|
||||
v-if="dialogTextVisible && filePreview.fileName.indexOf('.md') === -1" />
|
||||
<MarkdownViewer :file-name="filePreview.fileName" :file-url="filePreview.url"
|
||||
@ -913,18 +940,21 @@ function tonstatus(){
|
||||
</el-dialog>
|
||||
|
||||
<!-- pdf 在线预览 -->
|
||||
<el-dialog draggable :close-on-click-modal="false" class="zfile-pdf-dialog" :title="filePreview.fileName" v-model="dialogPdfVisible">
|
||||
<el-dialog draggable :close-on-click-modal="false" class="zfile-pdf-dialog" :title="filePreview.fileName"
|
||||
v-model="dialogPdfVisible">
|
||||
<PdfViewer :file-name="filePreview.fileName" :file-url="filePreview.url" v-if="dialogPdfVisible" />
|
||||
</el-dialog>
|
||||
|
||||
<!-- office 在线预览 -->
|
||||
<el-dialog draggable :close-on-click-modal="false" class="zfile-office-dialog zfile-dialog-mini-close zfile-dialog-hidden-title"
|
||||
:title="filePreview.fileName" v-model="dialogOfficeVisible">
|
||||
<el-dialog draggable :close-on-click-modal="false"
|
||||
class="zfile-office-dialog zfile-dialog-mini-close zfile-dialog-hidden-title" :title="filePreview.fileName"
|
||||
v-model="dialogOfficeVisible">
|
||||
<OfficeViewer :file-name="filePreview.fileName" :file-url="filePreview.url" v-if="dialogOfficeVisible" />
|
||||
</el-dialog>
|
||||
|
||||
<!-- 3d 在线预览 -->
|
||||
<el-dialog draggable :close-on-click-modal="false" class="zfile-3d-dialog" :title="filePreview.fileName" v-model="dialog3dVisible">
|
||||
<el-dialog draggable :close-on-click-modal="false" class="zfile-3d-dialog" :title="filePreview.fileName"
|
||||
v-model="dialog3dVisible">
|
||||
<Three3dPreview :file-name="filePreview.fileName" :file-url="filePreview.url" v-if="dialog3dVisible" />
|
||||
</el-dialog>
|
||||
<!-- 音频播放器 -->
|
||||
|
27
web/src/views/testdata/datamanagement/index.vue
vendored
27
web/src/views/testdata/datamanagement/index.vue
vendored
@ -50,9 +50,13 @@ const { openRow } = useFileData();
|
||||
const userStore = useUserStore();
|
||||
onMounted(() => {
|
||||
getProject()
|
||||
|
||||
});
|
||||
onUnmounted(() => {
|
||||
closeSSE()
|
||||
if (ws1 != null) {
|
||||
ws1.close()
|
||||
}
|
||||
})
|
||||
//拖动条
|
||||
const vMove = {
|
||||
@ -72,8 +76,25 @@ const vMove = {
|
||||
};
|
||||
}
|
||||
}
|
||||
//左侧树的选择框
|
||||
const projectId = ref()
|
||||
let ws1
|
||||
function setupWebSocket() {
|
||||
ws1.onopen = () => {
|
||||
console.log('websocket连接成功')
|
||||
};
|
||||
ws1.onerror = (error) => {
|
||||
};
|
||||
ws1.onmessage = (e) => {
|
||||
console.log('websocket接收到消息',e)
|
||||
tonstatus()
|
||||
}
|
||||
ws1.onclose = () => {
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
//左侧树的选择框
|
||||
|
||||
const projectArr = ref([])
|
||||
const taskName = ref('')
|
||||
//获取所有项目
|
||||
@ -82,6 +103,8 @@ function getProject() {
|
||||
projectArr.value = res.data
|
||||
projectId.value = projectArr.value[0].id
|
||||
taskName.value = projectArr.value[0].taskName
|
||||
ws1 = new WebSocket(userStore.WebSocketUrl + '/websocket/' + 'taskId' + projectId.value )
|
||||
setupWebSocket()
|
||||
gettreedata()
|
||||
tonstatus()
|
||||
})
|
||||
@ -97,7 +120,7 @@ const buttonmsg = ref('扫描试验数据')
|
||||
function tonstatus() {
|
||||
//sao
|
||||
obtaintestData({ id: projectId.value }).then((res: any) => {
|
||||
if (res.msg == '1') {
|
||||
if (res.data.status == '1') {
|
||||
tonloading.value = false
|
||||
buttonmsg.value = '扫描试验数据'
|
||||
} else {
|
||||
|
@ -8,6 +8,7 @@ export default {
|
||||
import { ref, onMounted, nextTick, defineAsyncComponent, onBeforeUnmount } from "vue";
|
||||
import { Search } from '@element-plus/icons-vue'
|
||||
import { ElMessageBox, ElMessage } from "element-plus";
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { tstaskList, getTsNodesTree, tsFilesPage, deleteTsFilesByIds } from "@/api/datamanagement";
|
||||
import { listLocalAndBackup, compare, compareLocalList, automaticFileBackupByIds, compareMd5List, compareMinioList, compareLocal, compareMd5, compareMinio, uploadToBackup, downloadToLocal, deleteTsFilesById, automaticFileBackup, obtainUrl, listBackupTree, listLocalTree,automaticFileBackupData } from "@/api/fileSynchronization";
|
||||
import { debounce } from 'lodash-es';
|
||||
@ -25,6 +26,23 @@ import MarkdownViewerDialogAsyncLoading from "@/components/file/preview/Markdown
|
||||
const { dialogVideoVisible, dialogTextVisible, dialogPdfVisible, dialogOfficeVisible, dialog3dVisible } = useFilePreview();
|
||||
|
||||
const { openRow } = useFileData();
|
||||
const userStore = useUserStore();
|
||||
let ws1 = new WebSocket(userStore.WebSocketUrl + '/websocket/' + 'backups' )
|
||||
function setupWebSocket() {
|
||||
ws1.onopen = () => {
|
||||
console.log('websocket连接成功')
|
||||
};
|
||||
ws1.onerror = (error) => {
|
||||
};
|
||||
ws1.onmessage = (e) => {
|
||||
console.log('websocket接收到消息',e)
|
||||
tonstatus()
|
||||
}
|
||||
ws1.onclose = () => {
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
//左侧树的选择框
|
||||
const projectId = ref()
|
||||
@ -871,6 +889,7 @@ function bfclick(type: any) {
|
||||
}
|
||||
onMounted(() => {
|
||||
getProject()
|
||||
setupWebSocket()
|
||||
});
|
||||
// 组件卸载时取消防抖(可选)
|
||||
// onBeforeUnmount(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user