Selaa lähdekoodia

webview联调

shmily1213 4 viikkoa sitten
vanhempi
commit
077d1b6361

+ 36 - 2
index.html

@@ -15,15 +15,49 @@
   <title></title>
   <!--preload-links-->
   <!--app-context-->
-  <!-- <script src="https://unpkg.com/vconsole@3.15.1/dist/vconsole.min.js"></script>
+  
+  <script src="https://unpkg.com/vconsole@3.15.1/dist/vconsole.min.js"></script>
   <script>
     const vconsole = new VConsole();
-  </script> -->
+  </script>
 </head>
 
 <body>
   <div id="app"><!--app-html--></div>
   <script type="module" src="/src/main.ts"></script>
 </body>
+<script>
+  document.addEventListener('UniAppJSBridgeReady', function () {
+    uni.webView.postMessage({
+      data: {
+        action: 'setPlatform'
+      }
+    });
+    window.backup = (from) => {
+      if (from === 'backbutton') {
+        const routes = getCurrentPages();
+        const route = routes[routes.length - 1].route;
+        if ([
+          'pagesMain/pages/index/index',
+          'pagesMain/pages/volunteer/volunteer',
+          'pagesMain/pages/me/me'
+        ].includes(route)) {
+          uni.webView.postMessage({
+            data: {
+              action: 'quit'
+            }
+          });
+        } else {
+          uni.navigateBack();
+        }
+      }
+    };
+    // 默认为h5平台
+    window.platform = 'h5';
+    window.setPlatform = (platform) => {
+      window.platform = platform;
+    };
+  });
+</script>
 
 </html>

+ 0 - 95
src/common/webview.bridge.js

@@ -1,95 +0,0 @@
-
-const WebviewEvents = {
-  /**
-   *  获取平台信息
-   */
-  GET_PLATFORM: 'getPlatform',
-  /**
-  *  获取状态栏高度
-  */
-  GET_STATUS_BAR_HEIGHT: 'getStatusBarHeight',
-  /**
-   * 扫码
-   */
-  SCAN: 'scan',
-  /**
-   * 苹果支付
-   */
-  APPLE_PAY: 'applePay',
-  APPLE_PAY_RESTORE: 'applePayRestore',
-  // 微信是否安装
-  CHECK_WECHAT_INSTALLED: 'checkWechatInstalled',
-  GET_UPGRADE_INFO: 'getUpgradeInfo',
-  DOWNLOAD_UPGRADE: 'downloadAndInstall',
-  OPEN_IFRAME: 'openIframe'
-}
-function resetWindowCallback(callbackEvent) {
-  window[callbackEvent] = null;
-  delete window[callbackEvent];
-}
-async function getWebviewCallback(event, args) {
-  if (!uni.webView) {
-    return Promise.reject(new Error('uni环境异常,请检查uni.webview是否正确引入'));
-  }
-  if (window.platform === 'h5') {
-    return Promise.reject(new Error('请在app中使用'));
-  }
-  const callbackEvent = `webviewCallback_${event}`;
-  try {
-    return await new Promise((resolve, reject) => {
-      window[callbackEvent] = (data) => {
-        resolve(data);
-        resetWindowCallback(callbackEvent);
-      };
-      uni.webView.postMessage({
-        data: {
-          action: event,
-          data: {
-            callbackAction: callbackEvent,
-            data: args
-          }
-        }
-      });
-    });
-  } catch (error) {
-    return Promise.reject(new Error('webview初始化失败,请检查是否正确引入uni.webview'));
-  }
-}
-
-class WebviewBridge {
-  constructor() { }
-  getPaltform() {
-    return getWebviewCallback(WebviewEvents.GET_PLATFORM);
-  }
-  scan(...args) {
-    return getWebviewCallback(WebviewEvents.SCAN, args);
-  }
-  applePay(...args) {
-    return getWebviewCallback(WebviewEvents.APPLE_PAY, args);
-  }
-  applePayRestore(...args) {
-    return getWebviewCallback(WebviewEvents.APPLE_PAY_RESTORE, args);
-  }
-  checkWechatInstalled(...args) {
-    return getWebviewCallback(WebviewEvents.CHECK_WECHAT_INSTALLED, args);
-  }
-  getStatusBarHeight() {
-    return getWebviewCallback(WebviewEvents.GET_STATUS_BAR_HEIGHT);
-  }
-  getUpgradeInfo(...args) {
-    return getWebviewCallback(WebviewEvents.GET_UPGRADE_INFO, args);
-  }
-  openIframe(...args) {
-    return getWebviewCallback(WebviewEvents.OPEN_IFRAME, args);
-  }
-  downloadUpgrade(url, progressCb) {
-    window.onDownloadProgress = progressCb;
-    return getWebviewCallback(WebviewEvents.DOWNLOAD_UPGRADE, {
-      url,
-      progressCb: 'onDownloadProgress'
-    });
-  }
-}
-
-const webviewBridge = new WebviewBridge();
-window.webviewBridge = webviewBridge;

+ 230 - 0
src/common/webview.bridge.ts

@@ -0,0 +1,230 @@
+// WebView 事件类型定义
+const WebviewEvents = {
+  /**
+   * 获取平台信息
+   */
+  GET_PLATFORM: 'getPlatform',
+  /**
+   * 获取状态栏高度
+   */
+  GET_STATUS_BAR_HEIGHT: 'getStatusBarHeight',
+  /**
+   * 扫码
+   */
+  SCAN: 'scan',
+  /**
+   * 苹果支付
+   */
+  APPLE_PAY: 'applePay',
+  APPLE_PAY_RESTORE: 'applePayRestore',
+  /**
+   * 微信是否安装
+   */
+  CHECK_WECHAT_INSTALLED: 'checkWechatInstalled',
+  /**
+   * 获取升级信息
+   */
+  GET_UPGRADE_INFO: 'getUpgradeInfo',
+  /**
+   * 下载升级
+   */
+  DOWNLOAD_UPGRADE: 'downloadAndInstall',
+  /**
+   * 打开 iframe
+   */
+  OPEN_IFRAME: 'openIframe'
+} as const;
+
+// 定义 WebView 事件键类型
+type WebviewEventKey = keyof typeof WebviewEvents;
+type WebviewEventValue = typeof WebviewEvents[WebviewEventKey];
+
+// 定义 uni.webView 类型
+interface UniWebView {
+  postMessage: (options: {
+    data: {
+      action: string;
+      data: {
+        callbackAction: string;
+        data?: any;
+      };
+    };
+  }) => void;
+}
+
+// 扩展 uni 命名空间
+declare global {
+  interface Uni {
+    webView?: UniWebView;
+  }
+
+  // 扩展 Window 接口
+  interface Window {
+    // 平台标识
+    platform?: string;
+    // WebView Bridge 实例
+    webviewBridge: WebviewBridge;
+    // 下载进度回调
+    onDownloadProgress?: (progress: any) => void;
+    // 动态回调函数
+    [key: `webviewCallback_${string}`]: ((data: any) => void) | undefined;
+  }
+}
+
+/**
+ * 重置 window 回调函数
+ * @param callbackEvent 回调事件名称
+ */
+function resetWindowCallback(callbackEvent: string): void {
+  const key = callbackEvent as keyof Window;
+  if (window[key]) {
+    window[key] = undefined as never;
+    delete window[key];
+  }
+}
+
+/**
+ * 获取 WebView 回调
+ * @param event 事件名称
+ * @param args 参数
+ * @returns Promise
+ */
+async function getWebviewCallback<T = any>(
+  event: string,
+  args?: any
+): Promise<T> {
+  if (!uni.webView) {
+    return Promise.reject(new Error('uni环境异常,请检查uni.webview是否正确引入'));
+  }
+  
+  if (window.platform === 'h5') {
+    return Promise.reject(new Error('请在app中使用'));
+  }
+
+  const callbackEvent = `webviewCallback_${event}`;
+  
+  try {
+    return await new Promise<T>((resolve, reject) => {
+      // 设置回调函数
+      (window as any)[callbackEvent] = (data: T) => {
+        resolve(data);
+        resetWindowCallback(callbackEvent);
+      };
+
+      // 发送消息到 WebView
+      uni.webView?.postMessage({
+        data: {
+          action: event,
+          data: {
+            callbackAction: callbackEvent,
+            data: args
+          }
+        }
+      });
+    });
+  } catch (error) {
+    return Promise.reject(new Error('webview初始化失败,请检查是否正确引入uni.webview'));
+  }
+}
+
+/**
+ * WebView Bridge 类
+ * 用于与原生 App 进行通信
+ */
+class WebviewBridge {
+  constructor() {}
+
+  /**
+   * 获取平台信息
+   * @returns Promise<string>
+   */
+  getPaltform(): Promise<string> {
+    return getWebviewCallback<string>(WebviewEvents.GET_PLATFORM);
+  }
+
+  /**
+   * 扫码功能
+   * @param args 扫码参数
+   * @returns Promise
+   */
+  scan(...args: any[]): Promise<any> {
+    return getWebviewCallback(WebviewEvents.SCAN, args);
+  }
+
+  /**
+   * 苹果支付
+   * @param args 支付参数
+   * @returns Promise
+   */
+  applePay(...args: any[]): Promise<any> {
+    return getWebviewCallback(WebviewEvents.APPLE_PAY, args);
+  }
+
+  /**
+   * 苹果支付恢复
+   * @param args 恢复参数
+   * @returns Promise
+   */
+  applePayRestore(...args: any[]): Promise<any> {
+    return getWebviewCallback(WebviewEvents.APPLE_PAY_RESTORE, args);
+  }
+
+  /**
+   * 检查微信是否已安装
+   * @param args 参数
+   * @returns Promise<boolean>
+   */
+  checkWechatInstalled(...args: any[]): Promise<boolean> {
+    return getWebviewCallback<boolean>(WebviewEvents.CHECK_WECHAT_INSTALLED, args);
+  }
+
+  /**
+   * 获取状态栏高度
+   * @returns Promise<number>
+   */
+  getStatusBarHeight(): Promise<number> {
+    return getWebviewCallback<number>(WebviewEvents.GET_STATUS_BAR_HEIGHT);
+  }
+
+  /**
+   * 获取升级信息
+   * @param args 参数
+   * @returns Promise
+   */
+  getUpgradeInfo(...args: any[]): Promise<any> {
+    return getWebviewCallback(WebviewEvents.GET_UPGRADE_INFO, args);
+  }
+
+  /**
+   * 打开 iframe
+   * @param args 参数
+   * @returns Promise
+   */
+  openIframe(...args: any[]): Promise<any> {
+    return getWebviewCallback(WebviewEvents.OPEN_IFRAME, args);
+  }
+
+  /**
+   * 下载升级包
+   * @param url 下载地址
+   * @param progressCb 进度回调函数
+   * @returns Promise
+   */
+  downloadUpgrade(url: string, progressCb?: (progress: any) => void): Promise<any> {
+    if (progressCb) {
+      window.onDownloadProgress = progressCb;
+    }
+    return getWebviewCallback(WebviewEvents.DOWNLOAD_UPGRADE, {
+      url,
+      progressCb: 'onDownloadProgress'
+    });
+  }
+}
+
+// 创建实例并挂载到 window
+const webviewBridge = new WebviewBridge();
+window.webviewBridge = webviewBridge;
+
+export default webviewBridge;
+export { WebviewBridge, WebviewEvents };
+

+ 13 - 11
src/components/ie-navbar/ie-navbar.vue

@@ -17,9 +17,11 @@
 <script lang="ts" setup>
 import { useTransferPage } from "@/hooks/useTransferPage";
 import { useScroll } from '@/hooks/useScroll';
+import { useAppStore } from "@/store/appStore";
 const { transferBack } = useTransferPage();
 const { scrollTop } = useScroll();
 const isTransparent = ref(false);
+const appStore = useAppStore();
 /**
  * ie-navbar 导航栏组件
  * @description 导航栏组件
@@ -36,17 +38,17 @@ const isTransparent = ref(false);
  */
 
 type NavbarOptions = {
-  title: string;
-  bgColor: string;
-  titleColor: string;
-  fixed: boolean;
-  placeholder: boolean;
-  opacity: boolean;
-  transparent: boolean;
-  keepTitleColor: boolean;
-  customBack: boolean;
-  clickHover: boolean;
-  titleStyle: any;
+  title?: string;
+  bgColor?: string;
+  titleColor?: string;
+  fixed?: boolean;
+  placeholder?: boolean;
+  opacity?: boolean;
+  transparent?: boolean;
+  keepTitleColor?: boolean;
+  customBack?: boolean;
+  clickHover?: boolean;
+  titleStyle?: any;
 }
 const props = withDefaults(defineProps<NavbarOptions>(), {
   fixed: true,

+ 12 - 18
src/components/ie-page/ie-page.vue

@@ -19,25 +19,20 @@ import { CLOSE_VIP_POPUP, OPEN_VIP_POPUP } from '@/types/injectionSymbols';
 import VipPopup from './components/vip-popup.vue';
 defineOptions({
   name: 'ie-page',
-  // 注意:virtualHost: true 会导致 provide/inject 失效
-  // options: {
-  //   virtualHost: true
-  // }
-});
-const props = defineProps({
-  safeAreaInsetBottom: {
-    type: Boolean,
-    default: true
-  },
-  bgColor: {
-    type: String,
-    default: ''
-  },
-  fixHeight: {
-    type: Boolean,
-    default: false
+  options: {
+    virtualHost: true
   }
 });
+type PageProps = {
+  safeAreaInsetBottom: boolean;
+  bgColor: string;
+  fixHeight: boolean;
+}
+const props = withDefaults(defineProps<PageProps>(), {
+  safeAreaInsetBottom: true,
+  bgColor: '',
+  fixHeight: false
+});
 // 为 ref 添加类型定义
 const vipPopupRef = ref<InstanceType<typeof VipPopup>>();
 
@@ -71,7 +66,6 @@ defineExpose({
   showVipPopup,
   closeVipPopup
 });
-
 onMounted(() => {
   // console.log('ie-page mounted, vipPopupRef.value:', vipPopupRef.value);
   // uni.$on('showVipPopup', showVipPopup);

+ 7 - 3
src/main.ts

@@ -2,8 +2,8 @@
 import App from './App'
 import uvUiTools from "@/uni_modules/uv-ui-tools";
 // #ifdef H5
-import "@/uni.webview.1.5.4"
-import './common/webview.bridge.js'
+import "@/uni.webview.1.5.6"
+import './common/webview.bridge'
 // #endif
 import { useRequest } from '@/utils/request'
 import tool from '@/utils/uni-tool'
@@ -48,7 +48,11 @@ export function createApp() {
       },
       navbar: {
         placeholder: { default: true },
-        clickHover: { default: true }
+        clickHover: { default: true },
+        statusBarHeight: { default: 0 }
+      },
+      statusBar: {
+        statusBarHeight: { default: 0 }
       },
       tabs: {
         activeStyle: { default: () => ({ color: 'var(--primary-color)' }) }

+ 34 - 24
src/pagesMain/pages/index/components/index-popup.vue

@@ -1,31 +1,41 @@
 <template>
-  <root-portal>
-    <uv-popup ref="popupRef" mode="bottom" :round="16" :closeOnClickOverlay="false">
-      <view class="popup-content">
-        <view class="p-40">
-          <view class="text-32 text-fore-title font-bold">请确认信息</view>
-          <view class="mt-10 text-26 text-fore-light">让我们开始体验升学备考之旅吧!</view>
-        </view>
-        <view class="mx-30 pb-50">
-          <view class="flex items-center px-42 bg-back rounded-40 h-104 box-border">
-            <view class="flex-shrink-0">所在省份</view>
-            <ie-picker ref="pickerRef" v-model="form.location" :list="provinceList" :customStyle="customStyle"
-              placeholder="请选择" key-label="dictLabel" key-value="dictValue">
-            </ie-picker>
-          </view>
-          <view class="mt-30 flex items-center px-42 bg-back rounded-40 h-104 box-border">
-            <view class="flex-shrink-0">考生类别</view>
-            <ie-picker ref="pickerRef" v-model="form.examType" :list="examTypeList" :disabled="!form.location"
-              :customStyle="customStyle" placeholder="请选择" key-label="dictLabel" key-value="dictValue">
-            </ie-picker>
+  <!-- #ifdef H5 -->
+  <teleport to="body">
+    <!-- #endif -->
+    <!-- #ifdef MP-WEIXIN -->
+    <root-portal externalClass="theme-ie">
+      <!-- #endif -->
+      <uv-popup ref="popupRef" mode="bottom" :round="16" :closeOnClickOverlay="false">
+        <view class="popup-content">
+          <view class="p-40">
+            <view class="text-32 text-fore-title font-bold">请确认信息</view>
+            <view class="mt-10 text-26 text-fore-light">让我们开始体验升学备考之旅吧!</view>
           </view>
-          <view class="mt-140">
-            <ie-button type="primary" @click="handleConfirm">立即体验</ie-button>
+          <view class="mx-30 pb-50">
+            <view class="flex items-center px-42 bg-back rounded-40 h-104 box-border">
+              <view class="flex-shrink-0">所在省份</view>
+              <ie-picker ref="pickerRef" v-model="form.location" :list="provinceList" :customStyle="customStyle"
+                placeholder="请选择" key-label="dictLabel" key-value="dictValue">
+              </ie-picker>
+            </view>
+            <view class="mt-30 flex items-center px-42 bg-back rounded-40 h-104 box-border">
+              <view class="flex-shrink-0">考生类别</view>
+              <ie-picker ref="pickerRef" v-model="form.examType" :list="examTypeList" :disabled="!form.location"
+                :customStyle="customStyle" placeholder="请选择" key-label="dictLabel" key-value="dictValue">
+              </ie-picker>
+            </view>
+            <view class="mt-140">
+              <ie-button type="primary" @click="handleConfirm">立即体验</ie-button>
+            </view>
           </view>
         </view>
-      </view>
-    </uv-popup>
-  </root-portal>
+      </uv-popup>
+      <!-- #ifdef MP-WEIXIN -->
+    </root-portal>
+    <!-- #endif -->
+    <!-- #ifdef H5 -->
+  </teleport>
+  <!-- #endif -->
 </template>
 <script lang="ts" setup>
 import { useExamType } from '@/composables/useExamType';

+ 3 - 0
src/pagesMain/pages/splash/splash.vue

@@ -22,6 +22,9 @@ const imgLaunch = computed(() => {
   return config.ossUrl + '/launch.png'
 });
 const handleLoad = () => {
+  window.webviewBridge.getStatusBarHeight().then(height => {
+    appStore.statusBarHeight = height;
+  });
   // 执行初始化的操作:预加载字典、提前校验token是否有效等
   appStore.init().then(() => {
     setTimeout(() => {

+ 60 - 49
src/pagesStudy/components/practice-table.vue

@@ -11,16 +11,17 @@
           </ie-picker>
         </view>
         <view class="picker-wrap">
-          <ie-picker ref="pickerRef" :disabled="!form.year" v-model="form.month" :list="monthList" placeholder="请选择" title="选择月份"
-            :fontSize="26" icon="arrow-down" key-label="label" key-value="value" @change="handleMonthChange">
+          <ie-picker ref="pickerRef" :disabled="!form.year" v-model="form.month" :list="monthList" placeholder="请选择"
+            title="选择月份" :fontSize="26" icon="arrow-down" key-label="label" key-value="value"
+            @change="handleMonthChange">
             <template #default="{ label }">
               <text>第{{ label }}</text>
             </template>
           </ie-picker>
         </view>
         <view class="picker-wrap">
-          <ie-picker ref="pickerRef" :disabled="!form.month" v-model="form.week" :list="weekList" placeholder="请选择" title="选择周" :fontSize="26"
-            icon="arrow-down" key-label="label" key-value="value" @change="handleWeekChange">
+          <ie-picker ref="pickerRef" :disabled="!form.month" v-model="form.week" :list="weekList" placeholder="请选择"
+            title="选择周" :fontSize="26" icon="arrow-down" key-label="label" key-value="value" @change="handleWeekChange">
             <template #default="{ label }">
               <text>{{ label }}</text>
             </template>
@@ -58,56 +59,66 @@
         </template>
       </ie-table>
     </view>
-    <root-portal>
-      <uv-popup ref="calendarPopupRef" mode="bottom" :round="16" v-if="canOpenCalendar">
-        <view class="h-[480px]">
-          <view class="h-108 flex items-center justify-center border-0 border-b border-solid border-border">
-            <view :class="prevButtonClass" @click="canGoPrev && !loading ? handlePrev() : null">
-              <uv-icon name="arrow-left" size="10" :color="canGoPrev && !loading ? '#808080' : '#CCCCCC'" />
-            </view>
-            <view class="mx-40 text-30 text-fore-title font-bold">
-              <text>{{ calendarTitle }}</text>
-            </view>
-            <view :class="nextButtonClass" @click="canGoNext && !loading ? handleNext() : null">
-              <uv-icon name="arrow-right" size="10" :color="canGoNext && !loading ? '#808080' : '#CCCCCC'" />
-            </view>
-          </view>
-          <view class="relative">
-            <view class="px-40 py-20 flex items-center justify-between">
-              <view class=" text-28">
-                <text>{{ calendarSubTitle }}</text>
-                <text class="text-32 text-primary font-bold">{{ practiceDate }}</text>
-                <text>天~</text>
+    <!-- #ifdef H5 -->
+    <teleport to="body">
+      <!-- #endif -->
+      <!-- #ifdef MP-WEIXIN -->
+      <root-portal externalClass="theme-ie">
+        <!-- #endif -->
+        <uv-popup ref="calendarPopupRef" mode="bottom" :round="16" v-if="canOpenCalendar">
+          <view class="h-[480px]">
+            <view class="h-108 flex items-center justify-center border-0 border-b border-solid border-border">
+              <view :class="prevButtonClass" @click="canGoPrev && !loading ? handlePrev() : null">
+                <uv-icon name="arrow-left" size="10" :color="canGoPrev && !loading ? '#808080' : '#CCCCCC'" />
+              </view>
+              <view class="mx-40 text-30 text-fore-title font-bold">
+                <text>{{ calendarTitle }}</text>
+              </view>
+              <view :class="nextButtonClass" @click="canGoNext && !loading ? handleNext() : null">
+                <uv-icon name="arrow-right" size="10" :color="canGoNext && !loading ? '#808080' : '#CCCCCC'" />
               </view>
-              <uv-icon name="question-circle" size="18" color="#31a0fc" />
             </view>
+            <view class="relative">
+              <view class="px-40 py-20 flex items-center justify-between">
+                <view class=" text-28">
+                  <text>{{ calendarSubTitle }}</text>
+                  <text class="text-32 text-primary font-bold">{{ practiceDate }}</text>
+                  <text>天~</text>
+                </view>
+                <uv-icon name="question-circle" size="18" color="#31a0fc" />
+              </view>
 
-            <uni-calendar ref="calendarRef" :insert="true" :lunar="false" :readonly="true" :showMonth="false"
-              :sundayFirst="false" :highlightToday="false" :showToolbar="false" :displayMode="displayMode"
-              :weekNumber="calendarWeekNumber" :selected="[]" :date="currentDate"
-              @change-week="handleCalendarWeekChange" @monthSwitch="handleCalendarMonthSwitch">
-              <template #calendar-item="{ weeks }">
-                <view class="calendar-item" :class="{
-                  'calendar-item--week-mode-disabled': weeks.isWeekModeDisabled,
-                  'uni-calendar-item--disable': !weeks.isCurrentMonth,
-                  'calendar-item--valid': weeks.extraInfo && weeks.extraInfo.info >= 0.7,
-                  'calendar-item--invalid': weeks.extraInfo && weeks.extraInfo.info < 0.7
-                }">
-                  <view class="date">{{ weeks.date }}</view>
-                  <view class="info">
-                    <text v-if="weeks.extraInfo && weeks.extraInfo.info">{{ weeks.extraInfo.info * 100 }}%</text>
+              <uni-calendar ref="calendarRef" :insert="true" :lunar="false" :readonly="true" :showMonth="false"
+                :sundayFirst="false" :highlightToday="false" :showToolbar="false" :displayMode="displayMode"
+                :weekNumber="calendarWeekNumber" :selected="[]" :date="currentDate"
+                @change-week="handleCalendarWeekChange" @monthSwitch="handleCalendarMonthSwitch">
+                <template #calendar-item="{ weeks }">
+                  <view class="calendar-item" :class="{
+                    'calendar-item--week-mode-disabled': weeks.isWeekModeDisabled,
+                    'uni-calendar-item--disable': !weeks.isCurrentMonth,
+                    'calendar-item--valid': weeks.extraInfo && weeks.extraInfo.info >= 0.7,
+                    'calendar-item--invalid': weeks.extraInfo && weeks.extraInfo.info < 0.7
+                  }">
+                    <view class="date">{{ weeks.date }}</view>
+                    <view class="info">
+                      <text v-if="weeks.extraInfo && weeks.extraInfo.info">{{ weeks.extraInfo.info * 100 }}%</text>
+                    </view>
                   </view>
-                </view>
-              </template>
-            </uni-calendar>
-            <!-- Loading 覆盖层 -->
-            <view v-if="loading" class="calendar-loading-overlay">
-              <uv-loading-icon mode="circle" size="32" color="#31a0fc" />
+                </template>
+              </uni-calendar>
+              <!-- Loading 覆盖层 -->
+              <view v-if="loading" class="calendar-loading-overlay">
+                <uv-loading-icon mode="circle" size="32" color="#31a0fc" />
+              </view>
             </view>
           </view>
-        </view>
-      </uv-popup>
-    </root-portal>
+        </uv-popup>
+        <!-- #ifdef MP-WEIXIN -->
+      </root-portal>
+      <!-- #endif -->
+      <!-- #ifdef H5 -->
+    </teleport>
+    <!-- #endif -->
   </view>
 </template>
 <script lang="ts" setup>
@@ -115,7 +126,7 @@ import { nextTick } from 'vue';
 import { TableColumnConfig } from '@/types';
 import ieEchart from './ie-echart/ie-echart.vue';
 import { useCalendar } from '@/composables/useCalendar';
-const props = defineProps<{ 
+const props = defineProps<{
   studentId: number;
 }>();
 // 使用 useCalendar composable

+ 1 - 0
src/store/appStore.ts

@@ -13,6 +13,7 @@ export const useAppStore = defineStore('ie-app', {
     return {
       isInitialized: false,
       activeTabbar: 0,
+      statusBarHeight: 0,
       sysInfo: null as UniApp.GetSystemInfoResult | null,
       appConfig: [] as ConfigItem[],
       provinceList: [] as DictItem[],

+ 1 - 0
src/types/index.ts

@@ -63,6 +63,7 @@ export interface TableColumnConfig {
 export interface AppStoreState {
   isInitialized: boolean;
   activeTabbar: number;
+  statusBarHeight: number;
   sysInfo: UniApp.GetSystemInfoResult | null;
   appConfig: ConfigItem[];
   provinceList: DictItem[];

+ 0 - 209
src/uni.webview.1.5.4.js

@@ -1,209 +0,0 @@
-! function(e, n) {
-	"object" == typeof exports && "undefined" != typeof module ? module.exports = n() : "function" == typeof define &&
-		define.amd ? define(n) : (e = e || self).webUni = n()
-}(this, (function() {
-	"use strict";
-	try {
-		var e = {};
-		Object.defineProperty(e, "passive", {
-			get: function() {
-				!0
-			}
-		}), window.addEventListener("test-passive", null, e)
-	} catch (e) {}
-	var n = Object.prototype.hasOwnProperty;
-
-	function i(e, i) {
-		return n.call(e, i)
-	}
-	var t = [];
-
-	function r() {
-		return window.__dcloud_weex_postMessage || window.__dcloud_weex_
-	}
-	var o = function(e, n) {
-			var i = {
-				options: {
-					timestamp: +new Date
-				},
-				name: e,
-				arg: n
-			};
-			if (r()) {
-				if ("postMessage" === e) {
-					var o = {
-						data: [n]
-					};
-					return window.__dcloud_weex_postMessage ? window.__dcloud_weex_postMessage(o) : window.__dcloud_weex_
-						.postMessage(JSON.stringify(o))
-				}
-				var a = {
-					type: "WEB_INVOKE_APPSERVICE",
-					args: {
-						data: i,
-						webviewIds: t
-					}
-				};
-				window.__dcloud_weex_postMessage ? window.__dcloud_weex_postMessageToService(a) : window.__dcloud_weex_
-					.postMessageToService(JSON.stringify(a))
-			}
-			if (!window.plus) return window.parent.postMessage({
-				type: "WEB_INVOKE_APPSERVICE",
-				data: i,
-				pageId: ""
-			}, "*");
-			if (0 === t.length) {
-				var d = plus.webview.currentWebview();
-				if (!d) throw new Error("plus.webview.currentWebview() is undefined");
-				var s = d.parent(),
-					w = "";
-				w = s ? s.id : d.id, t.push(w)
-			}
-			if (plus.webview.getWebviewById("__uniapp__service")) plus.webview.postMessageToUniNView({
-				type: "WEB_INVOKE_APPSERVICE",
-				args: {
-					data: i,
-					webviewIds: t
-				}
-			}, "__uniapp__service");
-			else {
-				var u = JSON.stringify(i);
-				plus.webview.getLaunchWebview().evalJS('UniPlusBridge.subscribeHandler("'.concat("WEB_INVOKE_APPSERVICE",
-					'",').concat(u, ",").concat(JSON.stringify(t), ");"))
-			}
-		},
-		a = {
-			navigateTo: function() {
-				var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
-					n = e.url;
-				o("navigateTo", {
-					url: encodeURI(n)
-				})
-			},
-			navigateBack: function() {
-				var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
-					n = e.delta;
-				o("navigateBack", {
-					delta: parseInt(n) || 1
-				})
-			},
-			switchTab: function() {
-				var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
-					n = e.url;
-				o("switchTab", {
-					url: encodeURI(n)
-				})
-			},
-			reLaunch: function() {
-				var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
-					n = e.url;
-				o("reLaunch", {
-					url: encodeURI(n)
-				})
-			},
-			redirectTo: function() {
-				var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
-					n = e.url;
-				o("redirectTo", {
-					url: encodeURI(n)
-				})
-			},
-			getEnv: function(e) {
-				r() ? e({
-					nvue: !0
-				}) : window.plus ? e({
-					plus: !0
-				}) : e({
-					h5: !0
-				})
-			},
-			postMessage: function() {
-				var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
-				o("postMessage", e.data || {})
-			}
-		},
-		d = /uni-app/i.test(navigator.userAgent),
-		s = /Html5Plus/i.test(navigator.userAgent),
-		w = /complete|loaded|interactive/;
-	var u = window.my && navigator.userAgent.indexOf(["t", "n", "e", "i", "l", "C", "y", "a", "p", "i", "l", "A"]
-		.reverse().join("")) > -1;
-	var g = window.swan && window.swan.webView && /swan/i.test(navigator.userAgent);
-	var v = window.qq && window.qq.miniProgram && /QQ/i.test(navigator.userAgent) && /miniProgram/i.test(navigator
-		.userAgent);
-	var c = window.tt && window.tt.miniProgram && /toutiaomicroapp/i.test(navigator.userAgent);
-	var m = window.wx && window.wx.miniProgram && /micromessenger/i.test(navigator.userAgent) && /miniProgram/i
-		.test(navigator.userAgent);
-	var p = window.qa && /quickapp/i.test(navigator.userAgent);
-	var f = window.ks && window.ks.miniProgram && /micromessenger/i.test(navigator.userAgent) && /miniProgram/i
-		.test(navigator.userAgent);
-	var l = window.tt && window.tt.miniProgram && /Lark|Feishu/i.test(navigator.userAgent);
-	var _ = window.jd && window.jd.miniProgram && /micromessenger/i.test(navigator.userAgent) && /miniProgram/i
-		.test(navigator.userAgent);
-	var E = window.xhs && window.xhs.miniProgram && /xhsminiapp/i.test(navigator.userAgent);
-	for (var h, P = function() {
-			window.UniAppJSBridge = !0, document.dispatchEvent(new CustomEvent("UniAppJSBridgeReady", {
-				bubbles: !0,
-				cancelable: !0
-			}))
-		}, b = [function(e) {
-			if (d || s) return window.__dcloud_weex_postMessage || window.__dcloud_weex_ ? document
-				.addEventListener("DOMContentLoaded", e) : window.plus && w.test(document.readyState) ? setTimeout(
-					e, 0) : document.addEventListener("plusready", e), a
-		}, function(e) {
-			if (m) return window.WeixinJSBridge && window.WeixinJSBridge.invoke ? setTimeout(e, 0) : document
-				.addEventListener("WeixinJSBridgeReady", e), window.wx.miniProgram
-		}, function(e) {
-			if (v) return window.QQJSBridge && window.QQJSBridge.invoke ? setTimeout(e, 0) : document
-				.addEventListener("QQJSBridgeReady", e), window.qq.miniProgram
-		}, function(e) {
-			if (u) {
-				document.addEventListener("DOMContentLoaded", e);
-				var n = window.my;
-				return {
-					navigateTo: n.navigateTo,
-					navigateBack: n.navigateBack,
-					switchTab: n.switchTab,
-					reLaunch: n.reLaunch,
-					redirectTo: n.redirectTo,
-					postMessage: n.postMessage,
-					getEnv: n.getEnv
-				}
-			}
-		}, function(e) {
-			if (g) return document.addEventListener("DOMContentLoaded", e), window.swan.webView
-		}, function(e) {
-			if (c) return document.addEventListener("DOMContentLoaded", e), window.tt.miniProgram
-		}, function(e) {
-			if (p) {
-				window.QaJSBridge && window.QaJSBridge.invoke ? setTimeout(e, 0) : document.addEventListener(
-					"QaJSBridgeReady", e);
-				var n = window.qa;
-				return {
-					navigateTo: n.navigateTo,
-					navigateBack: n.navigateBack,
-					switchTab: n.switchTab,
-					reLaunch: n.reLaunch,
-					redirectTo: n.redirectTo,
-					postMessage: n.postMessage,
-					getEnv: n.getEnv
-				}
-			}
-		}, function(e) {
-			if (f) return window.WeixinJSBridge && window.WeixinJSBridge.invoke ? setTimeout(e, 0) : document
-				.addEventListener("WeixinJSBridgeReady", e), window.ks.miniProgram
-		}, function(e) {
-			if (l) return document.addEventListener("DOMContentLoaded", e), window.tt.miniProgram
-		}, function(e) {
-			if (_) return window.JDJSBridgeReady && window.JDJSBridgeReady.invoke ? setTimeout(e, 0) : document
-				.addEventListener("JDJSBridgeReady", e), window.jd.miniProgram
-		}, function(e) {
-			if (E) return window.xhs.miniProgram
-		}, function(e) {
-			return document.addEventListener("DOMContentLoaded", e), a
-		}], y = 0; y < b.length && !(h = b[y](P)); y++);
-	h || (h = {});
-	var B = "undefined" != typeof uni ? uni : {};
-	if (!B.navigateTo)
-		for (var S in h) i(h, S) && (B[S] = h[S]);
-	return B.webView = h, B
-}));

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
src/uni.webview.1.5.6.js


+ 10 - 1
src/uni_modules/uv-navbar/components/uv-navbar/uv-navbar.vue

@@ -4,13 +4,14 @@
 			class="uv-navbar__placeholder"
 			v-if="fixed && placeholder"
 			:style="{
-				height: $uv.addUnit($uv.getPx(height) + $uv.sys().statusBarHeight,'px'),
+				height: $uv.addUnit($uv.getPx(height) + getStatusBarHeight,'px'),
 			}"
 		></view>
 		<view :class="[fixed && 'uv-navbar--fixed']">
 			<image class="uv-navbar--bgimg" :src="bgColor" :mode="imgMode" v-if="isImg" :style="[bgImgStyle]"></image>
 			<uv-status-bar
 				v-if="safeAreaInsetTop"
+				:statusBarHeight="getStatusBarHeight"
 				:bgColor="getStatusbgColor"
 			></uv-status-bar>
 			<view
@@ -110,6 +111,9 @@
 
 			}
 		},
+    created() {
+      console.log(123123, this.statusBarHeight);
+    },
 		computed: {
 			getBgColor(){
 				const style = {};
@@ -133,6 +137,11 @@
 					}
 				}
 			},
+      getStatusBarHeight() {
+        console.log(123123, this.statusBarHeight);
+        console.log(this.$uv.sys().statusBarHeight);
+        return this.statusBarHeight || this.$uv.sys().statusBarHeight;
+      },
 			// 判断传入的bgColor属性,是否图片路径,只要带有"/"均认为是图片形式
 			isImg() {
 				const isBase64 = this.bgColor.indexOf('data:') > -1 && this.bgColor.indexOf('base64') > -1;

+ 2 - 1
src/uni_modules/uv-status-bar/components/uv-status-bar/props.js

@@ -3,6 +3,7 @@ export default {
         bgColor: {
             type: String,
             default: 'transparent'
-        }
+        },
+        ...uni.$uv?.props?.statusBar
     }
 }

+ 2 - 1
src/uni_modules/uv-status-bar/components/uv-status-bar/uv-status-bar.vue

@@ -29,8 +29,9 @@
 		computed: {
 			style() {
 				const style = {}
+        console.log(123123, this.statusBarHeight);
 				// 状态栏高度,由于某些安卓和微信开发工具无法识别css的顶部状态栏变量,所以使用js获取的方式
-				style.height = this.$uv.addUnit(this.$uv.sys().statusBarHeight, 'px')
+				style.height = this.$uv.addUnit(this.$uv.sys().statusBarHeight || this.statusBarHeight, 'px')
 				if(this.bgColor){
 					if (this.bgColor.indexOf("gradient") > -1) {// 渐变色
 						style.backgroundImage = this.bgColor;

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä