Browse Source

🎨 按要求优化乡源树背景黑色问题

快乐的梦鱼 1 week ago
parent
commit
87ef53781c
1 changed files with 6 additions and 3 deletions
  1. 6 3
      src/pages/home/village/components/VillageTree.vue

+ 6 - 3
src/pages/home/village/components/VillageTree.vue

@@ -7,6 +7,7 @@
     :style="{
       width: systemInfo.windowWidth + 'px',
       height: HEIGHT + 'px',
+      backgroundColor: backgroundColor,
     }"
     @touchstart="render.events.handleTouchStart"
     @touchmove="render.events.handleTouchMove"
@@ -19,8 +20,9 @@
 import type { VillageTreeAnimProps } from '@/api/light/LightVillageApi';
 import { MiniRender } from '@/components/canvas/MiniRender';
 import { UniWeappRender } from '@/components/canvas/UniWeappRender';
+import { useTheme } from '@/components/theme/ThemeDefine';
 import { RandomUtils } from '@imengyu/imengyu-utils';
-import { getCurrentInstance, onBeforeUnmount, onMounted, watch } from 'vue';
+import { computed, getCurrentInstance, onBeforeUnmount, onMounted, watch } from 'vue';
 
 let treeMain : MiniRender.AnimateSprite | null = null;
 
@@ -40,7 +42,8 @@ const emit = defineEmits<{
   (e: 'fruitPick'): void;
 }>();
 
-
+const theme = useTheme();
+const backgroundColor = computed(() => theme.resolveThemeColor('background.primary'));
 
 const HEIGHT = 260;
 const instance = getCurrentInstance();
@@ -50,7 +53,7 @@ const render = new MiniRender.Scene(
     canvas: new UniWeappRender('villageTree', instance),
     width: systemInfo.windowWidth,
     height: HEIGHT,
-    backgroundColor: '#000',
+    backgroundColor: backgroundColor.value!,
   }, 
   async function() {
     const bg = new MiniRender.Sprite();