From cb3e9afa593f64be8c6d7dc2bf85c73b9f647237 Mon Sep 17 00:00:00 2001 From: CritasWang Date: Wed, 25 Nov 2026 17:28:15 +0800 Subject: [PATCH 01/13] fix(frontend): highlight the current view button and show date and time on the chart axis - extract the per-file view switcher into FileViewNav so the three view pages share one button set: back first, then the other views in a fixed order, and the current view's own button last as the primary (blue) one. Before this the data preview page highlighted "chart" and the metadata page highlighted "data preview", i.e. the highlight pointed at a button that leaves the current page. - chart time axis: labels used to render HH:mm only, so a multi-day series showed a row of identical times (00:00, 00:00, ...). Labels now render the full "YYYY-MM-DD HH:mm:ss", the dataZoom slider uses the same formatter, and hideOverlap drops the labels that would collide at high tick density. Clicking a file already defaults to the data preview page, and the page title still names the current view in the top-left corner. --- frontend/src/components/tsfile/ChartPanel.vue | 28 ++++++-- .../src/components/tsfile/FileViewNav.vue | 67 +++++++++++++++++++ frontend/src/views/tsfile/chart/index.vue | 15 +---- .../src/views/tsfile/data-preview/index.vue | 14 +--- frontend/src/views/tsfile/metadata/index.vue | 14 +--- 5 files changed, 97 insertions(+), 41 deletions(-) create mode 100644 frontend/src/components/tsfile/FileViewNav.vue diff --git a/frontend/src/components/tsfile/ChartPanel.vue b/frontend/src/components/tsfile/ChartPanel.vue index 5f5682c..7e9f5e6 100644 --- a/frontend/src/components/tsfile/ChartPanel.vue +++ b/frontend/src/components/tsfile/ChartPanel.vue @@ -81,6 +81,19 @@ function calcChartHeight() { chartHeight.value = Math.max(400, window.innerHeight - 310); } +const pad2 = (value: number) => String(value).padStart(2, "0"); + +/** + * 时间轴标签统一显示到秒(年月日时分秒)。 + * 原先只输出 HH:mm,跨天数据在横轴上就是同一串时刻(00:00、01:00…),看不出是哪一天。 + */ +function formatAxisLabel(value: number): string { + const date = new Date(value); + const day = `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())}`; + const clock = `${pad2(date.getHours())}:${pad2(date.getMinutes())}:${pad2(date.getSeconds())}`; + return `${day} ${clock}`; +} + const chartOption = computed(() => { const style = getChartStyle(isDark.value); const legendData = props.series.map((s) => s.name); @@ -134,10 +147,9 @@ const chartOption = computed(() => { boundaryGap: false, axisLabel: { ...style.timeAxis.axisLabel, - formatter: (value: number) => { - const date = new Date(value); - return `${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}`; - }, + formatter: (value: number) => formatAxisLabel(value), + // 标签带完整年月日时分秒后很长,密度高时会互相压住,交给 ECharts 丢掉重叠项 + hideOverlap: true, }, }, yAxis: { @@ -146,7 +158,13 @@ const chartOption = computed(() => { }, dataZoom: [ { type: "inside" as const, start: 0, end: 100 }, - { type: "slider" as const, start: 0, end: 100, bottom: "8%" }, + { + type: "slider" as const, + start: 0, + end: 100, + bottom: "8%", + labelFormatter: (value: number) => formatAxisLabel(value), + }, ], series: seriesData, }; diff --git a/frontend/src/components/tsfile/FileViewNav.vue b/frontend/src/components/tsfile/FileViewNav.vue new file mode 100644 index 0000000..bf0e44f --- /dev/null +++ b/frontend/src/components/tsfile/FileViewNav.vue @@ -0,0 +1,67 @@ + + + + diff --git a/frontend/src/views/tsfile/chart/index.vue b/frontend/src/views/tsfile/chart/index.vue index e31d747..7d33bfd 100644 --- a/frontend/src/views/tsfile/chart/index.vue +++ b/frontend/src/views/tsfile/chart/index.vue @@ -26,6 +26,7 @@ import { dataApi, metaApi } from "@/api/tsfile"; import ChartPanel from "@/components/tsfile/ChartPanel.vue"; import TableFilterPanel from "@/components/tsfile/TableFilterPanel.vue"; import TreeFilterPanel from "@/components/tsfile/TreeFilterPanel.vue"; +import FileViewNav from "@/components/tsfile/FileViewNav.vue"; import PageHeader from "@/components/layout/PageHeader.vue"; import { useFileStore } from "@/stores/tsfile/file"; import { decodeFileId } from "@/utils/fileId"; @@ -128,15 +129,7 @@ function handleFilterChange(filters: Record) { currentFilters.value = filters; loadChartData(filters); } -function goToDataPreview() { - router.push(`/tsfile/data/${fileId.value}`); -} -function goToMetadata() { - router.push(`/tsfile/meta/${fileId.value}`); -} -function goBack() { - router.push("/tsfile/files"); -} + function goToQuickScan() { try { const filePath = decodeFileId(fileId.value); @@ -153,9 +146,7 @@ function goToQuickScan() {
@@ -452,4 +458,14 @@ onMounted(() => { .file-tree :deep(.el-tree-node__expand-icon) { padding: 0.125rem; } + +/* 文件大小徽章:靠右对齐,不参与文件名的省略计算;等宽数字避免上下行错位 */ +.tc-file-size { + margin-left: auto; + flex-shrink: 0; + padding-left: 0.25rem; + font-size: 0.6875rem; + font-variant-numeric: tabular-nums; + color: var(--text-body); +} diff --git a/frontend/src/utils/formatSize.ts b/frontend/src/utils/formatSize.ts new file mode 100644 index 0000000..c7955ed --- /dev/null +++ b/frontend/src/utils/formatSize.ts @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/** + * 把字节数格式化为人类可读的大小(1024 进制)。 + * + * 侧栏文件树只需要展示磁盘文件大小,不解析 TsFile 内容,所以这里只是一次除法换算。 + */ +export function formatFileSize(bytes: number): string { + if (bytes < 1024) return `${bytes} B`; + if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`; + if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; + return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`; +} From 4c0d0dac68b5dc3f42f169bb6ee6d31094dda867 Mon Sep 17 00:00:00 2001 From: CritasWang Date: Wed, 25 Nov 2026 17:58:30 +0800 Subject: [PATCH 03/13] fix(frontend): stop the tables tab from stalling on files with many tables Opening a file with hundreds of tables (277eacd3a2864578_part_0.tsfile has 225) froze the UI on the metadata page. Two things combined: - TablesTable auto-expanded every table when the metadata arrived; - el-collapse-item keeps its slot content mounted and only hides it with v-show, so every expanded table built two el-tables right away. For 225 tables that is ~450 el-tables, 4,275 table rows and a ~6.9 MB initial DOM in one synchronous render. Now the panel content is rendered only while its panel is expanded (v-if), and only the first table is expanded by default. Collapsed panels cost a single header row, and a table's two el-tables are built when it is actually opened. Measured on that file with a production build: initial DOM 6.9 MB -> 0.9 MB, rendered table rows 4,275 -> 29, and expanding/collapsing a panel still renders and measures its tables correctly. --- .../src/components/tsfile/TablesTable.vue | 181 ++++++++++-------- 1 file changed, 96 insertions(+), 85 deletions(-) diff --git a/frontend/src/components/tsfile/TablesTable.vue b/frontend/src/components/tsfile/TablesTable.vue index c382cf0..dffd530 100644 --- a/frontend/src/components/tsfile/TablesTable.vue +++ b/frontend/src/components/tsfile/TablesTable.vue @@ -45,6 +45,15 @@ const { t } = useI18n(); const activeKeys = ref([]); +/** + * 只渲染已展开面板里的两张表。 + * + * el-collapse-item 用 v-show 隐藏折叠内容,插槽里的 el-table 依然会挂载;表多的文件 + * (例如 225 张表的 tsfile)一开页就要建出几百个 el-table,主线程直接卡住。 + * 所以内容加 v-if:收起时连 el-table 都不创建。 + */ +const expandedKeys = computed(() => new Set(activeKeys.value)); + /* ------------------------------------------------------------------ * * 表格高度:按需分配 * @@ -169,12 +178,12 @@ onBeforeUnmount(() => { // 折叠展开与数据变化都会改变第一个分区的位置,需要重新实测 watch([activeKeys, () => props.tables], () => void nextTick(measure), { deep: true }); -// Auto-expand all panels when tables data arrives +// 默认只展开第一张表:表多的文件全部展开既没有可读性,也会把折叠区撑到几万像素高 watch( () => props.tables, (tables) => { if (tables.length > 0 && activeKeys.value.length === 0) { - activeKeys.value = tables.map((tbl) => tbl.tableName); + activeKeys.value = [tables[0].tableName]; } }, { immediate: true }, @@ -208,93 +217,95 @@ watch( -
- -
-

- {{ t("tsfile.metadata.tagColumnsDesc") }} -

-
- - - - - - - - + From 0d04b87001595242f5c0a6226c871d2b1750efd3 Mon Sep 17 00:00:00 2001 From: CritasWang Date: Wed, 25 Nov 2026 19:02:08 +0800 Subject: [PATCH 04/13] fix(frontend): pin the file view buttons to a fixed order FileViewNav used to move the current view's button to the rightmost slot and make it the primary one, so the button row shifted on every page switch (data preview: back/metadata/chart/[data preview], chart: back/metadata/data preview/[chart], metadata: back/data preview/chart/[metadata]). Every view page now renders the same row in the same order -- back / metadata / chart visualization / data preview -- with data preview always the primary (blue) button on the right, because it is the page each file lands on. Clicking it while already there stays a no-op instead of raising a duplicate-navigation error. --- .../src/components/tsfile/FileViewNav.vue | 36 +++++++------------ frontend/src/views/tsfile/chart/index.vue | 2 +- .../src/views/tsfile/data-preview/index.vue | 2 +- frontend/src/views/tsfile/metadata/index.vue | 2 +- 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/frontend/src/components/tsfile/FileViewNav.vue b/frontend/src/components/tsfile/FileViewNav.vue index bf0e44f..930d54e 100644 --- a/frontend/src/components/tsfile/FileViewNav.vue +++ b/frontend/src/components/tsfile/FileViewNav.vue @@ -18,43 +18,32 @@ --> diff --git a/frontend/src/i18n/locales/en-US.json b/frontend/src/i18n/locales/en-US.json index e57779d..6e8b51e 100644 --- a/frontend/src/i18n/locales/en-US.json +++ b/frontend/src/i18n/locales/en-US.json @@ -249,7 +249,9 @@ "downsampledDescription": "Data has been automatically downsampled for performance. To view full data, narrow the time range or reduce measurements.", "noData": "No chart data. Please select measurements and apply filters.", "tooManySeries": "Too many series to render ({count}; limit {max})", - "tooManySeriesDescription": "Drawing too many lines at once can freeze or crash the page. Reduce the selected fields/devices in the filter above to {max} series or fewer, then view the chart." + "tooManySeriesDescription": "Drawing too many lines at once can freeze or crash the page. Reduce the selected fields/devices in the filter above to {max} series or fewer, then view the chart.", + "seriesTruncated": "Showing the first {max} series by default ({omitted} more not shown)", + "seriesTruncatedDescription": "The chart draws at most {max} lines at a time and ignores the rest. To inspect other fields, select fewer fields above and apply the filter again." }, "scan": { "title": "File Scan", diff --git a/frontend/src/i18n/locales/zh-CN.json b/frontend/src/i18n/locales/zh-CN.json index 28e846d..f5d6803 100644 --- a/frontend/src/i18n/locales/zh-CN.json +++ b/frontend/src/i18n/locales/zh-CN.json @@ -249,7 +249,9 @@ "downsampledDescription": "为保证性能,数据已自动降采样显示。如需查看完整数据,请缩小时间范围或减少测点数量。", "noData": "暂无图表数据,请选择测点并应用筛选条件", "tooManySeries": "序列过多,已暂停绘制({count} 条,上限 {max} 条)", - "tooManySeriesDescription": "一次性绘制过多折线会导致页面卡顿甚至崩溃。请在上方筛选器中减少所选字段/设备,将序列数降到 {max} 条以内后再查看。" + "tooManySeriesDescription": "一次性绘制过多折线会导致页面卡顿甚至崩溃。请在上方筛选器中减少所选字段/设备,将序列数降到 {max} 条以内后再查看。", + "seriesTruncated": "已默认只展示前 {max} 条序列(另有 {omitted} 条未展示)", + "seriesTruncatedDescription": "图表一次最多绘制 {max} 条折线,超出的部分已自动忽略。想查看其它字段,请在上方筛选器里减少所选字段后重新应用。" }, "scan": { "title": "文件扫描", diff --git a/frontend/src/utils/chartLimits.ts b/frontend/src/utils/chartLimits.ts new file mode 100644 index 0000000..ed7bb7a --- /dev/null +++ b/frontend/src/utils/chartLimits.ts @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +/** + * 单个图表最多绘制的序列数。 + * + * 图表页按这个上限只请求前 N 条序列,ChartPanel 用同一个值兜底,两边共用一个来源, + * 避免改了上限却只改一处。 + */ +export const MAX_CHART_SERIES = 50; diff --git a/frontend/src/views/tsfile/chart/index.vue b/frontend/src/views/tsfile/chart/index.vue index 013a1b6..60abd7f 100644 --- a/frontend/src/views/tsfile/chart/index.vue +++ b/frontend/src/views/tsfile/chart/index.vue @@ -30,6 +30,7 @@ import FileViewNav from "@/components/tsfile/FileViewNav.vue"; import PageHeader from "@/components/layout/PageHeader.vue"; import { useFileStore } from "@/stores/tsfile/file"; import { decodeFileId } from "@/utils/fileId"; +import { MAX_CHART_SERIES } from "@/utils/chartLimits"; const route = useRoute(); const router = useRouter(); @@ -50,6 +51,8 @@ const error = ref(null); const currentFilters = ref>({}); const metadata = ref(null); const metaError = ref(null); +/** 选中的序列超过 MAX_CHART_SERIES 时,被挡掉没有请求的数量 */ +const omittedSeries = ref(0); const isTableModel = computed(() => metadata.value?.tables && metadata.value.tables.length > 0); @@ -75,6 +78,7 @@ watch( timeRange.value = undefined; totalPoints.value = 0; downsampled.value = false; + omittedSeries.value = 0; error.value = null; currentFilters.value = {}; metadata.value = null; @@ -98,8 +102,11 @@ async function loadChartData(filters: Record) { loading.value = true; error.value = null; try { - const measurements = filters.measurements as string[] | undefined; - if (!measurements || measurements.length === 0) { + const selected = (filters.measurements as string[] | undefined) ?? []; + // 选中超过上限时默认只画前 MAX_CHART_SERIES 条,其余留给筛选器调整,避免一次画近百条折线卡住页面 + const measurements = selected.slice(0, MAX_CHART_SERIES); + omittedSeries.value = selected.length - measurements.length; + if (measurements.length === 0) { chartSeries.value = []; loading.value = false; return; @@ -180,6 +187,7 @@ function goToQuickScan() { :error="error" :downsampled="downsampled" :total-points="totalPoints" + :omitted-series="omittedSeries" />
From c7baea5177488cbff724b395c96bfa8b8860431d Mon Sep 17 00:00:00 2001 From: CritasWang Date: Fri, 27 Nov 2026 11:10:31 +0800 Subject: [PATCH 06/13] feat(backend): include the on-disk file size in the metadata response TsFileMetadataDTO gains a fileSize field and MetadataService stats the file while building the summary, so a page header can show "file / size" without a second request or a directory listing round-trip. --- .../apache/tsfile/viewer/dto/TsFileMetadataDTO.java | 11 +++++++++++ .../apache/tsfile/viewer/service/MetadataService.java | 2 ++ 2 files changed, 13 insertions(+) diff --git a/backend/src/main/java/org/apache/tsfile/viewer/dto/TsFileMetadataDTO.java b/backend/src/main/java/org/apache/tsfile/viewer/dto/TsFileMetadataDTO.java index c2a0cd3..9b1d025 100644 --- a/backend/src/main/java/org/apache/tsfile/viewer/dto/TsFileMetadataDTO.java +++ b/backend/src/main/java/org/apache/tsfile/viewer/dto/TsFileMetadataDTO.java @@ -33,6 +33,9 @@ public class TsFileMetadataDTO { private String fileId; private String version; + + /** Size of the file on disk, in bytes. */ + private long fileSize; private TimeRange timeRange; private int deviceCount; private int measurementCount; @@ -58,6 +61,14 @@ public String getVersion() { return version; } + public long getFileSize() { + return fileSize; + } + + public void setFileSize(long fileSize) { + this.fileSize = fileSize; + } + public void setVersion(String version) { this.version = version; } diff --git a/backend/src/main/java/org/apache/tsfile/viewer/service/MetadataService.java b/backend/src/main/java/org/apache/tsfile/viewer/service/MetadataService.java index 2d4c61f..ed9ff86 100644 --- a/backend/src/main/java/org/apache/tsfile/viewer/service/MetadataService.java +++ b/backend/src/main/java/org/apache/tsfile/viewer/service/MetadataService.java @@ -146,6 +146,8 @@ public TsFileMetadataDTO getMetadata(String fileId) TsFileParser.SummaryMetadata summary = tsFileParser.parseSummary(filePath); TsFileMetadataDTO metadata = toSummaryDTO(fileId, summary); + // 磁盘大小随元数据一起返回,页头展示「文件:xxx 大小:yyy」就不必再单独请求 + metadata.setFileSize(Files.exists(Paths.get(filePath)) ? Files.size(Paths.get(filePath)) : 0L); metadataCache.put(fileId, metadata); deviceIndexCache.put(fileId, summary.deviceIndex()); From e586fce3ac48eb90ebbb578c455a8c92d98359b1 Mon Sep 17 00:00:00 2001 From: CritasWang Date: Fri, 27 Nov 2026 11:10:35 +0800 Subject: [PATCH 07/13] feat(frontend): top view menu, file info line, and per-file filter reset - FileViewNav becomes a horizontal menu above the content: link-style items in a fixed order (back / data preview / chart / metadata) with the current view underlined. The three views drop their duplicate page title and show a single "file: xxx size: yyy" line instead, fed by the new metadata field. - clicking a file in the sidebar now keeps the current view: on the chart or metadata page it only swaps the file instead of jumping back to the data preview; pages outside the three views still land on the data preview. - the filter panels clear their whole state (table, devices, fields, time range, quick range, advanced conditions) when the fileId changes, and TablesTable re-expands the first table of the newly loaded file. - the chart draws only the first 50 returned series and reports how many were omitted. The API expands one series per device x measurement, so a single selected field can come back as hundreds of series; capping the selected fields alone did not avoid the "too many series" wall. The chart height offset follows the shorter header. --- frontend/src/App.vue | 12 ++- frontend/src/api/tsfile/types.ts | 2 + frontend/src/components/tsfile/ChartPanel.vue | 5 +- .../src/components/tsfile/FileViewNav.vue | 101 +++++++++++++++--- .../components/tsfile/TableFilterPanel.vue | 9 ++ .../src/components/tsfile/TablesTable.vue | 7 +- .../src/components/tsfile/TreeFilterPanel.vue | 7 ++ frontend/src/i18n/locales/en-US.json | 4 +- frontend/src/i18n/locales/zh-CN.json | 4 +- frontend/src/views/tsfile/chart/index.vue | 37 +++++-- .../src/views/tsfile/data-preview/index.vue | 23 ++-- frontend/src/views/tsfile/metadata/index.vue | 16 +-- 12 files changed, 180 insertions(+), 47 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index bf56bec..cf97d45 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -44,6 +44,13 @@ const sidebarOpen = ref(false); const isOnScanPage = computed(() => route.name === "FileScan"); +/** 当前所在的功能页;不在三个功能页上时为 null(文件列表、扫描页等) */ +const currentFileView = computed(() => { + const name = route.name; + if (name === "DataPreview" || name === "ChartVisualization" || name === "Metadata") return name; + return null; +}); + const elementLocale = computed(() => (locale.value === "zh-CN" ? zhCn : en)); function handleFileSelect(fileId: string, path: string, name: string) { @@ -51,7 +58,10 @@ function handleFileSelect(fileId: string, path: string, name: string) { fileStore.setScanTarget(path, "file"); } else { fileStore.setCurrentFile(fileId, name); - router.push(`/tsfile/data/${fileId}`); + // 在功能页里换文件时停留在当前页面,只换 fileId;不在功能页时默认进数据预览 + if (currentFileView.value === "ChartVisualization") router.push(`/tsfile/chart/${fileId}`); + else if (currentFileView.value === "Metadata") router.push(`/tsfile/meta/${fileId}`); + else router.push(`/tsfile/data/${fileId}`); } } diff --git a/frontend/src/api/tsfile/types.ts b/frontend/src/api/tsfile/types.ts index b1d70c9..b89b360 100644 --- a/frontend/src/api/tsfile/types.ts +++ b/frontend/src/api/tsfile/types.ts @@ -136,6 +136,8 @@ export interface DeviceMeasurements { export interface TsFileMetadata { fileId: string; version: string; + /** 文件在磁盘上的大小(字节),随元数据接口一起返回 */ + fileSize?: number; timeRange: TimeRange; deviceCount: number; measurementCount: number; diff --git a/frontend/src/components/tsfile/ChartPanel.vue b/frontend/src/components/tsfile/ChartPanel.vue index 6dc59bc..e880821 100644 --- a/frontend/src/components/tsfile/ChartPanel.vue +++ b/frontend/src/components/tsfile/ChartPanel.vue @@ -80,8 +80,9 @@ let chartInstance: echarts.ECharts | null = null; const chartHeight = ref(500); function calcChartHeight() { - // Fill remaining viewport: subtract header(64) + filter(~140) + chart title(40) + padding(60) - chartHeight.value = Math.max(400, window.innerHeight - 310); + // Fill the remaining viewport: header(64) + view menu(~49) + filter(~140) + chart title(40) + // + padding(60)。改动这里的分项时保持与视图的纵向布局同步,否则图表会顶出屏幕。 + chartHeight.value = Math.max(400, window.innerHeight - 360); } const pad2 = (value: number) => String(value).padStart(2, "0"); diff --git a/frontend/src/components/tsfile/FileViewNav.vue b/frontend/src/components/tsfile/FileViewNav.vue index 5b55637..98fab67 100644 --- a/frontend/src/components/tsfile/FileViewNav.vue +++ b/frontend/src/components/tsfile/FileViewNav.vue @@ -18,41 +18,112 @@ --> + + diff --git a/frontend/src/components/tsfile/TableFilterPanel.vue b/frontend/src/components/tsfile/TableFilterPanel.vue index b06dcaa..0fa13ef 100644 --- a/frontend/src/components/tsfile/TableFilterPanel.vue +++ b/frontend/src/components/tsfile/TableFilterPanel.vue @@ -187,6 +187,15 @@ async function loadMetadata() { loading.value = true; error.value = null; + // 换文件时先清掉上一个文件的筛选:时间范围/高级条件不会自己过期, + // 留着就会带着旧文件的设定去查新文件 + selectedTable.value = undefined; + selectedDevices.value = []; + selectedMeasurements.value = []; + timeRange.value = null; + selectedQuickRange.value = null; + advancedConditions.value = []; + try { const response = await metaApi.getMetadata(props.fileId); metadata.value = response as TsFileMetadata; diff --git a/frontend/src/components/tsfile/TablesTable.vue b/frontend/src/components/tsfile/TablesTable.vue index dffd530..5f21403 100644 --- a/frontend/src/components/tsfile/TablesTable.vue +++ b/frontend/src/components/tsfile/TablesTable.vue @@ -178,13 +178,12 @@ onBeforeUnmount(() => { // 折叠展开与数据变化都会改变第一个分区的位置,需要重新实测 watch([activeKeys, () => props.tables], () => void nextTick(measure), { deep: true }); -// 默认只展开第一张表:表多的文件全部展开既没有可读性,也会把折叠区撑到几万像素高 +// 默认只展开第一张表:表多的文件全部展开既没有可读性,也会把折叠区撑到几万像素高。 +// 表集合变化(换文件)时同样重置,否则会残留上一个文件的展开项、看起来一张都没展开。 watch( () => props.tables, (tables) => { - if (tables.length > 0 && activeKeys.value.length === 0) { - activeKeys.value = [tables[0].tableName]; - } + activeKeys.value = tables.length > 0 ? [tables[0].tableName] : []; }, { immediate: true }, ); diff --git a/frontend/src/components/tsfile/TreeFilterPanel.vue b/frontend/src/components/tsfile/TreeFilterPanel.vue index a74526e..8c941d6 100644 --- a/frontend/src/components/tsfile/TreeFilterPanel.vue +++ b/frontend/src/components/tsfile/TreeFilterPanel.vue @@ -173,6 +173,13 @@ async function loadMetadata() { if (!props.fileId) return; loading.value = true; error.value = null; + // 换文件时先清掉上一个文件的筛选:时间范围/高级条件不会自己过期, + // 留着就会带着旧文件的设定去查新文件 + selectedDevice.value = ""; + selectedMeasurements.value = []; + timeRange.value = null; + selectedQuickRange.value = null; + advancedConditions.value = []; try { const response = await metaApi.getMetadata(props.fileId); metadata.value = response as TsFileMetadata; diff --git a/frontend/src/i18n/locales/en-US.json b/frontend/src/i18n/locales/en-US.json index 6e8b51e..3632e47 100644 --- a/frontend/src/i18n/locales/en-US.json +++ b/frontend/src/i18n/locales/en-US.json @@ -34,6 +34,8 @@ "apply": "Apply", "close": "Close", "back": "Back", + "fileInfo": "File: {name}", + "fileSize": "Size: {size}", "next": "Next", "previous": "Previous", "noData": "No Data", @@ -251,7 +253,7 @@ "tooManySeries": "Too many series to render ({count}; limit {max})", "tooManySeriesDescription": "Drawing too many lines at once can freeze or crash the page. Reduce the selected fields/devices in the filter above to {max} series or fewer, then view the chart.", "seriesTruncated": "Showing the first {max} series by default ({omitted} more not shown)", - "seriesTruncatedDescription": "The chart draws at most {max} lines at a time and ignores the rest. To inspect other fields, select fewer fields above and apply the filter again." + "seriesTruncatedDescription": "The chart draws at most {max} lines at a time and ignores the rest. One line is one device + field pair, so narrow the selected devices or fields above and apply the filter again." }, "scan": { "title": "File Scan", diff --git a/frontend/src/i18n/locales/zh-CN.json b/frontend/src/i18n/locales/zh-CN.json index f5d6803..66e354a 100644 --- a/frontend/src/i18n/locales/zh-CN.json +++ b/frontend/src/i18n/locales/zh-CN.json @@ -34,6 +34,8 @@ "apply": "应用", "close": "关闭", "back": "返回", + "fileInfo": "文件:{name}", + "fileSize": "大小:{size}", "next": "下一步", "previous": "上一步", "noData": "暂无数据", @@ -251,7 +253,7 @@ "tooManySeries": "序列过多,已暂停绘制({count} 条,上限 {max} 条)", "tooManySeriesDescription": "一次性绘制过多折线会导致页面卡顿甚至崩溃。请在上方筛选器中减少所选字段/设备,将序列数降到 {max} 条以内后再查看。", "seriesTruncated": "已默认只展示前 {max} 条序列(另有 {omitted} 条未展示)", - "seriesTruncatedDescription": "图表一次最多绘制 {max} 条折线,超出的部分已自动忽略。想查看其它字段,请在上方筛选器里减少所选字段后重新应用。" + "seriesTruncatedDescription": "图表一次最多绘制 {max} 条折线,超出的部分已自动忽略。一条折线对应「设备 + 字段」,想查看其它序列,请在上方筛选器里减少所选设备或字段后重新应用。" }, "scan": { "title": "文件扫描", diff --git a/frontend/src/views/tsfile/chart/index.vue b/frontend/src/views/tsfile/chart/index.vue index 60abd7f..cca7887 100644 --- a/frontend/src/views/tsfile/chart/index.vue +++ b/frontend/src/views/tsfile/chart/index.vue @@ -27,9 +27,9 @@ import ChartPanel from "@/components/tsfile/ChartPanel.vue"; import TableFilterPanel from "@/components/tsfile/TableFilterPanel.vue"; import TreeFilterPanel from "@/components/tsfile/TreeFilterPanel.vue"; import FileViewNav from "@/components/tsfile/FileViewNav.vue"; -import PageHeader from "@/components/layout/PageHeader.vue"; import { useFileStore } from "@/stores/tsfile/file"; import { decodeFileId } from "@/utils/fileId"; +import { formatFileSize } from "@/utils/formatSize"; import { MAX_CHART_SERIES } from "@/utils/chartLimits"; const route = useRoute(); @@ -50,6 +50,8 @@ const loading = ref(false); const error = ref(null); const currentFilters = ref>({}); const metadata = ref(null); +/** 页头展示的文件大小(字节),由元数据接口带回来 */ +const fileSize = computed(() => metadata.value?.fileSize ?? 0); const metaError = ref(null); /** 选中的序列超过 MAX_CHART_SERIES 时,被挡掉没有请求的数量 */ const omittedSeries = ref(0); @@ -103,11 +105,11 @@ async function loadChartData(filters: Record) { error.value = null; try { const selected = (filters.measurements as string[] | undefined) ?? []; - // 选中超过上限时默认只画前 MAX_CHART_SERIES 条,其余留给筛选器调整,避免一次画近百条折线卡住页面 + // 请求阶段先只带前 MAX_CHART_SERIES 个字段;真正的折线条数要到响应里才知道,见下方截断。 const measurements = selected.slice(0, MAX_CHART_SERIES); - omittedSeries.value = selected.length - measurements.length; if (measurements.length === 0) { chartSeries.value = []; + omittedSeries.value = 0; loading.value = false; return; } @@ -121,7 +123,13 @@ async function loadChartData(filters: Record) { maxPoints: 10_000, }; const response = await dataApi.queryChartData(request); - chartSeries.value = response.series; + // 后端按 device×measurement 展开,一个文件可能有上千个设备,返回的序列数远多于所选字段数。 + // 只画前 MAX_CHART_SERIES 条,并把「没发出去的字段 + 没画出来的序列」一起报给 ChartPanel。 + const allSeries = response.series ?? []; + const drawnSeries = allSeries.slice(0, MAX_CHART_SERIES); + chartSeries.value = drawnSeries; + omittedSeries.value = + selected.length - measurements.length + (allSeries.length - drawnSeries.length); timeRange.value = response.timeRange; totalPoints.value = response.totalPoints; downsampled.value = response.downsampled; @@ -151,11 +159,13 @@ function goToQuickScan() {