feat: 联调对话功能
This commit is contained in:
+13
-25
@@ -1,11 +1,5 @@
|
||||
<template>
|
||||
<CasesPage
|
||||
v-if="showCasesPage"
|
||||
@open-settings="emit('open-settings')"
|
||||
@open-profile="openProfile"
|
||||
@go-home="emit('go-home')"
|
||||
/>
|
||||
<view v-else class="matching-page">
|
||||
<view class="matching-page">
|
||||
<view class="matching-shell">
|
||||
<view class="top-visual">
|
||||
<view class="network">
|
||||
@@ -70,16 +64,6 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, reactive, ref } from 'vue'
|
||||
import { fetchMatchingProfile, type MatchingProfile } from '../../api/matching'
|
||||
import { createProfileOpener } from '../../api/navigation'
|
||||
import CasesPage from '../cases/cases.vue'
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'open-settings'): void
|
||||
(event: 'open-profile'): void
|
||||
(event: 'go-home'): void
|
||||
}>()
|
||||
|
||||
const openProfile = createProfileOpener(emit)
|
||||
|
||||
type Particle = {
|
||||
id: number
|
||||
@@ -95,11 +79,12 @@ const profile = reactive<MatchingProfile>({
|
||||
|
||||
const particles = ref<Particle[]>([])
|
||||
const progress = ref(0)
|
||||
const showCasesPage = ref(false)
|
||||
|
||||
let particleId = 0
|
||||
let particleTimer: ReturnType<typeof setInterval> | null = null
|
||||
let progressTimer: ReturnType<typeof setInterval> | null = null
|
||||
const MATCHING_DURATION_MS = 10000
|
||||
const PROGRESS_INTERVAL_MS = 100
|
||||
|
||||
function loadMatchingProfile() {
|
||||
fetchMatchingProfile().then(result => {
|
||||
@@ -142,18 +127,21 @@ function startParticles() {
|
||||
function startProgress() {
|
||||
if (progressTimer) clearInterval(progressTimer)
|
||||
progress.value = 0
|
||||
const startedAt = Date.now()
|
||||
progressTimer = setInterval(() => {
|
||||
if (progress.value >= profile.progressTarget) {
|
||||
const elapsed = Date.now() - startedAt
|
||||
const ratio = Math.min(1, elapsed / MATCHING_DURATION_MS)
|
||||
progress.value = Math.round(profile.progressTarget * ratio)
|
||||
|
||||
if (ratio >= 1) {
|
||||
if (progressTimer) clearInterval(progressTimer)
|
||||
progressTimer = null
|
||||
setTimeout(() => {
|
||||
showCasesPage.value = true
|
||||
}, 700)
|
||||
uni.redirectTo({
|
||||
url: '/pages/cases/cases'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
progress.value = Math.min(profile.progressTarget, progress.value + Math.random() * 3)
|
||||
}, 600)
|
||||
}, PROGRESS_INTERVAL_MS)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
Reference in New Issue
Block a user