阶段性代码提交
This commit is contained in:
parent
e33556ba27
commit
5289fff280
27
src/App.vue
27
src/App.vue
|
|
@ -1,5 +1,30 @@
|
|||
<script setup>
|
||||
import { RouterLink, RouterView } from 'vue-router'
|
||||
// import { RouterLink, RouterView, useRoute } from 'vue-router'
|
||||
// const { VITE_APP_AUTHORITY, VITE_APP_CLIENT_ID } = import.meta.env
|
||||
|
||||
// const router = useRoute()
|
||||
|
||||
// let t = setInterval(() => {
|
||||
// if (router.query.access_token) {
|
||||
// clearInterval(t)
|
||||
// setUserInfo()
|
||||
// }
|
||||
// }, 50)
|
||||
|
||||
// const setUserInfo = () => {
|
||||
// let oidcSession = {
|
||||
// access_token: router.query.access_token,
|
||||
// token_type: router.query.token_type,
|
||||
// }
|
||||
|
||||
// oidcSession = JSON.stringify(oidcSession)
|
||||
// window.iframe_AirPortID = router.query.airporId
|
||||
// sessionStorage.setItem(`oidc.user:${VITE_APP_AUTHORITY}:${VITE_APP_CLIENT_ID}`, oidcSession)
|
||||
// const access_token = `Bearer ${oidcSession.access_token}`
|
||||
// //设置token
|
||||
// localStorage.setItem('access_token', access_token)
|
||||
// sessionStorage.setItem('access_token', access_token)
|
||||
// }
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
|||
63
src/main.js
63
src/main.js
|
|
@ -19,6 +19,8 @@ import 'vxe-table/lib/style.css'
|
|||
import { useSettingStore } from '@/stores/setting.js'
|
||||
import { qiankunWindow, renderWithQiankun } from 'vite-plugin-qiankun/dist/helper'
|
||||
|
||||
import { RouterLink, RouterView, useRoute } from 'vue-router'
|
||||
|
||||
// 创建实例
|
||||
let app
|
||||
const setupAll = async (props) => {
|
||||
|
|
@ -34,33 +36,50 @@ const setupAll = async (props) => {
|
|||
|
||||
//qiankun微前端
|
||||
if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
|
||||
//测试时候用的代码
|
||||
const { VITE_APP_AUTHORITY, VITE_APP_CLIENT_ID } = import.meta.env
|
||||
console.log('.......................', import.meta.env)
|
||||
const queryParams = new URLSearchParams(window.location.search)
|
||||
const access_token = queryParams.get('access_token')
|
||||
const token_type = queryParams.get('token_type')
|
||||
const airporId = queryParams.get('airporId')
|
||||
|
||||
let oidcSession = {
|
||||
access_token: access_token,
|
||||
token_type: token_type,
|
||||
}
|
||||
|
||||
oidcSession = JSON.stringify(oidcSession)
|
||||
window.iframe_AirPortID = airporId
|
||||
sessionStorage.setItem(`oidc.user:${VITE_APP_AUTHORITY}:${VITE_APP_CLIENT_ID}`, oidcSession)
|
||||
let access_token_str = `Bearer ${access_token}`
|
||||
//设置token
|
||||
localStorage.setItem('access_token', access_token_str)
|
||||
sessionStorage.setItem('access_token', access_token_str)
|
||||
|
||||
setupAll({ container: '#airapp' })
|
||||
|
||||
//监听消息事件
|
||||
window.addEventListener(
|
||||
'message',
|
||||
(event) => {
|
||||
if (event.data) {
|
||||
let mdata = JSON.parse(event.data)
|
||||
// console.log(mdata)
|
||||
window.iframe_AirPortID = mdata.airportId
|
||||
let oidcSession = JSON.stringify(mdata.userInfo)
|
||||
// window.addEventListener(
|
||||
// 'message',
|
||||
// (event) => {
|
||||
// if (event.data) {
|
||||
// let mdata = JSON.parse(event.data)
|
||||
// // console.log(mdata)
|
||||
// window.iframe_AirPortID = mdata.airportId
|
||||
// let oidcSession = JSON.stringify(mdata.userInfo)
|
||||
|
||||
sessionStorage.setItem(`oidc.user:${VITE_APP_AUTHORITY}:${VITE_APP_CLIENT_ID}`, oidcSession)
|
||||
// let userInfo = JSON.parse(oidcSession)
|
||||
const access_token = `Bearer ${mdata.userInfo.access_token}`
|
||||
//设置token
|
||||
localStorage.setItem('access_token', access_token)
|
||||
sessionStorage.setItem('access_token', access_token)
|
||||
// sessionStorage.setItem(`oidc.user:${VITE_APP_AUTHORITY}:${VITE_APP_CLIENT_ID}`, oidcSession)
|
||||
// // let userInfo = JSON.parse(oidcSession)
|
||||
// const access_token = `Bearer ${mdata.userInfo.access_token}`
|
||||
// //设置token
|
||||
// localStorage.setItem('access_token', access_token)
|
||||
// sessionStorage.setItem('access_token', access_token)
|
||||
|
||||
//测试时候用的代码
|
||||
setupAll({ container: '#airapp' })
|
||||
}
|
||||
},
|
||||
false,
|
||||
)
|
||||
// //测试时候用的代码
|
||||
// setupAll({ container: '#airapp' })
|
||||
// }
|
||||
// },
|
||||
// false,
|
||||
// )
|
||||
} else {
|
||||
renderWithQiankun({
|
||||
mount(props) {
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import router from '@/router'
|
|||
import { useSettingStore } from '@/stores/setting.js'
|
||||
|
||||
// request是一个axios实例,每一个实例你都可以单独定制它的baseURL,超时时间,请求头和一些其他配置项。
|
||||
//const baseUrl = import.meta.env.VITE_APP_API_BASE_URL + '/airport/admin' //接口统一域名
|
||||
const baseUrl = '/airport/admin' //接口统一域名
|
||||
const baseUrl = import.meta.env.VITE_APP_API_BASE_URL + '/airport/admin' //接口统一域名
|
||||
// const baseUrl = '/airport/admin' //接口统一域名
|
||||
// const baseUrl = '/airport/admin'
|
||||
|
||||
// 设置统一的url
|
||||
|
|
|
|||
|
|
@ -179,25 +179,21 @@ const setCurrentData = (data) => {
|
|||
//飞机高度
|
||||
// planeAlt = data.alt ? data.alt : 0
|
||||
//爬升速度
|
||||
planeStateList.vspeed.value = Number(data.vspeed) ? Number(data.vspeed).toFixed(1) : '-'
|
||||
planeStateList.vspeed.value = Number(data.vspeed) ? parseInt(data.vspeed, 10) : '0'
|
||||
//平飞速度
|
||||
planeStateList.hspeed.value = Number(data.hspeed) ? Number(data.hspeed).toFixed(1) : '-'
|
||||
planeStateList.hspeed.value = Number(data.hspeed) ? parseInt(data.hspeed, 10) : '0'
|
||||
//距离机场
|
||||
planeStateList.distToHome.value = Number(data.distToHome)
|
||||
? Number(data.distToHome).toFixed(1)
|
||||
: '-'
|
||||
planeStateList.distToHome.value = Number(data.distToHome) ? parseInt(data.distToHome, 10) : '0'
|
||||
//海拔高度
|
||||
planeStateList.altitude.value = Number(data.altitude) ? Number(data.altitude).toFixed(1) : '-'
|
||||
planeStateList.altitude.value = Number(data.altitude) ? parseInt(data.altitude, 10) : '0'
|
||||
//无人机俯仰角
|
||||
planeStateList.pitch.value = Number(data.pitch) ? Number(data.pitch).toFixed(1) : '-'
|
||||
planeStateList.pitch.value = Number(data.pitch) ? parseInt(data.pitch, 10) : '0'
|
||||
//无人机偏航角
|
||||
planeStateList.yaw.value = Number(data.yaw) ? Number(data.yaw).toFixed(1) : '-'
|
||||
planeStateList.yaw.value = Number(data.yaw) ? parseInt(data.yaw, 10) : '0'
|
||||
//云台俯仰角
|
||||
planeStateList.camerapitch.value = Number(data.camerapitch)
|
||||
? Number(data.camerapitch).toFixed(1)
|
||||
: '-'
|
||||
planeStateList.camerapitch.value = Number(data.camerapitch) ? parseInt(data.camerapitch, 10) : '0'
|
||||
//云台偏航角
|
||||
planeStateList.camerayaw.value = Number(data.camerayaw) ? Number(data.camerayaw).toFixed(1) : '-'
|
||||
planeStateList.camerayaw.value = Number(data.camerayaw) ? parseInt(data.camerayaw, 10) : '0'
|
||||
}
|
||||
|
||||
//切换视频位置
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ let statelliteCount = ref(0)
|
|||
let taskStatus = ref('continue')
|
||||
//是否显示继续按钮(针对急停操作)
|
||||
let command5 = ref(false)
|
||||
//机场名称
|
||||
let airPortName = ref('')
|
||||
|
||||
//timeout
|
||||
let weatherTimeOut = null
|
||||
|
|
@ -109,6 +111,8 @@ const queryAirLine_AirPort = async () => {
|
|||
currentAirPortInfo.value = res[0].value.data[0]
|
||||
airPortSocketStore.ceurrentAirPortData = currentAirPortInfo.value
|
||||
|
||||
airPortName.value = currentAirPortInfo.value.name
|
||||
|
||||
//机场当前状态
|
||||
if (currentAirPortStatus.value != Number(currentAirPortInfo.value.status)) {
|
||||
currentAirPortStatus.value = Number(currentAirPortInfo.value.status)
|
||||
|
|
@ -141,7 +145,7 @@ const queryAirLine_AirPort = async () => {
|
|||
|
||||
//地图数据
|
||||
iframeData = {
|
||||
airportName: currentAirPortInfo.value.airportName,
|
||||
airportName: currentAirPortInfo.value.name,
|
||||
airportLocation: {
|
||||
lon: currentAirPortInfo.value.longitude,
|
||||
lat: currentAirPortInfo.value.latitude,
|
||||
|
|
@ -168,7 +172,7 @@ const queryAirPort = async () => {
|
|||
airPortSocketStore.ceurrentAirPortData = currentAirPortInfo.value
|
||||
// console.log(currentAirPortInfo.value)
|
||||
|
||||
// currentAirPortInfo.value.status = 2
|
||||
currentAirPortInfo.value.status = 2
|
||||
|
||||
//机场当前状态
|
||||
if (currentAirPortStatus.value != Number(currentAirPortInfo.value.status)) {
|
||||
|
|
@ -204,8 +208,7 @@ const queryAirPort = async () => {
|
|||
//socket线程
|
||||
const socketFn = (workParams) => {
|
||||
//创建线程,一定要使用type:module的方式引入,否则worker不允许import外部js
|
||||
let url = 'https://virtualplane-test.t-aaron.com'
|
||||
const worker = new Worker(new URL('@/workers/worker.js', url), { type: 'module' })
|
||||
const worker = new Worker(new URL('@/workers/worker.js', import.meta.url), { type: 'module' })
|
||||
worker.postMessage(JSON.stringify(workParams))
|
||||
worker.onmessage = function (event) {
|
||||
//来自线程Worker的消息
|
||||
|
|
@ -231,9 +234,19 @@ const socketFn = (workParams) => {
|
|||
const iframeLoaded = (iframeContent) => {
|
||||
setTimeout(() => {
|
||||
map_iframeContent = iframeContent
|
||||
let data = JSON.stringify(iframeData)
|
||||
console.log(iframeContent)
|
||||
iframeContent.postMessage(data, '*')
|
||||
console.log('iframeData:')
|
||||
console.log(iframeData)
|
||||
|
||||
//必须等待数值
|
||||
let tempTime = null
|
||||
tempTime = setInterval(() => {
|
||||
if (iframeData) {
|
||||
clearInterval(tempTime)
|
||||
let data = JSON.stringify(iframeData)
|
||||
console.log(iframeContent)
|
||||
iframeContent.postMessage(data, '*')
|
||||
}
|
||||
}, 50)
|
||||
}, 0)
|
||||
}
|
||||
//无人机实时飞机发送消息
|
||||
|
|
@ -404,7 +417,7 @@ onMounted(() => {
|
|||
class="rem-header w-full px-3.5 flex flex-row items-center justify-between lg:h-[36px] xk:h-[36px] x1k:h-[50px] x2k:h-[66px]"
|
||||
>
|
||||
<div>
|
||||
<span class="text-sm text-[#B4D5FF]">江苏软件园银杏湖机场</span>
|
||||
<span class="text-sm text-[#B4D5FF]">{{ airPortName }}</span>
|
||||
<span class="ml-2.5 text-xs px-4 py-1 bg-[#016CF8] text-white rounded-sm">{{
|
||||
statusList[currentAirPortStatus]
|
||||
}}</span>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ addEventListener('message', (e) => {
|
|||
if (!WebSocket) message.error('你的浏览器不支持WebSocket')
|
||||
// const baseUrl = import.meta.env.VITE_APP_API_BASE_URL.match(/^http(s)?:\/\/([^\/]*).*/)[2]\
|
||||
const baseUrl = 'virtualplane-test.t-aaron.com'
|
||||
// console.log('来了这里吗')
|
||||
|
||||
// if (process.env.NODE_ENV !== 'development') {
|
||||
// data.wsAirport = WebSocketService.createConnection(`wss://${baseUrl}/airport/socket/webSocket/${url}`)
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ export default ({ command, mode }) => {
|
|||
host: '0.0.0.0',
|
||||
port: 8080,
|
||||
cors: true,
|
||||
//http: true,
|
||||
http: true,
|
||||
open: false, //不自动开启
|
||||
proxy: {
|
||||
'/airport': {
|
||||
|
|
|
|||
Loading…
Reference in New Issue