소스 검색

Merge remote-tracking branch 'origin/master' into zzx

学习?学个屁 3 주 전
부모
커밋
10c223e5f9
7개의 변경된 파일126개의 추가작업 그리고 102개의 파일을 삭제
  1. 1 1
      manifest.config.ts
  2. 75 74
      src/composables/useTheme.ts
  3. 2 2
      src/config/index.ts
  4. 8 4
      src/layouts/default.vue
  5. 34 17
      src/layouts/tabbar.vue
  6. 2 2
      src/manifest.json
  7. 4 2
      src/pages/index/index.vue

+ 1 - 1
manifest.config.ts

@@ -57,7 +57,7 @@ export default defineManifestConfig({
       urlCheck: false,
     },
     usingComponents: true,
-    darkmode: true,
+    darkmode: false,
     themeLocation: "theme.json",
     requiredPrivateInfos: ["getLocation"],
     permission: {

+ 75 - 74
src/composables/useTheme.ts

@@ -1,24 +1,24 @@
-import type { ConfigProviderThemeVars } from 'wot-design-uni'
+import type { ConfigProviderThemeVars } from "wot-design-uni";
 
 // 定义主题色选项
 export interface ThemeColorOption {
-  name: string
-  value: string
-  primary: string
+  name: string;
+  value: string;
+  primary: string;
 }
 
 // 预定义的主题色选项
 export const themeColorOptions: ThemeColorOption[] = [
-  { name: '默认蓝', value: 'blue', primary: '#4D7FFF' },
-  { name: '活力橙', value: 'orange', primary: '#FF7D00' },
-  { name: '薄荷绿', value: 'green', primary: '#07C160' },
-  { name: '樱花粉', value: 'pink', primary: '#FF69B4' },
-  { name: '紫罗兰', value: 'purple', primary: '#8A2BE2' },
-  { name: '朱砂红', value: 'red', primary: '#FF4757' },
-]
+  { name: "默认蓝", value: "blue", primary: "#4D7FFF" },
+  { name: "活力橙", value: "orange", primary: "#FF7D00" },
+  { name: "薄荷绿", value: "green", primary: "#07C160" },
+  { name: "樱花粉", value: "pink", primary: "#FF69B4" },
+  { name: "紫罗兰", value: "purple", primary: "#8A2BE2" },
+  { name: "朱砂红", value: "red", primary: "#FF4757" },
+];
 
 // 主题状态store
-const useThemeStore = defineStore('theme', {
+const useThemeStore = defineStore("theme", {
   state: () => ({
     theme: 'light' as 'light' | 'dark',
     followSystem: true, // 是否跟随系统主题
@@ -26,155 +26,156 @@ const useThemeStore = defineStore('theme', {
     currentThemeColor: themeColorOptions[0] as ThemeColorOption,
     showThemeColorSheet: false,
     themeVars: {
-      darkBackground: '#0f0f0f',
-      darkBackground2: '#1a1a1a',
-      darkBackground3: '#242424',
-      darkBackground4: '#2f2f2f',
-      darkBackground5: '#3d3d3d',
-      darkBackground6: '#4a4a4a',
-      darkBackground7: '#606060',
-      darkColor: '#ffffff',
-      darkColor2: '#e0e0e0',
-      darkColor3: '#a0a0a0',
+      darkBackground: "#0f0f0f",
+      darkBackground2: "#1a1a1a",
+      darkBackground3: "#242424",
+      darkBackground4: "#2f2f2f",
+      darkBackground5: "#3d3d3d",
+      darkBackground6: "#4a4a4a",
+      darkBackground7: "#606060",
+      darkColor: "#ffffff",
+      darkColor2: "#e0e0e0",
+      darkColor3: "#a0a0a0",
       colorTheme: themeColorOptions[0].primary,
     } as ConfigProviderThemeVars,
   }),
 
   getters: {
-    isDark: state => state.theme === 'dark',
+    isDark: (state) => state.theme === "dark",
   },
   actions: {
     /* 手动切换主题 */
-    toggleTheme(mode?: 'light' | 'dark') {
-      this.theme = mode || (this.theme === 'light' ? 'dark' : 'light')
-      this.hasUserSet = true // 标记用户已手动设置
-      this.followSystem = false // 不再跟随系统
-      this.setNavigationBarColor()
+    toggleTheme(mode?: "light" | "dark") {
+      this.theme = mode || (this.theme === "light" ? "dark" : "light");
+      this.hasUserSet = true; // 标记用户已手动设置
+      this.followSystem = false; // 不再跟随系统
+      this.setNavigationBarColor();
     },
 
     /* 设置是否跟随系统主题 */
     setFollowSystem(follow: boolean) {
-      this.followSystem = follow
+      console.log(follow, "  跟随系统");
+
+      this.followSystem = follow;
       if (follow) {
-        this.hasUserSet = false
-        this.initTheme() // 重新获取系统主题
+        this.hasUserSet = false;
+        this.initTheme(); // 重新获取系统主题
       }
     },
 
     /* 设置导航栏颜色 */
     setNavigationBarColor() {
       uni.setNavigationBarColor({
-        frontColor: this.theme === 'light' ? '#000000' : '#ffffff',
-        backgroundColor: this.theme === 'light' ? '#ffffff' : '#000000',
-      })
+        frontColor: this.theme === "light" ? "#000000" : "#ffffff",
+        backgroundColor: this.theme === "light" ? "#ffffff" : "#000000",
+      });
     },
 
     /* 设置主题色 */
     setCurrentThemeColor(color: ThemeColorOption) {
-      this.currentThemeColor = color
-      this.themeVars.colorTheme = color.primary
+      this.currentThemeColor = color;
+      this.themeVars.colorTheme = color.primary;
     },
 
     /* 获取系统主题 */
-    getSystemTheme(): 'light' | 'dark' {
+    getSystemTheme(): "light" | "dark" {
       try {
         // #ifdef MP-WEIXIN
         // 微信小程序使用 getAppBaseInfo
-        const appBaseInfo = uni.getAppBaseInfo()
+        const appBaseInfo = uni.getAppBaseInfo();
         if (appBaseInfo && appBaseInfo.theme) {
-          return appBaseInfo.theme as 'light' | 'dark'
+          return appBaseInfo.theme as "light" | "dark";
         }
         // #endif
 
         // #ifndef MP-WEIXIN
         // 其他平台使用 getSystemInfoSync
-        const systemInfo = uni.getSystemInfoSync()
+        const systemInfo = uni.getSystemInfoSync();
         if (systemInfo && systemInfo.theme) {
-          return systemInfo.theme as 'light' | 'dark'
+          return systemInfo.theme as "light" | "dark";
         }
         // #endif
+      } catch (error) {
+        console.warn("获取系统主题失败:", error);
       }
-      catch (error) {
-        console.warn('获取系统主题失败:', error)
-      }
-      return 'light' // 默认返回 light
+      return "light"; // 默认返回 light
     },
 
     /* 初始化主题 */
     initTheme() {
       // 如果用户已手动设置且不跟随系统,保持当前主题
       if (this.hasUserSet && !this.followSystem) {
-        console.log('使用用户设置的主题:', this.theme)
-        this.setNavigationBarColor()
-        return
+        console.log("使用用户设置的主题:", this.theme);
+        this.theme = "light";
+        this.setNavigationBarColor();
+        return;
       }
 
       // 获取系统主题
-      const systemTheme = this.getSystemTheme()
+      const systemTheme = this.getSystemTheme();
 
       // 如果是首次启动或跟随系统,使用系统主题
       if (!this.hasUserSet || this.followSystem) {
-        this.theme = systemTheme
+        this.theme = systemTheme;
         if (!this.hasUserSet) {
-          this.followSystem = true
-          console.log('首次启动,使用系统主题:', this.theme)
-        }
-        else {
-          console.log('跟随系统主题:', this.theme)
+          this.followSystem = true;
+          console.log("首次启动,使用系统主题:", this.theme);
+        } else {
+          console.log("跟随系统主题:", this.theme);
         }
       }
 
-      this.setNavigationBarColor()
+      this.setNavigationBarColor();
     },
   },
-})
+});
 
 export function useTheme() {
-  const store = useThemeStore()
-  const showThemeColorSheet = ref(false)
+  const store = useThemeStore();
+  const showThemeColorSheet = ref(false);
 
   /* 切换暗黑模式 */
-  function toggleTheme(mode?: 'light' | 'dark') {
-    store.toggleTheme(mode)
+  function toggleTheme(mode?: "light" | "dark") {
+    store.toggleTheme(mode);
   }
 
   /* 打开主题色选择 */
   function openThemeColorPicker() {
-    showThemeColorSheet.value = true
+    showThemeColorSheet.value = true;
   }
 
   /* 关闭主题色选择 */
   function closeThemeColorPicker() {
-    showThemeColorSheet.value = false
+    showThemeColorSheet.value = false;
   }
 
   /* 选择主题色 */
   function selectThemeColor(option: ThemeColorOption) {
-    store.setCurrentThemeColor(option)
-    closeThemeColorPicker()
+    store.setCurrentThemeColor(option);
+    closeThemeColorPicker();
   }
 
   /* 初始化theme */
   function initTheme() {
-    store.initTheme()
+    store.initTheme();
   }
 
   onBeforeMount(() => {
-    initTheme()
+    initTheme();
     if (CommonUtil.isFunction(uni.onThemeChange)) {
       uni.onThemeChange((res) => {
-        toggleTheme(res.theme)
-      })
+        toggleTheme(res.theme);
+      });
     }
-  })
+  });
 
   onUnmounted(() => {
     if (CommonUtil.isFunction(uni.offThemeChange)) {
       uni.offThemeChange((res) => {
-        toggleTheme(res.theme)
-      })
+        toggleTheme(res.theme);
+      });
     }
-  })
+  });
 
   return {
     theme: computed(() => store.theme),
@@ -190,5 +191,5 @@ export function useTheme() {
     openThemeColorPicker,
     closeThemeColorPicker,
     selectThemeColor,
-  }
+  };
 }

+ 2 - 2
src/config/index.ts

@@ -4,8 +4,8 @@ const mapEnvVersion = {
    */
   // develop: "http://192.168.1.166:8080/jeecg-boot",
   // develop: "http://192.168.0.217:8080/jeecg-boot",
-  // develop: "https://api.qlapp.cn/jeecgboot",
-  develop: "http://192.168.0.11:8080/jeecg-boot",
+  develop: "https://api.qlapp.cn/jeecgboot",
+  // develop: "http://192.168.0.11:8080/jeecg-boot",
   /**
    * 	体验版
    */

+ 8 - 4
src/layouts/default.vue

@@ -1,5 +1,5 @@
 <script lang="ts" setup>
-const { themeVars, theme } = useTheme()
+const { themeVars, theme } = useTheme();
 </script>
 
 <script lang="ts">
@@ -7,14 +7,18 @@ export default {
   options: {
     addGlobalClass: true,
     virtualHost: true,
-    styleIsolation: 'shared',
+    styleIsolation: "shared",
   },
-}
+};
 </script>
 
 <template>
   <!-- :theme-vars="themeVars" :theme="theme" :custom-class="`page-wraper ${theme}`"-->
-  <wd-config-provider>
+  <wd-config-provider
+    :theme-vars="themeVars"
+    :theme="theme"
+    :custom-class="`page-wraper ${theme}`"
+  >
     <slot />
     <wd-notify />
     <wd-message-box />

+ 34 - 17
src/layouts/tabbar.vue

@@ -1,27 +1,28 @@
 <script lang="ts" setup>
-const router = useRouter()
+const router = useRouter();
 
-const route = useRoute()
+const route = useRoute();
 
-const { themeVars, theme } = useTheme()
+const { themeVars, theme } = useTheme();
 
-const { activeTabbar, getTabbarItemValue, setTabbarItemActive, tabbarList } = useTabbar()
+const { activeTabbar, getTabbarItemValue, setTabbarItemActive, tabbarList } =
+  useTabbar();
 
 function handleTabbarChange({ value }: { value: string }) {
-  setTabbarItemActive(value)
-  router.pushTab({ name: value })
+  setTabbarItemActive(value);
+  router.pushTab({ name: value });
 }
 
 onMounted(() => {
   // #ifdef APP-PLUS
-  uni.hideTabBar()
+  uni.hideTabBar();
   // #endif
   nextTick(() => {
     if (route.name && route.name !== activeTabbar.value.name) {
-      setTabbarItemActive(route.name)
+      setTabbarItemActive(route.name);
     }
-  })
-})
+  });
+});
 </script>
 
 <script lang="ts">
@@ -29,19 +30,35 @@ export default {
   options: {
     addGlobalClass: true,
     virtualHost: true,
-    styleIsolation: 'shared',
+    styleIsolation: "shared",
   },
-}
+};
 </script>
 
 <template>
   <!-- :theme-vars="themeVars" :custom-class="`page-wraper ${theme}`" :theme="theme" -->
-  <wd-config-provider>
+  <wd-config-provider
+    :theme-vars="themeVars"
+    :theme="theme"
+    :custom-class="`page-wraper ${theme}`"
+  >
     <slot />
-    <wd-tabbar :model-value="activeTabbar.name" placeholder bordered safe-area-inset-bottom fixed
-      @change="handleTabbarChange">
-      <wd-tabbar-item v-for="(item, index) in tabbarList" :key="index" :name="item.name"
-        :value="getTabbarItemValue(item.name)" :title="item.title" :icon="item.icon" />
+    <wd-tabbar
+      :model-value="activeTabbar.name"
+      placeholder
+      bordered
+      safe-area-inset-bottom
+      fixed
+      @change="handleTabbarChange"
+    >
+      <wd-tabbar-item
+        v-for="(item, index) in tabbarList"
+        :key="index"
+        :name="item.name"
+        :value="getTabbarItemValue(item.name)"
+        :title="item.title"
+        :icon="item.icon"
+      />
     </wd-tabbar>
     <!-- #ifdef MP-WEIXIN -->
     <privacy-popup />

+ 2 - 2
src/manifest.json

@@ -47,7 +47,7 @@
       "urlCheck": false
     },
     "usingComponents": true,
-    "darkmode": true,
+    "darkmode": false,
     "themeLocation": "theme.json",
     "requiredPrivateInfos": [
       "getLocation"
@@ -79,4 +79,4 @@
     "darkmode": true,
     "themeLocation": "theme.json"
   }
-}
+}

+ 4 - 2
src/pages/index/index.vue

@@ -133,7 +133,9 @@ function getItemClass(path: string) {
         <view class="flex items-center px-40rpx header rounded-2xl h-162rpx" @click="handleCommenPath(item.route)"
           v-for="item in topMenu" :class="getItemClass(item.route)" :key="item.id">
           <image :src="getIcon(item.route)" class="w-100rpx h-100rpx"></image>
-          <view class="text-32rpx font-semibold">{{ item.name }}</view>
+          <view class="text-32rpx font-semibold text-#000">{{
+            item.name
+          }}</view>
         </view>
       </view>
       <view class="mt-3" v-if="sysMsg">
@@ -150,7 +152,7 @@ function getItemClass(path: string) {
           <view class="flex items-center justify-center flex-col" @click="handleCommenPath(item.route)"
             v-for="item in StoreMenu" :key="item.id">
             <image :src="getIcon(item.route)" class="w-52rpx h-52rpx"></image>
-            <view class="text-24rpx text-[rgb(0,0,0,0.6)] mt-3">{{
+            <view class="text-24rpx mt-3 text-[rgb(0,0,0,0.6)]">{{
               item.name
             }}</view>
           </view>