li.shaoyi 10 tháng trước cách đây
mục cha
commit
b476676161
2 tập tin đã thay đổi với 25 bổ sung3 xóa
  1. 24 0
      src/components/base/hqchart/index.vue
  2. 1 3
      src/stores/modules/global.ts

+ 24 - 0
src/components/base/hqchart/index.vue

@@ -45,7 +45,13 @@ Chart.JSConsole.Chart.Log = () => ({})
 Chart.JSConsole.Complier.Log = () => ({})
 
 const setChartStyle = (defaultTheme?: keyof typeof AppTheme) => {
+    const rootElement = document.documentElement
+    const computedStyles = window.getComputedStyle(rootElement)
+    const upBarColor = computedStyles.getPropertyValue('--color-up') // 上涨颜色
+    const downBarColor = computedStyles.getPropertyValue('--color-down') // 下跌颜色
+
     const chartEl = chartRef.value
+
     if (chartEl) {
         const jsChart = Chart.JSChart
         const hqChartStyle = Chart.HQChartStyle
@@ -56,12 +62,30 @@ const setChartStyle = (defaultTheme?: keyof typeof AppTheme) => {
         switch (theme) {
             case AppTheme.Dark: {
                 const blackStyle = hqChartStyle.GetStyleConfig(Chart.STYLE_TYPE_ID.BLACK_ID) // 黑色风格
+                blackStyle.UpBarColor = upBarColor
+                blackStyle.DownBarColor = downBarColor
+                blackStyle.UpTextColor = upBarColor
+                blackStyle.DownTextColor = downBarColor
+                blackStyle.FrameLatestPrice = {
+                    UpBarColor: upBarColor,
+                    DownBarColor: downBarColor
+                }
+
                 jsChart.SetStyle(blackStyle)
                 elStyle.setProperty('background-color', '#000')
                 break
             }
             default: {
                 const whiteStyle = hqChartStyle.GetStyleConfig(Chart.STYLE_TYPE_ID.WHITE_ID) // 白色风格
+                whiteStyle.UpBarColor = upBarColor
+                whiteStyle.DownBarColor = downBarColor
+                whiteStyle.UpTextColor = upBarColor
+                whiteStyle.DownTextColor = downBarColor
+                whiteStyle.FrameLatestPrice = {
+                    UpBarColor: upBarColor,
+                    DownBarColor: downBarColor
+                }
+
                 jsChart.SetStyle(whiteStyle)
                 elStyle.setProperty('background-color', '#fff')
             }

+ 1 - 3
src/stores/modules/global.ts

@@ -18,7 +18,6 @@ export interface SystemInfo {
     registrationCodeRule: -1 | 0 | 1; // 注册编码规则,-1=隐藏,0=非必填,1=必填
     riskType: 0 | 1 | 2; // 风控类型,1=按单风控,2=按账户风控
     i18nEnabled: boolean; // 是否启用多语言设置
-    priceColorType: 1 | 2; // 行情涨跌颜色类型,1=红涨绿跌,2=绿涨红跌
 }
 
 export const useGlobalStore = defineStore(() => {
@@ -44,8 +43,7 @@ export const useGlobalStore = defineStore(() => {
             forcedPasswordChange: false,
             registrationCodeRule: 1,
             riskType: 0,
-            i18nEnabled: true,
-            priceColorType: 1
+            i18nEnabled: true
         }
     })