// static/vue-app.js // 使用 CDN 引入的 Vue3 + Vue Router,构建单页应用 const { createApp, ref, computed, onMounted } = Vue; const { createRouter, createWebHistory, useRoute, useRouter } = VueRouter; // 通用工具函数 function formatFileSize(bytes) { if (!bytes || bytes === 0) return "0 Bytes"; const k = 1024; const sizes = ["Bytes", "KB", "MB", "GB"]; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i]; } function formatNumber(num) { if (num === null || num === undefined) return "N/A"; if (num >= 1_000_000) return (num / 1_000_000).toFixed(2) + "M"; if (num >= 1_000) return (num / 1_000).toFixed(2) + "K"; return num.toFixed ? num.toFixed(2) : String(num); } function formatDateTime(dateString) { if (!dateString) return "N/A"; try { return new Date(dateString).toLocaleString(); } catch { return dateString; } } function statusText(status) { const map = { pending: "排队中", processing: "处理中", completed: "已完成", failed: "失败", }; return map[status] || status || "未知"; } // 顶部导航 + 布局 const App = { setup() { const route = useRoute(); const router = useRouter(); const health = ref(null); const isActive = (pathPrefix) => computed(() => route.path === pathPrefix || route.path.startsWith(pathPrefix)); const loadHealth = async () => { try { const res = await fetch("/health", { method: "POST" }); if (res.ok) { health.value = await res.json(); } } catch { health.value = null; } }; onMounted(loadHealth); return { route, router, health, isActive }; }, template: `
上传模型 → 自动分析几何 / 型腔 / 工艺 → 聚合展示关键指标
上传后系统会自动解析几何、生成模具型腔并计算关键工艺参数。
{{ error }}
按文件名聚合展示所有上传与分析任务。
正在加载历史记录...
{{ error }}
暂无历史记录,先在仪表盘上传一个文件吧。
正在加载记录...
正在加载任务 {{ taskId }} 的分析结果...
{{ error }}