This commit is contained in:
zh
2025-10-11 16:29:34 +08:00
parent 98a9c02583
commit 52b753885d
16 changed files with 51 additions and 30 deletions

View File

@ -43,10 +43,10 @@ export default defineConfig({
})
]
// server: {
// port: 8808,
// port: 8848,
// proxy: {
// '/api': {
// target: localStorage.getItem('ip') || 'http://127.0.0.1:8808',
// target: localStorage.getItem('ip') || 'http://127.0.0.1:8848',
// changeOrigin: true,
// rewrite: (path) => path.replace(/^\/api/, '')
// }

View File

@ -10,12 +10,12 @@ import type {
const pendingRequests = new Map<string, AbortController>()
let baseURL: any
if (window && window.process && window.process.type === 'renderer') {
// baseURL = localStorage.getItem('ip') ||'http://192.168.110.25:8848'|| 'http://127.0.0.1:8808'
baseURL = 'http://127.0.0.1:8848'
baseURL = localStorage.getItem('ip') || 'http://127.0.0.1:8848'
// baseURL = 'http://127.0.0.1:8848'
} else {
baseURL = 'http://192.168.110.25:8848'
}
localStorage.setItem('service', baseURL)
// localStorage.setItem('service', baseURL)
// 创建自定义配置的axios实例
const service: AxiosInstance = axios.create({

View File

@ -3,7 +3,7 @@ import { renderVector } from '../views/components/tree/components/hooks/renderVe
export const initMapData = async (type, data, cd) => {
let entityObject
let options
let baseURL = localStorage.getItem('service')
let baseURL = localStorage.getItem('ip')
switch (type) {
case 'groundText':
entityObject = new YJ.Obj.GroundText(window.earth, data)

View File

@ -6,7 +6,6 @@ interface Window {
sendMessage: (msg: string) => void
onReply: (callback: (msg: string) => void) => void
}
isStandAlone: any
treeObj: any
AllNodes: any
}

View File

@ -151,7 +151,7 @@ const fs = require('fs')
const eventBus: any = inject('bus')
var clickTreeNode: any = reactive({})
var leftClickTreeNode: any = reactive({})
const service = ref(localStorage.getItem('service'))
const service = ref(localStorage.getItem('ip'))
interface TypeNode {
id: string

View File

@ -159,7 +159,7 @@ const fs = require('fs')
const eventBus: any = inject('bus')
var clickTreeNode: any = reactive({})
var leftClickTreeNode: any = reactive({})
const service = ref(localStorage.getItem('service'))
const service = ref(localStorage.getItem('ip'))
interface TypeNode {
id: string

View File

@ -193,7 +193,7 @@ const fs = require('fs')
const eventBus: any = inject('bus')
const imageRef: any = ref('')
var clickTreeNode: any = reactive({})
const service = ref(localStorage.getItem('service'))
const service = ref(localStorage.getItem('ip'))
interface TypeNode {
id: string

View File

@ -121,7 +121,7 @@ const isShowPup = ref(false)
const eventBus: any = inject('bus')
const { cusUpdateNode } = useTreeNode()
var modelName = ref('')
const service = ref(localStorage.getItem('service'))
const service = ref(localStorage.getItem('ip'))
//tab
interface Model {

View File

@ -45,7 +45,7 @@ const eventBus: any = inject('bus')
const viewPointHeight: any = ref(1.8)
var rowData: any = reactive([])
var imageData: any = ref(null)
const service = ref(localStorage.getItem('service'))
const service = ref(localStorage.getItem('ip'))
// var newData: any = reactive({
// name: ''
// })

View File

@ -122,7 +122,7 @@ const eventBus: any = inject('bus')
var modelName = ref('')
var clickTreeNode: any = ref('')
const service = ref(localStorage.getItem('service'))
const service = ref(localStorage.getItem('ip'))
//tab
interface Model {

View File

@ -173,7 +173,7 @@ const { cusUpdateNode } = useTreeNode()
var modelName = ref('')
const availablePort = ref(55110)
const service = ref(localStorage.getItem('service'))
const service = ref(localStorage.getItem('ip'))
ipcRenderer.invoke('get-available-port').then((port) => {
availablePort.value = port

View File

@ -168,7 +168,7 @@ const init = (obj, selected, hasGEMarker = true, isUrl) => {
activeName.value = arr[0];
}
hasGEMarker1.value = hasGEMarker;
url.value = localStorage.getItem('service')
url.value = localStorage.getItem('ip')
for (const objKey in obj) {
let imgList: any = [];

View File

@ -104,7 +104,7 @@ export const useRightOperate = () => {
renderVector(params, true)
}
else if (["geojson"].includes(sourceType)) {
let baseURL = localStorage.getItem('service')
let baseURL = localStorage.getItem('ip')
await addMapSource({
type: 'geojson',
id: id,

View File

@ -178,7 +178,7 @@ async function tankuang(id, node, info) {
let availablePort = await ipcRenderer.invoke('get-available-port');
window.treeObj.selectNode(node);
console.log('BrowserWindow---------------------', electron.BrowserWindow)
let baseURL = localStorage.getItem('service')
let baseURL = localStorage.getItem('ip')
// console.log("node.detail.namenode.detail.namenode.detail.name", node.detail);
let _winMap = await ipcRenderer.invoke('get-_winMap')
if (!_winMap.has(id)) {

View File

@ -436,7 +436,7 @@ const getStatus = (time) => {
}
onMounted(async () => {
let baseURL = localStorage.getItem('service')
let baseURL = localStorage.getItem('ip')
getAuthInfo()
await YJ.on({ host: baseURL })
createEarth()

View File

@ -1,6 +1,6 @@
import { validateURL } from '@/utils/validate'
import { ElMessage } from 'element-plus'
import { setIP } from '@/utils/index'
import { setIP,getIP } from '@/utils/index'
export const useSetUp = () => {
const serviceDialog = ref(false) // 服务设置对话框
const servVal = ref('单机') // 服务类型选择值
@ -8,13 +8,32 @@ export const useSetUp = () => {
const ip = ref('192.168.1.1')
const port = ref('8890')
const localip = ref('127.0.0.1')
const localport = ref('8808')
const localport = ref('8848')
const gpsVal = ref('') // 服务类型选择值
const gpsOptions: any = ref([])
const servOptions: any = ref([{ name: '单机' }, { name: '网络' }])
const selectedService = ref('接口服务')
const serviceOptions: any = ref([{ name: '接口服务' }, { name: '北斗串口' }])
let serveUrl:any = getIP()
let isOk = validateURL(serveUrl)
let serverMode = localStorage.getItem('serverMode')
if(isOk) {
const parsedUrl = new URL(serveUrl);
const host = parsedUrl.host;
const ipPort = host.split(':');
if(serverMode === 'false') {
servVal.value = '网络'
ip.value = ipPort[0]
port.value = ipPort[1]
prototype.value = parsedUrl.protocol.slice(0, -1)
}
else {
localip.value = ipPort[0]
localport.value = ipPort[1]
}
}
const submit = () => {
switch (selectedService.value) {
case '接口服务':
@ -39,7 +58,7 @@ export const useSetUp = () => {
// 验证url 合法性
if (isOk) {
// 网络走这里
window.isStandAlone = false //判断走哪个服务
localStorage.setItem('serverMode', 'false') //判断走哪个服务
setIP(url)
serviceDialog.value = false
} else {
@ -47,21 +66,24 @@ export const useSetUp = () => {
}
} else {
//单机走这里
window.isStandAlone = true
localStorage.setItem('serverMode', 'true')
setIP('http://127.0.0.1:' + localport.value)
serviceDialog.value = false
}
}
const initialize = () => {
if (!window.isStandAlone) {
setIP('http://127.0.0.1:' + localport.value)
} else {
let url = prototype.value + '://' + ip.value + ':' + port.value
let isOk = validateURL(url)
if (isOk) {
setIP(url)
if(localStorage.getItem('ip')) {}
else {
if (serverMode==='false') {
setIP('http://127.0.0.1:' + localport.value)
} else {
ElMessage.error('url不合法')
let url = prototype.value + '://' + ip.value + ':' + port.value
let isOk = validateURL(url)
if (isOk) {
setIP(url)
} else {
ElMessage.error('url不合法')
}
}
}
}