Procházet zdrojové kódy

修改移动端判断逻辑

JohnnyChan před 1 měsícem
rodič
revize
64ec9bd81f

+ 2 - 5
JLHWEB/src/components/LjDetail/components/BaseForm.vue

@@ -893,7 +893,7 @@ import Grid from "@/components/Grid/index.vue";
 import GridItem from "@/components/Grid/components/GridItem.vue";
 import draggable from "vuedraggable";
 import { cloneDeep, pick, uniq, defaults, throttle, defaultsDeep } from "lodash-es";
-import { getDifference, handleProp, handleRowAccordingToProp } from "@/utils";
+import { getDifference, handleProp, handleRowAccordingToProp, isMobile } from "@/utils";
 import { ElMessage, ElNotification, ElAffix, type FormInstance, type FormRules } from "element-plus";
 import { useI18n } from "vue-i18n";
 import { useGlobalStore } from "@/stores/modules/global";
@@ -1053,10 +1053,7 @@ const isLabelPosition = computed(() => {
   // if (["xs", "sm"].includes(breakPoint.value)) {
   //   return "top";
   // }
-  let width = window.innerWidth;
-  if (width <= 1366) {
-    return "top";
-  }
+  if (isMobile()) return "top";
   return publicAttr.value.labelPosition;
 });
 // const breakPoint = ref("xl");

+ 2 - 5
JLHWEB/src/components/LjDetail/index.vue

@@ -25,7 +25,7 @@ import { useI18n } from "vue-i18n";
 import Affix from "./components/Affix.vue";
 import SettingWidget from "./components/Setting.vue";
 import { useLayoutLocalStore } from "@/stores/modules/layoutLocal";
-import { getDifference, setDifference, handleProp, streamlineFunc, streamlineAttrFunc, convertStrToObj } from "@/utils";
+import { getDifference, setDifference, handleProp, streamlineFunc, streamlineAttrFunc, convertStrToObj, isMobile } from "@/utils";
 import { cloneDeep, pick, get, omit, defaultsDeep } from "lodash-es";
 import LjHeader from "@/components/LjHeader/index.vue";
 import BaseMsgForm from "@/components/BaseMsgForm/index.vue";
@@ -150,10 +150,7 @@ const isScrollspy = computed(() => {
   console.log("isScrollspy currentMould.value :>> ", currentMould.value);
   console.log("DETAIL_LAYOUT_DEFINE :>> ", DETAIL_LAYOUT_DEFINE);
 
-  let width = window.innerWidth;
-  if (width <= 1366) {
-    return true;
-  }
+  if (isMobile()) return true;
   return currentMould.value?.header?.tabsProp?.scrollspy ?? DETAIL_LAYOUT_DEFINE.tabsProp.scrollspy;
 });
 /**

+ 2 - 5
JLHWEB/src/components/LjDrawer/index.vue

@@ -25,6 +25,7 @@
 import { ref, useSlots, nextTick, onMounted, onActivated, onUnmounted, onDeactivated, computed } from "vue";
 import type { BreakPoint } from "@/components/Grid/interface/index";
 import { omit } from "lodash-es";
+import { isMobile } from "@/utils/index";
 
 // // 抽屉数据模型
 // interface LjDrawerData {
@@ -67,11 +68,7 @@ const drawerSize = ref("50%");
 const getDrawerSize = () => {
   let width = window.innerWidth;
   let _size = props?.size || "50%";
-  switch (!!width) {
-    case width <= 1366:
-      _size = "100%";
-      break;
-  }
+  isMobile() && (_size = "100%");
   drawerSize.value = _size;
 };
 

+ 30 - 0
JLHWEB/src/utils/index.ts

@@ -1411,3 +1411,33 @@ export const copyFunc = (data: any) => {
     message: "复制成功"
   });
 };
+
+export const isMobile = () => {
+  let ua = navigator.userAgent.toLowerCase();
+  let isMobile = false;
+
+  // 先检查 User Agent 是否包含 "iPad"
+  if (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini|mobile|windows phone/i.test(ua)) {
+    isMobile = true;
+  }
+
+  // 对于 iOS 13+ 的 iPad,需要进一步验证是否为 Mac 平台
+  const macApp = ua.match(/macintosh/i) !== null;
+  if (macApp) {
+    const canvas = document.createElement("canvas");
+    if (canvas) {
+      const context: any = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
+      if (context) {
+        const info = context.getExtension("WEBGL_debug_renderer_info");
+        if (info) {
+          const renderer = context.getParameter(info.UNMASKED_RENDERER_WEBGL);
+          if (renderer && renderer.indexOf("Apple") !== -1) {
+            isMobile = true;
+          }
+        }
+      }
+    }
+  }
+
+  return isMobile;
+};

+ 1 - 1
JLHWEB/src/views/quote/mattressQuote/components/AllFormula.vue

@@ -18,7 +18,7 @@
           <el-segmented v-model="dannumValue" :options="dannumOptions" class="ml-32" size="default" />
         </div>
         <div class="flx-shrink">
-          <el-button type="danger" :icon="Close" text circle @click="cancelClick"></el-button>
+          <el-button type="danger" :icon="Close" circle @click="cancelClick"></el-button>
         </div>
       </div>
     </template>

+ 6 - 2
JLHWEB/src/views/quote/mattressQuote/components/StatisticItem.vue

@@ -1,5 +1,5 @@
 <template>
-  <el-tooltip class="box-item" effect="dark" placement="left">
+  <el-tooltip class="box-item" effect="dark" placement="left" :disabled="isDisabled">
     <template #content>
       <div class="flx-col" style="width: 150px">
         <div class="flx">
@@ -65,7 +65,7 @@
 import { ref, watch, computed, inject } from "vue";
 import { useTransition } from "@vueuse/core";
 // import { CaretTop, CaretBottom } from "@element-plus/icons-vue";
-import { floatSub, formatAmount3 } from "@/utils/index";
+import { floatSub, formatAmount3, isMobile } from "@/utils/index";
 
 interface WidgetProps {
   data: any;
@@ -79,6 +79,10 @@ const props = withDefaults(defineProps<WidgetProps>(), {
   iforigin: false
 });
 
+const isDisabled = computed(() => {
+  return isMobile();
+});
+
 const source = ref(0);
 const outputValue = useTransition(source, {
   duration: 800