创建新仓库
This commit is contained in:
427
static/infoShow.html
Normal file
427
static/infoShow.html
Normal file
@ -0,0 +1,427 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="./Vue/index.css">
|
||||
<link rel="stylesheet" href="./Vue/w-e-text.css">
|
||||
<script src="./Vue/vue.js"></script>
|
||||
<script src="./Vue/index.js"></script>
|
||||
<link href="./viewerJs/dist/viewer.css" rel="stylesheet">
|
||||
<script src="./viewerJs/dist/viewer.js"></script>
|
||||
<style>
|
||||
body,
|
||||
#info,
|
||||
div {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#info {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
/* height: 100vh; background-color: rgba(255, 255, 255, 0.014); */
|
||||
/*color: red;*/
|
||||
}
|
||||
|
||||
.tabs-header {
|
||||
display: flex;
|
||||
background: #ccc;
|
||||
user-select: none;
|
||||
overflow: hidden;
|
||||
overflow-x: scroll;
|
||||
/* height: 41px; */
|
||||
}
|
||||
|
||||
.tabs-header::-webkit-scrollbar {
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
.tabs-header::-webkit-scrollbar-thumb {
|
||||
background: #f0f0f0;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.tabs-header::-webkit-scrollbar-track {
|
||||
background: #ccc;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.tabs-header>.item {
|
||||
border-radius: 6px;
|
||||
/* padding: 5px 15px; */
|
||||
padding: 5px 0 5px 0;
|
||||
margin: 5px 3px;
|
||||
min-width: 80px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.active {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
/* 合并边框 */
|
||||
width: 100%;
|
||||
/* 表格宽度 */
|
||||
}
|
||||
|
||||
td {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
<style type="text/css">
|
||||
#iframe1>[src] {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="info">
|
||||
<!-- zhgeli -->
|
||||
<div class="tabs-header">
|
||||
<template v-for="(item,index) in tabsData">
|
||||
<div :class="['item',index!=tabsData.length-1?'borderRight':'',index==activeIndex?'active':'',]"
|
||||
@click="clickItem(item,index)">
|
||||
{{ item.name }}
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<!-- 全景图片 -->
|
||||
<template v-if="activeItem.type === '全景图'">
|
||||
<div style="flex: 9" id="vrBox"></div>
|
||||
</template>
|
||||
<template v-else-if="activeItem.name === '富文本'">
|
||||
<div style="flex: 9" class="w-e-text" v-html="info.text"></div>
|
||||
</template>
|
||||
<template v-else-if="activeItem.type === '物资'">
|
||||
<div v-if="activeItem.type === '物资'" style="flex: 9" class="w-e-text">
|
||||
<table id="myTable" border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>序号</th>
|
||||
<th>名称</th>
|
||||
<th>数量</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<template v-if="isPicture">
|
||||
<div style="flex: auto;">
|
||||
<img v-if="isSvg" style="width: 100%;height: 100%" :src="activeItem.url" alt="">
|
||||
<iframe v-else style="width: 100%;height: 100%" src="./showPicture.html" frameborder="0"
|
||||
id="iframe1"></iframe>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div style="flex: auto;">
|
||||
<iframe style="width: 100%;height: 100%" :src="activeItem.url" frameborder="0" id="iframe2">
|
||||
</iframe>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script type="text/javascript">
|
||||
const fs = require('fs')
|
||||
//调用子页面方法
|
||||
function getIframe(data, str) {
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.src = "../static/vrHtml/index.html";
|
||||
iframe.style.width = "100%"
|
||||
iframe.style.height = "100%"
|
||||
iframe.setAttribute('frameborder', 0)
|
||||
iframe.onload = () => {
|
||||
iframe.contentWindow.setIframe(data, str);
|
||||
}
|
||||
document.getElementById('vrBox').appendChild(iframe);
|
||||
}
|
||||
//获取img元素并且插入属性
|
||||
function getImg(data) {
|
||||
console.log('进入方法', data);
|
||||
|
||||
let iframe1 = document.getElementById('iframe1')
|
||||
|
||||
console.log(iframe1);
|
||||
|
||||
if (!iframe1) {
|
||||
return
|
||||
}
|
||||
console.log('url', data);
|
||||
|
||||
iframe1.contentWindow.postMessage(data, '*')
|
||||
console.log('urlurlurlurlurl', data);
|
||||
// let frame = window.frames['iframeDialog']
|
||||
iframe1.onload = () => {
|
||||
iframe1.contentWindow.postMessage(data, '*')
|
||||
}
|
||||
}
|
||||
|
||||
//调用子组件关闭按钮
|
||||
function closeImg() {
|
||||
let iframe1 = document.getElementById('iframe1')
|
||||
if (!iframe1) {
|
||||
return
|
||||
}
|
||||
iframe1.contentWindow.close()
|
||||
}
|
||||
function closeVr() {
|
||||
let parentElement = document.getElementById('vrBox')
|
||||
if (!parentElement) {
|
||||
return
|
||||
}
|
||||
removeAllChildren(parentElement);
|
||||
}
|
||||
function removeAllChildren(parentNode) {
|
||||
while (parentNode.firstChild) {
|
||||
parentNode.removeChild(parentNode.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
const ipcRenderer = require('electron').ipcRenderer
|
||||
new Vue({
|
||||
el: '#info',
|
||||
data: function () {
|
||||
return {
|
||||
showRichText: '',
|
||||
activeIndex: 0,
|
||||
activeItem: {},
|
||||
tabsData: [],
|
||||
info: {
|
||||
type: "",
|
||||
text: "",
|
||||
hrefs: "",
|
||||
vrPath: '',
|
||||
},
|
||||
isPicture: false,
|
||||
tbody: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
||||
},
|
||||
watch: {
|
||||
activeItem: {
|
||||
handler: function (val, oldVal) {
|
||||
this.appendData(val)
|
||||
console.log('document.getElementByIdmyObject', document.getElementById('myObject'));
|
||||
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 填入数据
|
||||
appendData(item) {
|
||||
if (item.name === '物资') {
|
||||
this.$nextTick(() => {
|
||||
const table = document.querySelector('#myTable');
|
||||
if (table) {
|
||||
table.appendChild(this.tbody)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
clickItem(item, i) {
|
||||
if (this.tabsData.length < 1) {
|
||||
console.log('只有一个选项,不允许切换');
|
||||
return;
|
||||
}
|
||||
let setName = () => {
|
||||
this.showRichText = item.name
|
||||
this.activeIndex = i
|
||||
this.activeItem = item
|
||||
closeImg()
|
||||
console.log('this.activeItem', this.activeItem);
|
||||
this.renderImgView()
|
||||
this.$nextTick(() => {
|
||||
if (this.activeItem.name.indexOf('ISC-') > -1) {
|
||||
if (!this.player) {
|
||||
this.player = new window.JSPlugin({
|
||||
szId: 'player',
|
||||
szBasePath: "./sdk",
|
||||
iMaxSplit: 1,
|
||||
iCurrentSplit: 1,
|
||||
openDebug: true,
|
||||
oStyle: {
|
||||
borderSelect: IS_MOVE_DEVICE ? '#000' : '#FFCC00',
|
||||
}
|
||||
})
|
||||
}
|
||||
//播放某一特定监控
|
||||
let playURL = this.activeItem.previewUrl, index = this.player.currentWindowIndex, mode = 0//:0=普通模式; 1=高级模式
|
||||
|
||||
this.player.JS_Play(playURL, { playURL, mode }, index).then(
|
||||
() => { console.log('realplay success') },
|
||||
e => { console.error(e) }
|
||||
)
|
||||
|
||||
console.log("this.player", this.player);
|
||||
|
||||
}
|
||||
})
|
||||
closeVr()
|
||||
// setIframe2()
|
||||
}
|
||||
if (['富文本', '全景图', '链接'].includes(this.activeItem.type)) {
|
||||
setName()
|
||||
this.$nextTick(() => {
|
||||
getImg(this.activeItem.url)
|
||||
})
|
||||
return
|
||||
}
|
||||
setName()
|
||||
},
|
||||
renderImgView() {
|
||||
console.log(this.activeItem.url);
|
||||
let name
|
||||
if (this.activeItem.url) {
|
||||
name = this.activeItem.url.slice(this.activeItem.url.length - 3, this.activeItem.url.length)
|
||||
}
|
||||
console.log('node.detail.namenode.detail.namenode.detail.name', name);
|
||||
this.isPicture = ['jpg', 'png', 'JPG', 'PNG', 'JPEG', 'jpeg', 'gif', 'webp', 'GIF', 'bmp'].includes(name)
|
||||
console.log('this.isPicture', this.isPicture);
|
||||
this.isSvg = (name === 'svg');
|
||||
setTimeout(() => {
|
||||
//我希望图片和全景都有时,他们各自渲染各自的
|
||||
if (this.activeItem.type === '全景图') {
|
||||
getIframe(this.activeItem.url, '')
|
||||
} else {
|
||||
getImg(this.activeItem.url)
|
||||
}
|
||||
// if (!Boolean(this.info.panorama.length)) {
|
||||
// console.log('图片渲染', 1232132);
|
||||
// getImg(this.activeItem.url)
|
||||
// } else {
|
||||
// getIframe(this.activeItem.url, '')
|
||||
// }
|
||||
}, 0)
|
||||
},
|
||||
|
||||
},
|
||||
mounted() {
|
||||
window.ssssssssssssss = this.tabsData
|
||||
let fs = require('fs')
|
||||
console.log('fsfsfsfsfsfsfsfsfsfsfsfsfsfsfsfsfsfsfs', fs);
|
||||
ipcRenderer.on('data', (event, obj) => {
|
||||
this.info = obj.info
|
||||
console.log('ddddddddddddddddddddddddddd', this.info);
|
||||
document.title = obj.source_name
|
||||
let arr = this.info.hrefs
|
||||
arr.forEach(item => {
|
||||
console.log(fs.existsSync(item.url));
|
||||
if (fs.existsSync(item.url)) {
|
||||
if (!item.url.startsWith('http')) {
|
||||
// if (item.url.indexOf(":/") > -1) {
|
||||
// ipcRenderer.send('setStaticFile', item.url)
|
||||
// let name = item.url.replaceAll("\\", "/").split("/").pop()
|
||||
// item.url = location.origin + "/" + name
|
||||
// item.url = this.info.env + "/yjearth4.0/api/v1/picture/getBypath?path=" + item.url
|
||||
item.url = this.info.env + "/yjearth4.0/api/v1/picture/getBypath?path=" + encodeURIComponent(item.url)
|
||||
// item.url
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
if (!item.url.startsWith('http')) {
|
||||
// item.url = this.info.env + "/" + item.url
|
||||
item.url = this.info.env + "/" + encodeURIComponent(item.url)
|
||||
}
|
||||
}
|
||||
})
|
||||
this.tabsData = arr
|
||||
console.log('this.tabsData', this.tabsData);
|
||||
let hasRichText = Boolean(this.info.text)
|
||||
let hasVrPath = Boolean(this.info.vrPath)
|
||||
let hasVr = Boolean(this.info.vr.length)
|
||||
let hasGoods = Boolean(this.info.goods.length)
|
||||
let hasISC = this.info.ISC && Boolean(this.info.ISC.length > 0)
|
||||
|
||||
if (hasRichText) {
|
||||
this.tabsData.unshift({ name: "富文本", type: '富文本', href: this.info.text })
|
||||
this.activeItem = this.tabsData[this.activeIndex]
|
||||
}
|
||||
// 当hasRichText为false,将第一个选项设置为链接
|
||||
if (!hasRichText && !hasVrPath && !hasVr && !hasGoods && !hasISC) {
|
||||
this.activeItem = this.tabsData[this.activeIndex]
|
||||
this.activeItem.type = '链接'
|
||||
this.clickItem(this.activeItem, this.activeIndex)
|
||||
}
|
||||
if (this.info.type == "link" && this.tabsData.length > 0) {
|
||||
this.activeIndex = hasRichText ? 0 : 0
|
||||
this.activeItem = this.tabsData[this.activeIndex]
|
||||
this.showRichText = ''
|
||||
this.activeItem.type = '链接'
|
||||
this.clickItem(this.activeItem, this.activeIndex)
|
||||
}
|
||||
let jsonPath = obj.info.source_path.replace('.jpg', '.json')
|
||||
console.log(hasRichText, hasVrPath, fs.existsSync(jsonPath), this.tabsData);
|
||||
let str = ""
|
||||
// fetch(jsonPath)
|
||||
if (fs.existsSync(jsonPath)) {
|
||||
str = String(fs.readFileSync(jsonPath))
|
||||
} /*else {
|
||||
return
|
||||
}*/
|
||||
if (hasVrPath) {
|
||||
this.tabsData.unshift({ name: "全景图", type: '全景图', href: this.info.vrPath })
|
||||
this.$nextTick(() => {
|
||||
getIframe(this.info.vrPath, str)
|
||||
})
|
||||
this.activeItem = this.tabsData[this.activeIndex]
|
||||
}
|
||||
if (hasISC) {
|
||||
this.info.ISC.forEach(item => {
|
||||
this.tabsData.push({ name: "ISC-" + item.name, cameraIndexCode: item.cameraIndexCode, status: item.status })
|
||||
})
|
||||
this.activeItem = this.tabsData[this.activeIndex]
|
||||
}
|
||||
if (hasGoods) {
|
||||
this.tabsData.unshift({ name: "物资", type: '物资' })
|
||||
// tbody.appendChild(row);
|
||||
this.tbody = document.createElement('tbody')
|
||||
|
||||
this.info.goods.reverse().forEach((item, index) => {
|
||||
const row = document.createElement('tr');
|
||||
row.innerHTML = `
|
||||
<td>${index + 1}</td>
|
||||
<td>${item.name}</td>
|
||||
<td>${item.cnt}</td>
|
||||
`;
|
||||
this.tbody.appendChild(row);
|
||||
});
|
||||
this.activeItem = this.tabsData[this.activeIndex]
|
||||
}
|
||||
if (hasVr) {
|
||||
this.info.vr.forEach(item => {
|
||||
console.log(item);
|
||||
if (!item.url.startsWith('http')) {
|
||||
item.url = this.info.env + '/yjearth4.0/api/v1/picture/getBypath?path=' + encodeURIComponent(item.url)
|
||||
}
|
||||
this.tabsData.unshift({ name: item.name, type: '全景图', url: item.url })
|
||||
})
|
||||
this.activeItem = this.tabsData[this.activeIndex]
|
||||
this.renderImgView()
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
|
||||
</html>
|
Reference in New Issue
Block a user