feat: 病例列表联调
This commit is contained in:
@@ -63,6 +63,8 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, reactive, ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import type { CaseListSource } from '../../api/cases'
|
||||
import { fetchMatchingProfile, type MatchingProfile } from '../../api/matching'
|
||||
|
||||
type Particle = {
|
||||
@@ -79,6 +81,7 @@ const profile = reactive<MatchingProfile>({
|
||||
|
||||
const particles = ref<Particle[]>([])
|
||||
const progress = ref(0)
|
||||
const source = ref<CaseListSource>('recommended')
|
||||
|
||||
let particleId = 0
|
||||
let particleTimer: ReturnType<typeof setInterval> | null = null
|
||||
@@ -137,13 +140,20 @@ function startProgress() {
|
||||
if (progressTimer) clearInterval(progressTimer)
|
||||
progressTimer = null
|
||||
uni.redirectTo({
|
||||
url: '/pages/cases/cases'
|
||||
url: `/pages/cases/cases?source=${encodeURIComponent(source.value)}`
|
||||
})
|
||||
return
|
||||
}
|
||||
}, PROGRESS_INTERVAL_MS)
|
||||
}
|
||||
|
||||
onLoad(query => {
|
||||
const querySource = query?.source
|
||||
if (isCaseListSource(querySource)) {
|
||||
source.value = querySource
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
loadMatchingProfile()
|
||||
startParticles()
|
||||
@@ -153,6 +163,14 @@ onUnmounted(() => {
|
||||
if (particleTimer) clearInterval(particleTimer)
|
||||
if (progressTimer) clearInterval(progressTimer)
|
||||
})
|
||||
|
||||
function isCaseListSource(value: unknown): value is CaseListSource {
|
||||
return value === 'recommended' ||
|
||||
value === 'specialty' ||
|
||||
value === 'weak' ||
|
||||
value === 'teaching' ||
|
||||
value === 'teacher-task'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
Reference in New Issue
Block a user