diff --git a/public/config/config.json b/public/config/config.json index 181a4b5..842e02c 100644 --- a/public/config/config.json +++ b/public/config/config.json @@ -1,9 +1,9 @@ { "title": "安全生产智慧监管系统", - "baseUrl": "http://192.168.83.42:6909/safe-server/", + "baseUrl": "http://192.168.83.65:6909/safe-server/", "deployPathDec": "****************注意:这个/alarm的alarm一定要改成部署的文件夹的名字***************************", "deployPath": "/alarm", - "mediaBaseUrl": "http://192.168.83.42:80", + "mediaBaseUrl": "http://192.168.83.65:8099", "lat-bd": "39.91459528", "lng-bd": "116.26499505", "lat": "39.90", @@ -12,7 +12,7 @@ "maxZoom": "18", "zoom": "15", "timeGap": 600000, - "systemType": "gm", + "systemType": "sm", "lineWidth": "3", "lineColor": "#1aa034", "fontSize": "18px", diff --git a/public/config/config.json b/public/config/config.json index 181a4b5..842e02c 100644 --- a/public/config/config.json +++ b/public/config/config.json @@ -1,9 +1,9 @@ { "title": "安全生产智慧监管系统", - "baseUrl": "http://192.168.83.42:6909/safe-server/", + "baseUrl": "http://192.168.83.65:6909/safe-server/", "deployPathDec": "****************注意:这个/alarm的alarm一定要改成部署的文件夹的名字***************************", "deployPath": "/alarm", - "mediaBaseUrl": "http://192.168.83.42:80", + "mediaBaseUrl": "http://192.168.83.65:8099", "lat-bd": "39.91459528", "lng-bd": "116.26499505", "lat": "39.90", @@ -12,7 +12,7 @@ "maxZoom": "18", "zoom": "15", "timeGap": 600000, - "systemType": "gm", + "systemType": "sm", "lineWidth": "3", "lineColor": "#1aa034", "fontSize": "18px", diff --git a/public/playerVideo6/jessibuca.js b/public/playerVideo6/jessibuca.js index 1450494..601f208 100644 --- a/public/playerVideo6/jessibuca.js +++ b/public/playerVideo6/jessibuca.js @@ -37,8 +37,8 @@ hasControl: !1, loadingText: '', background: '', - decoder: `${window.localStorage.getItem('deployPath')}/playerVideo6/decoder.js`, // 线上使用 - // decoder: `/playerVideo6/decoder.js`, // 本地使用 + // decoder: `${window.localStorage.getItem('deployPath')}/playerVideo6/decoder.js`, // 线上使用 + decoder: `/playerVideo6/decoder.js`, // 本地使用 // decoder: import.meta.env.MODE === 'development' ? `/playerVideo6/decoder.js` : `${window.localStorage.getItem('deployPath')}/playerVideo6/decoder.js`, url: '', rotate: 0, diff --git a/public/config/config.json b/public/config/config.json index 181a4b5..842e02c 100644 --- a/public/config/config.json +++ b/public/config/config.json @@ -1,9 +1,9 @@ { "title": "安全生产智慧监管系统", - "baseUrl": "http://192.168.83.42:6909/safe-server/", + "baseUrl": "http://192.168.83.65:6909/safe-server/", "deployPathDec": "****************注意:这个/alarm的alarm一定要改成部署的文件夹的名字***************************", "deployPath": "/alarm", - "mediaBaseUrl": "http://192.168.83.42:80", + "mediaBaseUrl": "http://192.168.83.65:8099", "lat-bd": "39.91459528", "lng-bd": "116.26499505", "lat": "39.90", @@ -12,7 +12,7 @@ "maxZoom": "18", "zoom": "15", "timeGap": 600000, - "systemType": "gm", + "systemType": "sm", "lineWidth": "3", "lineColor": "#1aa034", "fontSize": "18px", diff --git a/public/playerVideo6/jessibuca.js b/public/playerVideo6/jessibuca.js index 1450494..601f208 100644 --- a/public/playerVideo6/jessibuca.js +++ b/public/playerVideo6/jessibuca.js @@ -37,8 +37,8 @@ hasControl: !1, loadingText: '', background: '', - decoder: `${window.localStorage.getItem('deployPath')}/playerVideo6/decoder.js`, // 线上使用 - // decoder: `/playerVideo6/decoder.js`, // 本地使用 + // decoder: `${window.localStorage.getItem('deployPath')}/playerVideo6/decoder.js`, // 线上使用 + decoder: `/playerVideo6/decoder.js`, // 本地使用 // decoder: import.meta.env.MODE === 'development' ? `/playerVideo6/decoder.js` : `${window.localStorage.getItem('deployPath')}/playerVideo6/decoder.js`, url: '', rotate: 0, diff --git a/src/utils/download.ts b/src/utils/download.ts index 9efd4ac..88a45c5 100644 --- a/src/utils/download.ts +++ b/src/utils/download.ts @@ -97,19 +97,22 @@ * @param fileName 文件名称 */ export function urlToBlob(url: string, name: string) { - const xhr = new XMLHttpRequest() - xhr.open('get', url) - xhr.responseType = 'blob' // ""|"text"-字符串 "blob"-Blob对象 "arraybuffer"-ArrayBuffer对象 - xhr.onload = function () { - const path = URL.createObjectURL(xhr.response) - const link = document.createElement('a') - link.download = name - link.href = path - link.click() - link.remove() - window.URL.revokeObjectURL(link.href) - } - xhr.send() + return new Promise((resolve) => { + const xhr = new XMLHttpRequest() + xhr.open('get', url) + xhr.responseType = 'blob' // ""|"text"-字符串 "blob"-Blob对象 "arraybuffer"-ArrayBuffer对象 + xhr.onload = function () { + const path = URL.createObjectURL(xhr.response) + const link = document.createElement('a') + link.download = name + link.href = path + link.click() + link.remove() + window.URL.revokeObjectURL(link.href) + resolve(null) + } + xhr.send() + }) } /** @@ -117,35 +120,48 @@ * @param url 网络文件地址 * @param name 文件名 */ -export function download(url: string, name: string) { - // 下载图片 - const photo = ['jpg', 'jpeg', 'png'] - const fileType = url.split('.')[url.split('.').length - 1] - console.log(fileType, 'fileType') - if (photo.includes(fileType)) { - // 图片 将服务器图片地址转化成本地地址 - const image = new Image() - image.setAttribute('crossOrigin', 'anonymous') - image.src = url - image.onload = () => { - const canvas = document.createElement('canvas') - canvas.width = image.width - canvas.height = image.height - const ctx = canvas.getContext('2d'); - (ctx as CanvasRenderingContext2D).drawImage(image, 0, 0, image.width, image.height) - canvas.toBlob((blob) => { - const url = URL.createObjectURL(blob as Blob) - downloadImg(url, name) - // 用完释放URL对象 - URL.revokeObjectURL(url) +export async function download(url: string, name: string) { + return new Promise((resolve) => { + // 下载图片 + const photo = ['jpg', 'jpeg', 'png'] + const fileType = url.split('.')[url.split('.').length - 1] + console.log(fileType, 'fileType') + if (photo.includes(fileType)) { + // 图片 将服务器图片地址转化成本地地址 + const image = new Image() + image.setAttribute('crossOrigin', 'anonymous') + image.src = url + image.onload = () => { + const canvas = document.createElement('canvas') + canvas.width = image.width + canvas.height = image.height + const ctx = canvas.getContext('2d') + ;(ctx as CanvasRenderingContext2D).drawImage( + image, + 0, + 0, + image.width, + image.height, + ) + canvas.toBlob((blob) => { + const url = URL.createObjectURL(blob as Blob) + downloadImg(url, name) + // 用完释放URL对象 + URL.revokeObjectURL(url) + console.log('111111111111111111') + resolve(' ') + console.log('2222222222') + }) + } + } + else { + // 预览一般都是用的a标签,文件下载用的window.open + // 1.pdf文件路径放到window.open里面,点击是进行在线预览 + // 2.word文件和excel文件通过a标签打开时,是直接下载了 + // 将网络地址转化为 blob地址 并下载 + urlToBlob(url, name).then(() => { + resolve(' ') }) } - } - else { - // 预览一般都是用的a标签,文件下载用的window.open - // 1.pdf文件路径放到window.open里面,点击是进行在线预览 - // 2.word文件和excel文件通过a标签打开时,是直接下载了 - // 将网络地址转化为 blob地址 并下载 - urlToBlob(url, name) - } + }) } diff --git a/public/config/config.json b/public/config/config.json index 181a4b5..842e02c 100644 --- a/public/config/config.json +++ b/public/config/config.json @@ -1,9 +1,9 @@ { "title": "安全生产智慧监管系统", - "baseUrl": "http://192.168.83.42:6909/safe-server/", + "baseUrl": "http://192.168.83.65:6909/safe-server/", "deployPathDec": "****************注意:这个/alarm的alarm一定要改成部署的文件夹的名字***************************", "deployPath": "/alarm", - "mediaBaseUrl": "http://192.168.83.42:80", + "mediaBaseUrl": "http://192.168.83.65:8099", "lat-bd": "39.91459528", "lng-bd": "116.26499505", "lat": "39.90", @@ -12,7 +12,7 @@ "maxZoom": "18", "zoom": "15", "timeGap": 600000, - "systemType": "gm", + "systemType": "sm", "lineWidth": "3", "lineColor": "#1aa034", "fontSize": "18px", diff --git a/public/playerVideo6/jessibuca.js b/public/playerVideo6/jessibuca.js index 1450494..601f208 100644 --- a/public/playerVideo6/jessibuca.js +++ b/public/playerVideo6/jessibuca.js @@ -37,8 +37,8 @@ hasControl: !1, loadingText: '', background: '', - decoder: `${window.localStorage.getItem('deployPath')}/playerVideo6/decoder.js`, // 线上使用 - // decoder: `/playerVideo6/decoder.js`, // 本地使用 + // decoder: `${window.localStorage.getItem('deployPath')}/playerVideo6/decoder.js`, // 线上使用 + decoder: `/playerVideo6/decoder.js`, // 本地使用 // decoder: import.meta.env.MODE === 'development' ? `/playerVideo6/decoder.js` : `${window.localStorage.getItem('deployPath')}/playerVideo6/decoder.js`, url: '', rotate: 0, diff --git a/src/utils/download.ts b/src/utils/download.ts index 9efd4ac..88a45c5 100644 --- a/src/utils/download.ts +++ b/src/utils/download.ts @@ -97,19 +97,22 @@ * @param fileName 文件名称 */ export function urlToBlob(url: string, name: string) { - const xhr = new XMLHttpRequest() - xhr.open('get', url) - xhr.responseType = 'blob' // ""|"text"-字符串 "blob"-Blob对象 "arraybuffer"-ArrayBuffer对象 - xhr.onload = function () { - const path = URL.createObjectURL(xhr.response) - const link = document.createElement('a') - link.download = name - link.href = path - link.click() - link.remove() - window.URL.revokeObjectURL(link.href) - } - xhr.send() + return new Promise((resolve) => { + const xhr = new XMLHttpRequest() + xhr.open('get', url) + xhr.responseType = 'blob' // ""|"text"-字符串 "blob"-Blob对象 "arraybuffer"-ArrayBuffer对象 + xhr.onload = function () { + const path = URL.createObjectURL(xhr.response) + const link = document.createElement('a') + link.download = name + link.href = path + link.click() + link.remove() + window.URL.revokeObjectURL(link.href) + resolve(null) + } + xhr.send() + }) } /** @@ -117,35 +120,48 @@ * @param url 网络文件地址 * @param name 文件名 */ -export function download(url: string, name: string) { - // 下载图片 - const photo = ['jpg', 'jpeg', 'png'] - const fileType = url.split('.')[url.split('.').length - 1] - console.log(fileType, 'fileType') - if (photo.includes(fileType)) { - // 图片 将服务器图片地址转化成本地地址 - const image = new Image() - image.setAttribute('crossOrigin', 'anonymous') - image.src = url - image.onload = () => { - const canvas = document.createElement('canvas') - canvas.width = image.width - canvas.height = image.height - const ctx = canvas.getContext('2d'); - (ctx as CanvasRenderingContext2D).drawImage(image, 0, 0, image.width, image.height) - canvas.toBlob((blob) => { - const url = URL.createObjectURL(blob as Blob) - downloadImg(url, name) - // 用完释放URL对象 - URL.revokeObjectURL(url) +export async function download(url: string, name: string) { + return new Promise((resolve) => { + // 下载图片 + const photo = ['jpg', 'jpeg', 'png'] + const fileType = url.split('.')[url.split('.').length - 1] + console.log(fileType, 'fileType') + if (photo.includes(fileType)) { + // 图片 将服务器图片地址转化成本地地址 + const image = new Image() + image.setAttribute('crossOrigin', 'anonymous') + image.src = url + image.onload = () => { + const canvas = document.createElement('canvas') + canvas.width = image.width + canvas.height = image.height + const ctx = canvas.getContext('2d') + ;(ctx as CanvasRenderingContext2D).drawImage( + image, + 0, + 0, + image.width, + image.height, + ) + canvas.toBlob((blob) => { + const url = URL.createObjectURL(blob as Blob) + downloadImg(url, name) + // 用完释放URL对象 + URL.revokeObjectURL(url) + console.log('111111111111111111') + resolve(' ') + console.log('2222222222') + }) + } + } + else { + // 预览一般都是用的a标签,文件下载用的window.open + // 1.pdf文件路径放到window.open里面,点击是进行在线预览 + // 2.word文件和excel文件通过a标签打开时,是直接下载了 + // 将网络地址转化为 blob地址 并下载 + urlToBlob(url, name).then(() => { + resolve(' ') }) } - } - else { - // 预览一般都是用的a标签,文件下载用的window.open - // 1.pdf文件路径放到window.open里面,点击是进行在线预览 - // 2.word文件和excel文件通过a标签打开时,是直接下载了 - // 将网络地址转化为 blob地址 并下载 - urlToBlob(url, name) - } + }) } diff --git a/src/views/alarm/library/algorithm/editDialog.vue b/src/views/alarm/library/algorithm/editDialog.vue index bc131b7..49ffbb1 100644 --- a/src/views/alarm/library/algorithm/editDialog.vue +++ b/src/views/alarm/library/algorithm/editDialog.vue @@ -33,6 +33,7 @@ const btnLoading = ref(false) // 保存按钮加载状态 const dialogLoading = ref(false) +const loadingText = ref('拼命加载中') const dataFormRef = ref() // 表单对象 // 校验规则 const rules = reactive({ @@ -147,6 +148,7 @@ background: 'rgba(255, 255, 255, 0.8)', }) dialogLoading.value = true + loadingText.value = '文件上传中,请耐心等待...' uploadFile(fd).then((res) => { if (res.code === 200) { formData.value.path = res.data @@ -169,9 +171,17 @@ } // 下载压缩包 -const downloadZipFile = () => { +const downloadZipFile = async () => { const fileType = formData.value.path.slice(formData.value.path.lastIndexOf('.')) // 得到的是后缀名,且转换为大写 - download(`${window.localStorage.getItem('baseurl-safe')}/static/${formData.value.path}`, `${formData.value.modelName}模型文件${fileType}`) + dialogLoading.value = true + loadingText.value = '文件下载中,请耐心等待...' + const loading = ElLoading.service({ + lock: true, + background: 'rgba(255, 255, 255, 0.8)', + }) + await download(`${window.localStorage.getItem('baseurl-safe')}/static/${formData.value.path}`, `${formData.value.modelName}模型文件${fileType}`) + dialogLoading.value = false + loading.close() } // ------------------------------------------表格------------------------------------------------ // 增加行 @@ -254,107 +264,108 @@