This commit is contained in:
duanhao 2025-07-31 13:43:08 +08:00
commit 960130fba1

View File

@ -56,7 +56,7 @@
<script setup>
import { defineEmits, onMounted, ref, onUnmounted, computed, watch, nextTick } from "vue"
import { TansTimestamp, getAvatarUrl } from "@/utils/transform"
import { TansTimestamp } from "@/utils/transform"
import nodeHoverImg from "@/assets/images/nodeHover.png"
import * as echarts from "echarts"
import { storeToRefs } from "pinia"
@ -96,7 +96,48 @@ watch(
const startTime = ref(new Date("2024-05-16 16:56:04"))
const endTime = ref(new Date("2024-05-23 10:16:56"))
const currentTime = ref(new Date("2024-05-16 16:56:04")) //
const currentPosition = ref(0) //
const currentPosition = ref(0) //
const isPlaying = ref(false) //
let playTimer = null
//
const play = () => {
if (isPlaying.value) return
isPlaying.value = true
playTimer = setInterval(() => {
//
const step = 4 // 4px
if (currentPosition.value >= axisWidth) {
pause()
return
}
currentPosition.value = Math.min(axisWidth, currentPosition.value + step)
currentTime.value = getTimeFromPosition(currentPosition.value)
sendTimeChangeRequest()
}, 300) // 300ms
}
const pause = () => {
isPlaying.value = false
if (playTimer) {
clearInterval(playTimer)
playTimer = null
}
}
//
const sendTimeChangeRequest = () => {
const currentTimes = TansTimestamp(currentTime.value, "YYYY-MM-DD HH:mm:ss")
if (interactionStore.curRelationId == "") {
interactionStore.initGraphCommunityDetailNode(interactionStore.curSelecedGroupIds, currentTimes)
} else {
interactionStore.initGraphCommunityDetailNode(
interactionStore.curSelecedGroupIds,
currentTimes,
interactionStore.curRelationId
)
}
}
const axisRef = ref(null)
const isDragging = ref(false)
@ -135,24 +176,12 @@ const getTimeFromPosition = (position) => {
//
const handlePointerDown = (e) => {
if (e.target.classList.contains("timeLine-point")) return
pause() //
const rect = axisRef.value.getBoundingClientRect()
const position = Math.max(0, Math.min(axisWidth, e.clientX - rect.left))
// 使
currentPosition.value = position
currentTime.value = getTimeFromPosition(position)
//
const currentTimes = TansTimestamp(currentTime.value, "YYYY-MM-DD HH:mm:ss")
if (interactionStore.curRelationId == "") {
interactionStore.initGraphCommunityDetailNode(interactionStore.curSelecedGroupIds, currentTimes)
} else {
interactionStore.initGraphCommunityDetailNode(
interactionStore.curSelecedGroupIds,
currentTimes,
interactionStore.curRelationId
)
}
sendTimeChangeRequest()
}
//
@ -210,6 +239,7 @@ const trackStyle = computed(() => {
onUnmounted(() => {
document.removeEventListener("pointermove", () => {})
document.removeEventListener("pointerup", () => {})
pause()
})
let chart = null
@ -371,7 +401,7 @@ const initChart = async () => {
animation: false,
draggable: true,
roam: true,
zoom: 0.15,
zoom: 0.1,
categories: categories,
force: {
edgeLength: 2500,
@ -443,6 +473,7 @@ const highLightUserNodes = (userIds) => {
onMounted(() => {
initChart()
highLightUserNodes()
play()
})
</script>