提交代码

This commit is contained in:
ldh
2026-11-19 16:42:26 +08:00
parent c5908eff03
commit 9d06abe41c
209 changed files with 158631 additions and 1311 deletions
+416 -79
View File
@@ -7,6 +7,9 @@ import ScanVisual from '@/components/ScanVisual.vue'
import ProgressStrip from '@/components/ProgressStrip.vue'
import StatusFooter from '@/components/StatusFooter.vue'
import { analyzeSample, type SampleAnalysisResult } from '@/api/sample'
import { startScan } from '@/api/scan'
import { useStageHub } from '@/composables/useStageHub'
import { showToast } from '@/composables/useToast'
type AnalysisStatus = 'processing' | 'done' | 'error'
@@ -16,6 +19,9 @@ const status = ref<AnalysisStatus>('processing')
const result = ref<SampleAnalysisResult | null>(null)
const errorMessage = ref('')
const progress = ref(0)
const scanStarting = ref(false)
const { position: stagePosition, connect: connectStageHub } = useStageHub()
let progressTimer: number | undefined
@@ -29,6 +35,16 @@ const samplingPointCount = computed(
() => result.value?.samplingPointCount ?? '—',
)
const stageStatusText = computed(() => {
if (!stagePosition.value) return '未连接'
return stagePosition.value.moving ? '运动中' : '就绪'
})
const stageStatusTone = computed(() => {
if (!stagePosition.value) return 'is-off'
return stagePosition.value.moving ? 'is-moving' : 'is-ready'
})
const progressLabel = computed(() => {
if (status.value === 'done') return '靶样轮廓与采样点 100%'
if (status.value === 'error') return '图像分析失败'
@@ -101,12 +117,31 @@ function retry() {
void runAnalysis()
}
function goSpectrum() {
void router.replace({ name: 'spectrum' })
async function startScanning() {
if (scanStarting.value) return
if (!result.value) {
showToast('请等待靶样分析完成')
return
}
scanStarting.value = true
try {
const started = await startScan()
await router.push({
name: 'spectrum',
query: { scanId: started.scanId },
})
} catch (error) {
showToast(error instanceof Error ? error.message : '启动扫描失败')
} finally {
scanStarting.value = false
}
}
onMounted(() => {
void runAnalysis()
void connectStageHub()
})
onBeforeUnmount(stopProgress)
@@ -114,15 +149,21 @@ onBeforeUnmount(stopProgress)
<template>
<AppStage>
<PageHeader title="样品轮廓识别与激光点位规划" variant="process">
<div class="scan-bg" aria-hidden="true">
<span class="scan-bg__orb scan-bg__orb--blue"></span>
<span class="scan-bg__orb scan-bg__orb--cyan"></span>
<span class="scan-bg__orb scan-bg__orb--violet"></span>
</div>
<PageHeader title="样品轮廓识别与激光点位规划" variant="process" theme="dark">
<template #left>
<button class="header-button header-button--warn" type="button" @click="abortProcess">
<button class="scan-abort" type="button" @click="abortProcess">
中止流程
</button>
</template>
<template #right>
<button class="icon-close" type="button" aria-label="关闭并返回首页" @click="abortProcess">
<button class="scan-close" type="button" aria-label="关闭并返回首页" @click="abortProcess">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="m6 6 12 12M18 6 6 18" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" />
</svg>
@@ -167,7 +208,10 @@ onBeforeUnmount(stopProgress)
<aside class="params-card">
<header class="params-card__header">
<h2>采样点</h2>
<div class="params-card__heading">
<span class="params-card__eyebrow">Sampling Plan</span>
<h2>采样点</h2>
</div>
</header>
<div class="params-card__body">
@@ -177,43 +221,167 @@ onBeforeUnmount(stopProgress)
</div>
<div class="param-field">
<span class="param-field__label">脉冲能量</span>
<div class="param-field__value">120 <small>mJ</small></div>
<span class="param-field__label">当前位置</span>
<div class="param-field__value param-field__value--position">
<span>X {{ stagePosition ? stagePosition.x : '—' }}</span>
<span>Y {{ stagePosition ? stagePosition.y : '—' }}</span>
</div>
</div>
<div class="param-field">
<span class="param-field__label">积分时间</span>
<div class="param-field__value">10 <small>ms</small></div>
<span class="param-field__label">位移台状态</span>
<div
class="param-field__value param-field__value--status"
:class="stageStatusTone"
>
<i class="param-field__dot"></i>
{{ stageStatusText }}
</div>
</div>
</div>
<div class="param-field">
<span class="param-field__label">预扫描</span>
<div class="param-field__value">3 <small>次</small></div>
</div>
<div class="params-card__hint">
<span class="params-card__hint-mark">i</span>
<p>确认靶样轮廓与采样点分布符合要求后,点击“开始采集”进入光谱采集流程。</p>
</div>
</aside>
</main>
<div v-if="status !== 'error'" class="scan-progress">
<div class="scan-progress__strip">
<ProgressStrip :progress="progress" :label="progressLabel" :note="progressNote" />
<ProgressStrip
:progress="progress"
:label="progressLabel"
:note="progressNote"
theme="dark"
/>
</div>
<button
v-if="status === 'done'"
class="scan-next"
type="button"
@click="goSpectrum"
:disabled="scanStarting"
@click="startScanning"
>
开始采集光谱
{{ scanStarting ? '启动中...' : '开始采集' }}
</button>
</div>
<StatusFooter icon="info" :items="footerItems" />
<StatusFooter icon="info" :items="footerItems" theme="dark" />
</AppStage>
</template>
<style scoped>
.scan-bg {
position: absolute;
inset: 0;
overflow: hidden;
pointer-events: none;
background:
radial-gradient(1000px 600px at 8% -16%, rgba(48, 112, 255, 0.28), transparent 62%),
radial-gradient(820px 520px at 98% 4%, rgba(0, 209, 255, 0.14), transparent 60%),
radial-gradient(900px 680px at 58% 116%, rgba(122, 84, 255, 0.18), transparent 62%),
linear-gradient(156deg, #050a16 0%, #081226 46%, #0a1730 100%);
}
.scan-bg::before {
content: '';
position: absolute;
inset: 0;
background-image:
linear-gradient(rgba(130, 175, 255, 0.05) 1px, transparent 1px),
linear-gradient(90deg, rgba(130, 175, 255, 0.05) 1px, transparent 1px);
background-size: 64px 64px;
mask-image: radial-gradient(ellipse 78% 72% at 50% 32%, #000 20%, transparent 78%);
}
.scan-bg__orb {
position: absolute;
border-radius: 50%;
filter: blur(100px);
animation: scan-orb-drift 16s ease-in-out infinite alternate;
}
.scan-bg__orb--blue {
top: -340px;
left: -160px;
width: 760px;
height: 760px;
background: rgba(48, 118, 255, 0.3);
}
.scan-bg__orb--cyan {
top: -200px;
right: -220px;
width: 640px;
height: 640px;
background: rgba(0, 214, 255, 0.18);
animation-delay: -5s;
}
.scan-bg__orb--violet {
bottom: -360px;
left: 36%;
width: 700px;
height: 700px;
background: rgba(124, 92, 255, 0.18);
animation-delay: -10s;
}
@keyframes scan-orb-drift {
from {
transform: translate3d(0, 0, 0) scale(1);
}
to {
transform: translate3d(42px, 30px, 0) scale(1.08);
}
}
.scan-abort {
width: 300px;
height: 68px;
border: 1px solid rgba(255, 190, 60, 0.45);
border-radius: 14px;
background: linear-gradient(120deg, rgba(255, 186, 40, 0.18), rgba(255, 150, 20, 0.06));
color: #ffd98a;
font-size: 26px;
font-weight: 600;
letter-spacing: 3px;
backdrop-filter: blur(10px);
transition:
transform 0.2s ease,
border-color 0.2s ease,
background 0.2s ease;
}
.scan-abort:hover {
border-color: rgba(255, 205, 100, 0.65);
background: linear-gradient(120deg, rgba(255, 186, 40, 0.26), rgba(255, 150, 20, 0.1));
transform: translateY(-1px);
}
.scan-close {
display: grid;
place-items: center;
width: 52px;
height: 52px;
border-radius: 50%;
color: rgba(170, 200, 235, 0.8);
transition: color 0.2s ease, background 0.2s ease;
}
.scan-close:hover {
background: rgba(255, 255, 255, 0.08);
color: #eaf3ff;
}
.scan-close svg {
width: 26px;
height: 26px;
}
.scan-main {
position: absolute;
top: 142px;
@@ -233,16 +401,21 @@ onBeforeUnmount(stopProgress)
}
.result-card {
position: relative;
display: flex;
flex-direction: column;
width: 1120px;
max-width: 100%;
height: 100%;
overflow: hidden;
border: 1px solid #1e55a4;
border-radius: 18px;
background: #0b1220;
box-shadow: 0 18px 44px rgba(31, 77, 147, 0.28);
border: 1px solid rgba(130, 175, 255, 0.18);
border-radius: 26px;
background: linear-gradient(158deg, rgba(20, 40, 78, 0.7) 0%, rgba(6, 14, 30, 0.85) 100%);
box-shadow:
0 30px 70px rgba(0, 10, 32, 0.5),
0 0 40px rgba(48, 118, 255, 0.1),
inset 0 1px 0 rgba(255, 255, 255, 0.08);
backdrop-filter: blur(16px);
justify-self: center;
}
@@ -251,25 +424,38 @@ onBeforeUnmount(stopProgress)
flex: none;
align-items: center;
justify-content: space-between;
height: 66px;
padding: 0 26px;
background: linear-gradient(180deg, #3d80e2 0%, #2f6fd0 100%);
height: 72px;
padding: 0 28px;
border-bottom: 1px solid rgba(130, 175, 255, 0.12);
background: linear-gradient(120deg, rgba(26, 58, 112, 0.85) 0%, rgba(10, 24, 52, 0.8) 100%);
}
.result-card__header h2 {
color: #fff;
display: flex;
align-items: center;
gap: 12px;
color: #eef5ff;
font-size: 28px;
font-weight: 600;
letter-spacing: 3px;
text-shadow: 0 1px 3px rgba(16, 49, 101, 0.22);
text-shadow: 0 0 22px rgba(80, 150, 255, 0.3);
}
.result-card__header h2::before {
content: '';
width: 4px;
height: 24px;
border-radius: 4px;
background: linear-gradient(180deg, #7fe0ff, #4d8bf0);
box-shadow: 0 0 14px rgba(90, 170, 255, 0.7);
}
.result-card__count {
padding: 5px 14px;
border: 1px solid rgba(255, 255, 255, 0.3);
padding: 6px 16px;
border: 1px solid rgba(130, 195, 255, 0.3);
border-radius: 30px;
background: rgba(255, 255, 255, 0.12);
color: #fff;
background: rgba(16, 40, 80, 0.5);
color: #9fe8ff;
font-size: 17px;
letter-spacing: 1px;
}
@@ -280,6 +466,7 @@ onBeforeUnmount(stopProgress)
min-height: 0;
place-items: center;
padding: 10px;
background: #040810;
}
.result-card__image {
@@ -297,10 +484,14 @@ onBeforeUnmount(stopProgress)
max-width: 100%;
height: 100%;
padding: 40px;
border: 1px solid #d9e0e8;
border-radius: 18px;
background: #fff;
box-shadow: var(--shadow-card);
border: 1px solid rgba(255, 107, 107, 0.24);
border-radius: 26px;
background: linear-gradient(158deg, rgba(64, 22, 34, 0.4) 0%, rgba(8, 14, 28, 0.88) 70%);
box-shadow:
0 30px 70px rgba(0, 10, 32, 0.5),
0 0 40px rgba(255, 84, 84, 0.08),
inset 0 1px 0 rgba(255, 255, 255, 0.06);
backdrop-filter: blur(16px);
justify-self: center;
text-align: center;
}
@@ -311,9 +502,11 @@ onBeforeUnmount(stopProgress)
width: 96px;
height: 96px;
margin-bottom: 24px;
border: 1px solid rgba(255, 120, 120, 0.3);
border-radius: 50%;
color: var(--red);
background: #fdeeee;
background: rgba(255, 84, 84, 0.12);
box-shadow: 0 0 30px rgba(255, 84, 84, 0.18);
color: #ff9d9d;
}
.error-card__icon svg {
@@ -322,16 +515,17 @@ onBeforeUnmount(stopProgress)
}
.error-card h2 {
color: #1f2937;
color: #f3f8ff;
font-size: 32px;
font-weight: 600;
letter-spacing: 2px;
text-shadow: 0 0 24px rgba(255, 100, 100, 0.2);
}
.error-card p {
margin-top: 16px;
max-width: 760px;
color: var(--muted);
color: rgba(178, 202, 232, 0.72);
font-size: 20px;
line-height: 1.6;
}
@@ -349,64 +543,119 @@ onBeforeUnmount(stopProgress)
font-size: 21px;
font-weight: 600;
letter-spacing: 3px;
transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
transition:
transform 0.2s ease,
box-shadow 0.2s ease,
background 0.2s ease,
border-color 0.2s ease;
}
.error-button--ghost {
border: 2px solid var(--line-strong);
color: var(--ink-soft);
background: #fff;
border: 1px solid rgba(130, 175, 255, 0.3);
background: rgba(18, 40, 78, 0.5);
color: #bcd9ff;
}
.error-button--ghost:hover {
background: var(--surface-soft);
border-color: rgba(150, 205, 255, 0.5);
background: rgba(30, 66, 128, 0.6);
}
.error-button--primary {
color: #fff;
background: linear-gradient(180deg, #4b89e4 0%, #2f6fd0 100%);
box-shadow: 0 10px 22px rgba(47, 111, 208, 0.28);
background: linear-gradient(180deg, #6fc6ff 0%, #3f86f0 55%, #2c63c9 100%);
box-shadow:
0 12px 26px rgba(47, 111, 208, 0.35),
inset 0 1px 0 rgba(255, 255, 255, 0.4);
color: #04101f;
}
.error-button--primary:hover {
box-shadow:
0 16px 32px rgba(47, 111, 208, 0.45),
inset 0 1px 0 rgba(255, 255, 255, 0.45);
transform: translateY(-1px);
box-shadow: 0 14px 28px rgba(47, 111, 208, 0.36);
}
.params-card {
position: relative;
display: flex;
flex-direction: column;
height: 100%;
overflow: hidden;
border: 1px solid #d9e0e8;
border-radius: 10px;
background: #fff;
box-shadow: 0 8px 24px rgba(33, 53, 84, 0.05);
border: 1px solid rgba(130, 175, 255, 0.16);
border-radius: 26px;
background: linear-gradient(
158deg,
rgba(255, 255, 255, 0.07) 0%,
rgba(255, 255, 255, 0.025) 58%,
rgba(255, 255, 255, 0.04) 100%
);
box-shadow:
0 30px 70px rgba(0, 10, 32, 0.45),
inset 0 1px 0 rgba(255, 255, 255, 0.08);
backdrop-filter: blur(16px);
}
.params-card::before {
content: '';
position: absolute;
top: 0;
right: 32px;
left: 32px;
height: 1px;
background: linear-gradient(90deg, transparent, rgba(120, 180, 255, 0.55), transparent);
pointer-events: none;
}
.params-card__header {
display: flex;
flex: none;
align-items: center;
height: 64px;
padding: 0 22px;
border-bottom: 1px solid #e4e8ee;
background: #f3f4f6;
height: 96px;
padding: 0 26px;
border-bottom: 1px solid rgba(130, 175, 255, 0.12);
background: linear-gradient(120deg, rgba(30, 66, 128, 0.24) 0%, transparent 70%);
}
.params-card__heading {
display: flex;
flex-direction: column;
gap: 6px;
}
.params-card__eyebrow {
color: #5aa2ff;
font-size: 12px;
font-weight: 600;
letter-spacing: 2.6px;
text-transform: uppercase;
}
.params-card__header h2 {
color: #333b46;
font-size: 23px;
font-weight: 500;
letter-spacing: 1px;
display: flex;
align-items: center;
gap: 12px;
color: #eaf3ff;
font-size: 26px;
font-weight: 600;
letter-spacing: 2px;
}
.params-card__header h2::before {
content: '';
width: 4px;
height: 22px;
border-radius: 4px;
background: linear-gradient(180deg, #7fe0ff, #4d8bf0);
box-shadow: 0 0 14px rgba(90, 170, 255, 0.7);
}
.params-card__body {
padding: 26px 22px;
padding: 28px 24px;
}
.param-field {
margin-bottom: 24px;
margin-bottom: 26px;
}
.param-field:last-child {
@@ -416,9 +665,9 @@ onBeforeUnmount(stopProgress)
.param-field__label {
display: block;
margin-bottom: 10px;
color: #46505e;
font-size: 22px;
letter-spacing: 0.5px;
color: rgba(158, 190, 226, 0.7);
font-size: 20px;
letter-spacing: 1px;
}
.param-field__value {
@@ -426,20 +675,90 @@ onBeforeUnmount(stopProgress)
align-items: center;
height: 62px;
padding: 0 18px;
border: 1px solid #d8dde6;
border-radius: 7px;
background: #fff;
color: #2e3641;
border: 1px solid rgba(130, 175, 255, 0.16);
border-radius: 12px;
background: rgba(8, 18, 38, 0.6);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
color: #e8f2ff;
font-size: 24px;
box-shadow: inset 0 1px 2px rgba(30, 45, 66, 0.03);
}
.param-field__value small {
margin-left: 8px;
color: #8d97a4;
color: rgba(158, 190, 226, 0.55);
font-size: 18px;
}
.param-field__value--position {
justify-content: space-between;
gap: 12px;
}
.param-field__value--status {
gap: 10px;
}
.param-field__dot {
flex: none;
width: 9px;
height: 9px;
border-radius: 50%;
background: #c9d4e4;
}
.param-field__value--status.is-ready {
color: #8ff5e7;
}
.param-field__value--status.is-ready .param-field__dot {
background: #74f4c5;
box-shadow: 0 0 10px rgba(116, 244, 197, 0.9);
}
.param-field__value--status.is-moving {
color: #ffd98a;
}
.param-field__value--status.is-moving .param-field__dot {
background: #ffd86a;
box-shadow: 0 0 10px rgba(255, 216, 106, 0.8);
}
.param-field__value--status.is-off {
color: rgba(255, 154, 145, 0.9);
}
.param-field__value--status.is-off .param-field__dot {
background: #ff9a91;
box-shadow: 0 0 10px rgba(255, 154, 145, 0.7);
}
.params-card__hint {
display: flex;
gap: 12px;
margin: auto 24px 26px;
padding: 16px 18px;
border: 1px solid rgba(130, 175, 255, 0.14);
border-radius: 14px;
background: rgba(8, 18, 38, 0.45);
color: rgba(158, 190, 226, 0.66);
font-size: 16px;
line-height: 1.6;
}
.params-card__hint-mark {
display: grid;
flex: none;
place-items: center;
width: 24px;
height: 24px;
border: 1px solid rgba(130, 195, 255, 0.35);
border-radius: 50%;
color: #8fc6ff;
font-size: 14px;
font-weight: 700;
}
.scan-progress {
position: absolute;
top: 900px;
@@ -460,18 +779,36 @@ onBeforeUnmount(stopProgress)
flex: none;
width: 280px;
height: 54px;
border-radius: 10px;
color: #fff;
border-radius: 12px;
background: linear-gradient(180deg, #ffd166 0%, #f0ac0b 100%);
box-shadow:
0 14px 30px rgba(240, 172, 11, 0.28),
0 0 26px rgba(255, 190, 60, 0.16),
inset 0 1px 0 rgba(255, 255, 255, 0.6);
color: #241500;
font-size: 23px;
font-weight: 600;
letter-spacing: 3px;
background: linear-gradient(180deg, #4b89e4 0%, #2f6fd0 100%);
box-shadow: 0 10px 22px rgba(47, 111, 208, 0.28);
transition: transform 0.2s ease, box-shadow 0.2s ease;
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.25);
transition:
transform 0.2s ease,
box-shadow 0.2s ease,
filter 0.2s ease;
}
.scan-next:hover {
transform: translateY(-1px);
box-shadow: 0 14px 28px rgba(47, 111, 208, 0.36);
.scan-next:not(:disabled):hover {
box-shadow:
0 18px 38px rgba(240, 172, 11, 0.36),
0 0 34px rgba(255, 190, 60, 0.26),
inset 0 1px 0 rgba(255, 255, 255, 0.6);
transform: translateY(-2px);
}
.scan-next:disabled {
cursor: default;
filter: saturate(0.35);
opacity: 0.45;
box-shadow: none;
transform: none;
}
</style>