This commit is contained in:
zh
2025-12-12 17:23:12 +08:00
13 changed files with 229 additions and 123 deletions

View File

@ -1,7 +1,7 @@
server:
host: 127.0.0.1
port: 8849
path: C:\Users\MSI\AppData\Roaming\dzsp_shijingjun_offline_Y_save
path: C:\Users\Administrator\AppData\Roaming\dzsp_shijingjun_offline_Y_save
poi:
global:
enabled: false

View File

@ -12,9 +12,10 @@ import { GetHomeDir } from './config'
import { start, getServer } from "./app";
const http = require("http");
const yaml = require("js-yaml");
let Store = require('electron-store')
Store.initRenderer();
const store = new Store()
// 移除 electron-store使用 Electron 提供的用户数据目录
// let Store = require('electron-store')
// Store.initRenderer();
// const store = new Store()
process.on('unhandledRejection', (reason) => {
@ -147,7 +148,8 @@ function createWindow(): void {
ymlBatPath = process.platform === 'win32' ? ymlBatPath.replace(/^(\w:)/, '/$1') : ymlBatPath
let ymlPath = ymlBatPath.substring(1, 200)
const ymlContent = yaml.load(fs.readFileSync(ymlPath, 'utf8'));
ymlContent.server.path = path.dirname(store.path)
ymlContent.server.path = app.getPath('userData')
// ymlContent.server.path = path.dirname(store.path)
fs.writeFileSync(ymlPath, yaml.dump(ymlContent));
ipcMain.on("getIniConfig", (event, option) => {
let ymlPath = ymlBatPath.substring(1, 200)
@ -215,6 +217,38 @@ function createWindow(): void {
event.sender.send("selectedItem", arr);
});
});
ipcMain.handle('get-user-data-path', () => {
return app.getPath('userData')
});
ipcMain.on('import-project-override', async (event, { srcZip, dst }) => {
try {
const compressing = require('compressing')
await compressing.zip.uncompress(srcZip, dst)
event.sender.send('import-project-override-res', { ok: true })
} catch (e: any) {
event.sender.send('import-project-override-res', { ok: false, error: e.message })
}
});
ipcMain.on("export-project", (event, { dst }) => {
try {
const archiver = require('archiver');
const output = fs.createWriteStream(dst);
const archive = archiver('zip', { zlib: { level: 9 } });
output.on('close', () => {
event.sender.send('export-project-res', { ok: true });
});
archive.on('error', (err) => {
event.sender.send('export-project-res', { ok: false, error: err.message });
});
archive.pipe(output);
const dbPath = path.join(app.getPath('userData'), 'app.db');
console.log('dbPath', dbPath);
archive.file(dbPath, { name: 'app.db' });
archive.finalize();
} catch (e: any) {
event.sender.send('export-project-res', { ok: false, error: e.message });
}
});
ipcMain.on("saveFile", (event, { title, filename, filters }) => {
dialog
.showSaveDialog({

View File

@ -11,54 +11,56 @@ export const addMapSource = async ({ type, id, sourceName = '未命名对象', o
if (window.earth.entityMap.get(id)) {
window.earth.entityMap.get(id).remove()
}
let options: any = await initMapData(type, opt, cd)
let selectedNodes = window.treeObj.getSelectedNodes()
let node = selectedNodes && selectedNodes[selectedNodes.length - 1]
function getParentId(nd: any) {
if (nd.sourceType === 'directory') {
return nd.id
} else {
let parentNode = window.treeObj.getNodeByParam("id", nd.parentId, null);
if (parentNode) {
return getParentId(parentNode)
}
else {
return
setTimeout(async () => {
let options: any = await initMapData(type, opt, cd)
let selectedNodes = window.treeObj.getSelectedNodes()
let node = selectedNodes && selectedNodes[selectedNodes.length - 1]
function getParentId(nd: any) {
if (nd.sourceType === 'directory') {
return nd.id
} else {
let parentNode = window.treeObj.getNodeByParam("id", nd.parentId, null);
if (parentNode) {
return getParentId(parentNode)
}
else {
return
}
}
}
}
let parentId
if (node) {
parentId = getParentId(node)
}
delete options.host
if (options.attribute && options.attribute.rtmp) {
delete options.attribute.rtmp
}
switch (type) {
case 'rendezvous':
case 'attackArrow':
case 'pincerArrow':
delete options.label.ground
delete options.label.position
break;
case 'path':
delete options.label.text
break;
}
console.log('options', options)
let params: any = {
id: id,
sourceName: sourceName,
sourceType: type,
// isShow: 1,
parentId: parentId,
// "treeIndex": 0,
params: options
}
TreeApi.addOtherSource(params)
params.params = JSON.stringify(params.params)
params.isShow = true
let parentId
if (node) {
parentId = getParentId(node)
}
delete options.host
if (options.attribute && options.attribute.rtmp) {
delete options.attribute.rtmp
}
switch (type) {
case 'rendezvous':
case 'attackArrow':
case 'pincerArrow':
delete options.label.ground
delete options.label.position
break;
case 'path':
delete options.label.text
break;
}
console.log('options', options)
let params: any = {
id: id,
sourceName: sourceName,
sourceType: type,
// isShow: 1,
parentId: parentId,
// "treeIndex": 0,
params: options
}
TreeApi.addOtherSource(params)
params.params = JSON.stringify(params.params)
params.isShow = true
cusAddNodes(window.treeObj, params.parentId, [params])
cusAddNodes(window.treeObj, params.parentId, [params])
}, 10);
}

View File

@ -156,7 +156,7 @@ const initTreeCallBack = () => {
}
}
if (layerTypes.includes(arr[i].sourceType)) {
console.log(detail, params)
// console.log(detail, params)
if (!detail && !params) {
detail = {
id: arr[i].id,
@ -168,10 +168,10 @@ const initTreeCallBack = () => {
sourceType: arr[i].sourceType,
detail: {...detail, ...params, layerIndex: layers.length + 1}
}
console.log(layer)
// console.log(layer)
layers.push(layer)
} else {
console.log({...detail, ...params})
// console.log({...detail, ...params})
let details = {...detail, ...params}
details.show = Boolean(arr[i].isShow)
initMapData(arr[i].sourceType, details)
@ -188,6 +188,7 @@ const initTreeCallBack = () => {
let speed = (distance / duration_S) * window['tsObj']._Store._multiplier
detail.speed = speed
console.log("event的detail", detail)
// detail.viewFollow = true
initMapData("guiji", detail, (TrajectoryMotionObject) => {
TrajectoryMotionObject.state = false;
TrajectoryMotionObject.oldSpeed = distance / duration_S * multiplier;
@ -359,7 +360,7 @@ const onCheck = async (event: any, treeId: any, treeNode: any) => {
sourceStatus(treeNode)
console.log("ids", ids)
return
// return
const res = await TsApi.updateTreeShow(ids)
if (res.code == 0 || res.code == 200) {
ElMessage({

View File

@ -24,7 +24,7 @@ const selectedEventId = ref(null)
const eventBus: any = inject('bus')
const props = defineProps(['eventList', 'hr', 'originHrOffset', 'scrollLeft'])
let clickEventBar = (event) => {
console.log("点击事件块", selectedEventId.value, event.id)
console.log("点击事件块", selectedEventId.value, event)
let entity = window['_entityMap'].get(event.sourceId)
entity && entity.flyTo()
selectedEventId.value = (selectedEventId.value == null || selectedEventId.value != event.id) ? event.id : null
@ -90,6 +90,7 @@ let getWidth = (durationTime) => {
// 6. 让 progressStyle 间接依赖 refreshKey通过 getWidth
let progressStyle = (task) => {
let taskLeft = task.startTime - window['tsObj']._Store._startTimestamp;
console.log("taskLeft", task, taskLeft, getWidth(taskLeft))
let width = 1
if (!['display', 'hide'].includes(task.callback))
width = getWidth(task.duration_time) * 1000

View File

@ -4,6 +4,22 @@
<div class="eventPanel">
<span class="title">{{ eventObj.name }}</span>
<div class="eventDetail">
<template v-if="eventObj.callback&&eventObj.callback=='move'">
<div>
路径显隐
<el-switch size="small" v-model="detail.line.show" @change="(val)=>handleChange(val,'lineShow')"/>
</div>
<!-- <div>
实时路径
<el-switch size="small" v-model="detail.realTimeRoute"
@change="(val)=>handleChange(val,'realTimeRoute')"/>
</div>-->
<div>
是否圆滑
<el-switch size="small" v-model="detail.line.smooth"
@change="(val)=>handleChange(val,'smooth')"/>
</div>
</template>
<template v-if="eventObj.callback&&eventObj.callback=='flicker'">
<!-- <div>
闪烁间隔
@ -16,6 +32,7 @@
</div>
</template>
</div>
<div class="optBtn">
<el-button @click="updateEvent">{{ t('ts.confirm') }}</el-button>
@ -56,13 +73,37 @@ eventBus.on('click-event-show-plane', (params) => {
}
switch (params.callback) {
case 'flicker':
case 'move':
// times.value = detail.times
// numbers.value = detail.numbers
detail.value = details
break
}
}
console.log("detail.value", detail.value)
})
const handleChange = (val, key) => {
let entity = window['_entityMap'].get(eventObj.value.id + "move" + eventObj.value.sourceId)
console.log(eventObj.value.id + "move" + eventObj.value.sourceId)
console.log(entity)
if (entity) {
entity[key] = val
}
// 如果当前属性变为true那么其他的将变为false唯一真原则
if (val) {
switch (key) {
case 'lineShow':
detail.value.realTimeRoute = false
break
case 'realTimeRoute':
detail.value.line.show = false
break
}
}
console.log(val, key)
}
const updateEvent = () => {
// console.log(detail.value)
let obj = eventObj.value
@ -88,6 +129,7 @@ const updateEvent = () => {
})
}
const cancel = () => {
eventObj.value = null
detail.value = {}
eventBus.emit('click-cancel-hide-plane',)

View File

@ -105,6 +105,8 @@ import {ElMessage, ElPopover} from 'element-plus'; // 确保导入ElPopover
import dragLeftRight from './util/dragLeftRight.js';
import {TsApi} from "../../api/ts";
const props = defineProps(['TSOBJ'])
console.log(props.TSOBJ)
const eventBus: any = inject('bus')
const instance = getCurrentInstance();
@ -121,7 +123,7 @@ const multiplierPopover: any = ref(null);
const isPopoverShow = ref(false);
let multipliers = [16, 8, 4, 2, 1, 0.5, 0.25]
let currentStamp = ref(window['tsObj']._Store._startTimestamp)
let maxLevel = ref(24)
let maxLevel = ref(36)
let minLevel = ref(1)
let hr = ref(0)
let originHrOffset = ref(0)
@ -134,6 +136,8 @@ let distanceOfTicMain = ref(5)
let originOffset = ref(0)
let originMainOffset = ref(0)
let status = ref(false)
distanceOfTicTiny.value = props.TSOBJ._Store.getScale("distanceOfTicTiny")
distanceOfTicMain.value = window['tsObj']._Store.getScale('numOfMain') * distanceOfTicTiny.value
const propsMap = {
ticTiny,
@ -161,8 +165,7 @@ window['updateProp'] = (key: string, val: any) => {
const level = ref(20)
const props = defineProps(['TSOBJ'])
console.log(props.TSOBJ)
level.value = props.TSOBJ.wheel
let handleMultiplierChange = (multiplier) => {
props.TSOBJ._Store._multiplier = multiplier
@ -204,6 +207,9 @@ let stopCallBack = (status) => {
props.TSOBJ._Store.setScale('scrollLeft', 0)
props.TSOBJ._Store.setScale('cursorLeft', 0)
Revert()
setTimeout(() => {
Revert()
}, 100)
}
}
@ -345,6 +351,7 @@ const handleDrag = (newLeft: number) => {
let tsEntitys = window['_entityMap'].get(task.sourceId);
tsEntitys.show = true
// TrajectoryMotionObject.speed = TrajectoryMotionObject.oldSpeed
console.log(window['tsObj']._Store._currentTimestamp - task.startTime)
TrajectoryMotionObject.setMovePositionByTime((window['tsObj']._Store._currentTimestamp - task.startTime) / 1000)
break;
default:

View File

@ -99,8 +99,10 @@
oninput="value=value.replace(/[^0-9.]/g, '').replace(/^\./, '').replace(/\.{2,}/g, '.').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.')"/>{{
t('ts.minute')
}} </span>
<span><el-input v-model="second" :maxlength="2"
oninput="value=value.replace(/[^0-9.]/g, '').replace(/^\./, '').replace(/\.{2,}/g, '.').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.')"/>{{
<span>
<!--:maxlength="2"-->
<el-input v-model="second"
oninput="value=value.replace(/[^0-9.]/g, '').replace(/^\./, '').replace(/\.{2,}/g, '.').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.')"/>{{
t('ts.second')
}}</span>
</div>
@ -226,7 +228,7 @@ const addEvent = () => {
console.log(zNode.value)
let startTime = form.datetime.getTime()
let obj: any = {}
console.log("obj", obj)
let duration_S = Number(hour.value * 3600) + Number(minute.value * 60) + Number(second.value)
// 数据是否合法有效
let isRight = true
@ -234,12 +236,16 @@ const addEvent = () => {
let minPositionLength = 2
switch (currentKey.value) {
case 'flicker':
obj = {
numbers: numbers.value,
times: 0
}
if (duration_S == 0) {
isRight = false
errorFields.push("持续时间")
}
if (obj.numbers == 0) {
if (Number(obj.numbers) == 0 || !Number(obj.numbers)) {
isRight = false
errorFields.push("闪烁次数")
}
@ -266,7 +272,8 @@ const addEvent = () => {
show: false,
positions: positions.value,
},
isContainModelPosition: isContainModelPosition.value
isContainModelPosition: isContainModelPosition.value,
realTimeRoute: false
}
if (!obj.line['positions'] || (obj.line['positions'] && obj.line['positions'].length < minPositionLength)) {
// ElMessage({message: "机动事件的路径不合法", type: "warning"})
@ -300,8 +307,8 @@ const addEvent = () => {
endTime: startTime + duration_S * 1000,
"detail": JSON.stringify(obj)
}
console.log("dbParams", dbParams)
console.log("duration_S", duration_S)
// console.log("dbParams", dbParams)
// console.log("duration_S", duration_S)
// return;
TsApi.addTsEvent(dbParams).then(res => {
if (res.code == 200) {

View File

@ -38,8 +38,11 @@ export class Store {
let preMainIndex = Math.ceil(option.wheel / 3)
// 小格宽度的选值【3,5,8】
let index = option.wheel % 3
this._scales.preMainIndex = preMainIndex
this._scales.preMainIndex = preMainIndex - 1
this._scales.distanceOfTicTiny = this._scales.distanceOfTicTinyRange[index]
console.log("this._scales.preMainIndex", this._scales.preMainIndex)
console.log("this._scales.preMains", this._scales.preMains)
console.log("this._scales.preMains", this._scales.preMains[this._scales.preMainIndex])
this._scales.preSecondPx = this._scales.distanceOfTicMain / this._scales.preMains[this._scales.preMainIndex]
this._multiplier = option.multiplier || 1
@ -48,9 +51,9 @@ export class Store {
this._startTimestamp = option.startTimestamp
this._currentTimestamp = option.currentTimestamp || option.startTimestamp
this._scales = {...this._scales, ...option.scales}
let num = this.getScale("distanceOfTicMain") / this.getScale("preMains")[this.getScale("preMainIndex")]
console.log(num)
this._scales.preSecondPx = num
// let num = this.getScale("distanceOfTicMain") / this.getScale("preMains")[this.getScale("preMainIndex")]
// console.log(num)
// this._scales.preSecondPx = num
// this.setScale("preSecondPx", num)
}
@ -82,6 +85,7 @@ export class Store {
// 封装对_scales属性的修改器setter在此处触发监听 tsObj._Store.setScale('ticTiny', 10);
setScale(key: ScaleKey, value: any) {
// console.log(key, value)
const oldValue = this._scales[key];
if (oldValue === value) return; // 值未变化则不触发
this._scales[key] = value;
@ -139,7 +143,7 @@ export class Store {
let m = 60 * s//一分
let h = 60 * m//一小时
let d = 24 * h//一天
return [30 * s, 1 * m, 2 * m, 5 * m, 10 * m, 1 * h, 2 * h, 5 * h/*, 10 * h, 1 * d, 2 * d, 5 * d*/].reverse()
return [30 * s, 1 * m, 2 * m, 5 * m, 10 * m, 1 * h, 2 * h, 5 * h, 10 * h, 1 * d, 2 * d, 5 * d].reverse()
}
ceil(num) {
@ -188,11 +192,11 @@ export class Store {
}
getTaskInStamp() {
return this._tasks.filter(item => this._currentTimestamp > item.startTime && this._currentTimestamp <= item.endTime)
return this._tasks.filter(item => this._currentTimestamp >= item.startTime && this._currentTimestamp <= item.endTime)
}
set currentTimestamp(val) {
console.log("currentTimestamp", val)
// console.log("currentTimestamp", val)
this._currentTimestamp = val
window['updateProp']("currentStamp", val)
}

View File

@ -31,11 +31,15 @@ export class TS extends Tools {
// console.log("renderLabel", nums)
let allTimeLabels = []
for (let i = 0; i < all; i++) {
let timeOfMain = this._Store.getScale('preMains')[this._Store.getScale('preMainIndex')]
let timeOfMain = this._Store.getScale('preMains')[this._Store.getScale('preMainIndex') - 1]
// console.log("timeOfMain", this._Store.getScale('preMains'))
// console.log("timeOfMain", timeOfMain)
// console.log("timeOfMain", this._Store.getScale('preMainIndex'))
// @ts-ignore
allTimeLabels.push(i * timeOfMain * 1000 + this._Store._startTimestamp)
}
allTimeLabels.splice(0, nums)
// console.log("##########")
this._Store.setScale('timeLabels', allTimeLabels)
}

View File

@ -521,35 +521,28 @@ const importProject = () => {
if (paths.length > 0) {
// let loadingInstance = this.$openLoading('拼命导入中...')
importWin = false
let arr = getElectronPath().replaceAll('\\', '/').split('/')
console.log(arr, 'arrarr')
arr.pop()
// let path: any = 'C:/Users/Administrator/AppData/Roaming/yjearth'
console.log(paths[0], arr.join('/'), 'pathpath')
unzip_file(paths[0], arr.join('/'))
.then((res) => {
// loadingInstance.close()
// ElMessage({
// message: '导入成功',
// type: 'success'
// })
setTimeout(() => {
const { ipcRenderer } = require('electron')
ipcRenderer.invoke('get-user-data-path').then((userDataPath) => {
ipcRenderer.send('import-project-override', { srcZip: paths[0], dst: userDataPath })
ipcRenderer.once('import-project-override-res', (ev, res) => {
if (res && res.ok) {
setTimeout(() => {
ElMessage({
message: '载入成功将在2s后自动重启',
type: 'success'
})
}, 1000)
setTimeout(() => {
$sendElectronChanel('restart')
}, 3000)
} else {
ElMessage({
message: '载入成功将在2s后自动重启',
type: 'success'
message: res?.error || '导入失败',
type: 'warning'
})
}, 1000)
setTimeout(() => {
$sendElectronChanel('restart')
}, 3000)
})
.catch((err) => {
console.log(err)
ElMessage({
message: err,
type: 'warning'
})
}
})
})
} else {
importWin = false
}
@ -657,31 +650,41 @@ function derive() {
$sendElectronChanel('saveFile', option)
$recvElectronChanel('selectedFileItem', (e, path) => {
if (path) {
// if (result.canceled) {
// this.exportWin = !this.exportWin
// return
// }
// let loadingInstance = this.$openLoading('拼命导出中...')
// exportWin = !exportWin
let arr = getElectronPath().replaceAll('\\', '/').split('/')
arr.pop()
arr[arr.length - 1] = 'yjearth/app.db'
let db_path: any = arr.join('/')
// let db_path: any = 'C:/Users/Administrator/AppData/Roaming/yjearth/app.db'
try {
zip_file([db_path], path, () => {
// loadingInstance.close()
const { ipcRenderer } = require('electron')
ipcRenderer.send('export-project', { dst: path })
ipcRenderer.once('export-project-res', (ev, res) => {
if (res && res.ok) {
ElMessage({
message: '导出完成',
type: 'success'
})
})
} catch (error) {
ElMessage({
message: error,
type: 'error'
})
}
} else {
ElMessage({
message: res?.error || '导出失败',
type: 'error'
})
}
})
// let arr = getElectronPath().replaceAll('\\', '/').split('/')
// arr.pop()
// arr[arr.length - 1] = 'yjearth/app.db'
// let db_path: any = arr.join('/')
// console.log(db_path, 'db_pathdb_path')
// try {
// zip_file([db_path], path, () => {
// // loadingInstance.close()
// ElMessage({
// message: '导出完成',
// type: 'success'
// })
// })
// } catch (error) {
// ElMessage({
// message: error,
// type: 'error'
// })
// }
}
})

View File

@ -292,7 +292,7 @@ watch(photoName, (val) => {
// treeRef.value!.filter(val)
// }
getModelList()
modelList.value = []
currModelList.value = []
})
const filterNode: any = (value, data) => {
if (!value) return true

View File

@ -230,6 +230,7 @@ var readOnly = ref(true)
const changeWater = () => {
submerge.restart()
isPausng.value = false
}
eventBus.on('submergeDialog', () => {