소스 검색

echats调整

caoziwu 1 주 전
부모
커밋
5c1afced5d
3개의 변경된 파일과 17개의 추가작업 그리고 13개의 파일을 삭제
  1. 1 1
      src/main/index.ts
  2. 2 2
      src/renderer/src/components/simulator/DiagramPanel.vue
  3. 14 10
      src/renderer/src/lib/speaker/echarts/diagramOption.ts

+ 1 - 1
src/main/index.ts

@@ -13,7 +13,7 @@ function createWindow(): void {
     autoHideMenuBar: true,
     ...(process.platform === 'linux' ? { icon } : {}),
     webPreferences: {
-      preload: join(__dirname, '../preload/index.cjs'),
+      preload: join(__dirname, '../preload/index.js'),
       sandbox: false
     }
   })

+ 2 - 2
src/renderer/src/components/simulator/DiagramPanel.vue

@@ -2,7 +2,7 @@
 import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
 import { useI18n } from 'vue-i18n'
 import { echarts } from '../../lib/speaker/echarts/install'
-import type { EChartsOption } from 'echarts/core'
+import type { EChartsCoreOption } from 'echarts/core'
 import type { CalcResult, SpeakerParams } from '../../lib/speaker/types'
 import { buildChartEmptyOption, buildDiagramOption } from '../../lib/speaker/echarts'
 import { useChartPalette } from '../../theme/useChartPalette'
@@ -32,7 +32,7 @@ const render = (): void => {
     vertical: t('diagram.vertical')
   }
   const pal = palette.value
-  const option: EChartsOption = props.result
+  const option: EChartsCoreOption = props.result
     ? buildDiagramOption(props.params, labels, pal)
     : buildChartEmptyOption(labels.empty, pal)
   chart.setOption(option, true)

+ 14 - 10
src/renderer/src/lib/speaker/echarts/diagramOption.ts

@@ -44,22 +44,26 @@ export function buildDiagramOption(
   const nearX = dNear >= 0 ? Math.min(maxD, Math.max(0, dNear)) : null
   const farX = dFar > 0 ? Math.min(maxD, dFar) : null
 
-  // 覆盖区域多边形(扬声器顶点 + 地面边界点,按 x 升序)
-  const poly: [number, number][] = [[0, z]]
-  const groundX = [nearX, farX].filter((v): v is number => v !== null).sort((a, b) => a - b)
-  groundX.forEach((x) => poly.push([x, 0]))
-
   const series: SeriesOption[] = []
 
-  // 覆盖区域填充(三角形)
-  if (groundX.length > 0) {
+  // 覆盖区域阴影:[0, z] + 地面交点围成的三角形
+  if (nearX !== null && farX !== null) {
+    // 按 X 轴坐标从小到大排序,避免折线图渲染时产生折返导致的填充错乱
+    const leftX = Math.min(nearX, farX)
+    const rightX = Math.max(nearX, farX)
+
     series.push({
       name: labels.coverage,
       type: 'line',
-      data: poly,
+      data: [
+        [0, z],
+        [leftX, 0],
+        [rightX, 0],
+        [0, z] // 显式闭合多边形,让 ECharts 准确填充内部
+      ],
       showSymbol: false,
-      lineStyle: { opacity: 0 },
-      areaStyle: { color: pal.accent, opacity: 0.07 },
+      lineStyle: { opacity: 0 }, // 隐藏边框线,只要填充
+      areaStyle: { color: pal.accent, opacity: 0.1 },
       silent: true,
       z: 2
     } as SeriesOption)