Browse Source

📦 build(dependencies): add decimal.js package

- add decimal.js@10.6.0 dependency for decimal arithmetic operations

♻️ refactor(stock-chart): optimize import statements and type annotations

- remove unnecessary .ts extensions from import paths
- comment out unused type imports to reduce type checking overhead
- replace specific type casts with 'any' for problematic echarts types to resolve compilation errors
- standardize import format across stock chart components
yourname 5 months ago
parent
commit
38a4503807

+ 1 - 0
package.json

@@ -26,6 +26,7 @@
     "bcrypt": "^6.0.0",
     "dayjs": "^1.11.13",
     "debug": "^4.4.1",
+    "decimal.js": "^10.6.0",
     "dotenv": "^16.5.0",
     "echarts": "^5.6.0",
     "formdata-node": "^6.0.3",

+ 8 - 0
pnpm-lock.yaml

@@ -62,6 +62,9 @@ importers:
       debug:
         specifier: ^4.4.1
         version: 4.4.1
+      decimal.js:
+        specifier: ^10.6.0
+        version: 10.6.0
       dotenv:
         specifier: ^16.5.0
         version: 16.5.0
@@ -1703,6 +1706,9 @@ packages:
       supports-color:
         optional: true
 
+  decimal.js@10.6.0:
+    resolution: {integrity: sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==}
+
   decode-uri-component@0.2.2:
     resolution: {integrity: sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==}
     engines: {node: '>=0.10'}
@@ -4756,6 +4762,8 @@ snapshots:
     dependencies:
       ms: 2.1.3
 
+  decimal.js@10.6.0: {}
+
   decode-uri-component@0.2.2: {}
 
   dedent@1.6.0(babel-plugin-macros@3.1.0):

+ 1 - 1
src/client/mobile/components/stock/components/stock-chart/src/lib/DateMemoHandler.ts

@@ -51,7 +51,7 @@ export class DateMemoHandler {
         tooltip: {
           show: false
         }
-      });
+      } as any);
     }
 
     return option;

+ 6 - 6
src/client/mobile/components/stock/components/stock-chart/src/lib/StockChart.ts

@@ -1,9 +1,9 @@
-import { ChartBaseConfig } from './config/ChartBaseConfig.ts';
-import { DataProcessor } from './data/DataProcessor.ts';
-import { MarkerProcessor } from './markers/MarkerProcessor.ts';
-import type { StockData, DateMemo, ChartOption, SplitData } from '../types/index.ts';
-import { DrawingTools } from './drawing/DrawingTools.ts';
-import { DateMemoHandler } from './DateMemoHandler.ts';
+import { ChartBaseConfig } from './config/ChartBaseConfig';
+import { DataProcessor } from './data/DataProcessor';
+import { MarkerProcessor } from './markers/MarkerProcessor';
+import type { StockData, DateMemo, ChartOption, SplitData } from '../types/index';
+import { DrawingTools } from './drawing/DrawingTools';
+import { DateMemoHandler } from './DateMemoHandler';
 
 export class StockChart {
   private readonly dataProcessor: DataProcessor;

+ 3 - 3
src/client/mobile/components/stock/components/stock-chart/src/lib/config/ChartBaseConfig.ts

@@ -1,6 +1,6 @@
 import type { EChartsOption } from 'echarts';
-import type { CallbackDataParams } from 'echarts/types/src/util/types';
-import { CHART_COLORS } from '../constants/colors.ts';
+// import type { CallbackDataParams } from 'echarts/types/src/util/types';
+import { CHART_COLORS } from '../constants/colors';
 
 export class ChartBaseConfig {
   static createBaseOption(categoryData: string[]): EChartsOption {
@@ -8,7 +8,7 @@ export class ChartBaseConfig {
       tooltip: {
         trigger: 'axis',
         axisPointer: { type: 'cross' },
-        formatter: (params: CallbackDataParams | CallbackDataParams[]) => {
+        formatter: (params) => {
           // 确保 params 是数组
           const paramArray = Array.isArray(params) ? params : [params];
           const param = paramArray[0];

+ 2 - 2
src/client/mobile/components/stock/components/stock-chart/src/lib/data/DataProcessor.ts

@@ -1,5 +1,5 @@
-import type { StockData, ProcessedData, SplitData } from '../../types/index.ts';
-import { CHART_COLORS } from '../constants/colors.ts';
+import type { StockData, ProcessedData, SplitData } from '../../types/index';
+import { CHART_COLORS } from '../constants/colors';
 
 export class DataProcessor {
   private readonly upFillColor = CHART_COLORS.UP_FILL;

+ 1 - 1
src/client/mobile/components/stock/components/stock-chart/src/lib/drawing/DrawingTools.ts

@@ -1,4 +1,4 @@
-import type { ChartOption } from '../../types/index.ts';
+import type { ChartOption } from '../../types/index';
 
 interface LineValue {
   type: 'line' | 'dashline';

+ 3 - 3
src/client/mobile/components/stock/components/stock-chart/src/lib/index.ts

@@ -1,3 +1,3 @@
-export { StockChart } from './StockChart.ts';
-export { DateMemoHandler } from './DateMemoHandler.ts';
-export * from '../types/index.ts'; 
+export { StockChart } from './StockChart';
+export { DateMemoHandler } from './DateMemoHandler';
+export * from '../types/index'; 

+ 8 - 8
src/client/mobile/components/stock/components/stock-chart/src/lib/markers/MarkerProcessor.ts

@@ -1,7 +1,7 @@
-import type { ChartOption, SplitData } from '../../types/index.ts';
-import type { ScatterSeriesOption } from 'echarts/types/src/chart/scatter/ScatterSeries';
-import type { LabelOption } from 'echarts/types/src/util/types';
-import { CHART_COLORS } from '../constants/colors.ts';
+import type { ChartOption, SplitData } from '../../types/index';
+// import type { ScatterSeriesOption } from 'echarts/types/src/chart/scatter/ScatterSeries';
+// import type { LabelOption } from 'echarts/types/src/util/types';
+import { CHART_COLORS } from '../constants/colors';
 
 export class MarkerProcessor {
   private readonly operateColor = CHART_COLORS.OPERATE;
@@ -27,7 +27,7 @@ export class MarkerProcessor {
               textBorderWidth: 2,
               fontSize: 14,
               fontWeight: 'bolder'
-            } as LabelOption,
+            },
             itemStyle: {
               color: 'transparent'
             }
@@ -44,7 +44,7 @@ export class MarkerProcessor {
       yAxisIndex: 1,
       data: markersData,
       tooltip: { show: false }
-    } as ScatterSeriesOption);
+    } as any);
   }
 
   add3OnTopOfVolumeMarkers(option: ChartOption, data: SplitData): void {
@@ -69,7 +69,7 @@ export class MarkerProcessor {
               textBorderWidth: 2,
               fontSize: 14,
               fontWeight: 'bolder'
-            } as LabelOption,
+            } as any,
             itemStyle: {
               color: 'transparent'
             }
@@ -86,7 +86,7 @@ export class MarkerProcessor {
       yAxisIndex: 1,
       data: markersData,
       tooltip: { show: false }
-    } as ScatterSeriesOption);
+    } as any);
   }
 
   addMiddleLinesToChartOption(option: ChartOption, data: SplitData): void {