浏览代码

feat: 完成插件广告组件部分UI兼容

huangzhichao 1 年之前
父节点
当前提交
03e2158ea0
共有 4 个文件被更改,包括 21 次插入10 次删除
  1. 1 1
      project.config.json
  2. 2 1
      src/app.config.ts
  3. 1 1
      src/hooks/useGetCustomClient.ts
  4. 17 7
      src/plugin/pages/customPage/index.tsx

+ 1 - 1
project.config.json

@@ -12,7 +12,7 @@
     "enhance": false,
     "compileHotReLoad": false,
     "postcss": false,
-    "minified": false,
+    "minified": true,
     "newFeature": true,
     "babelSetting": {
       "ignore": [],

+ 2 - 1
src/app.config.ts

@@ -9,7 +9,8 @@ export default {
     backgroundTextStyle: 'light',
     navigationBarBackgroundColor: '#fff',
     navigationBarTitleText: 'WeChat',
-    navigationBarTextStyle: 'black'
+    navigationBarTextStyle: 'black',
+    navigationStyle: 'custom'
   },
   plugins: {
     myPlugin: {

+ 1 - 1
src/hooks/useGetCustomClient.ts

@@ -23,7 +23,7 @@ async function useGetCustomClient(cb) {
   })
 }
 
-function getTopSafeHeight() {
+export function getTopSafeHeight() {
     // 状态栏 刘海屏
     const systemInfo = Taro.getSystemInfoSync()
     const { statusBarHeight = 0 } = systemInfo

+ 17 - 7
src/plugin/pages/customPage/index.tsx

@@ -1,15 +1,25 @@
-import Taro from '@tarojs/taro'
-import { View, Image } from '@tarojs/components'
-import React from 'react'
+import Taro, { useLoad } from '@tarojs/taro'
+import { useState } from 'react'
+import { getTopSafeHeight } from '@/hooks/useGetCustomClient'
+import { View } from '@tarojs/components'
 import './index.less'
-import { useDidShow } from '@tarojs/taro'
 
-const H5: React.FC = () => {
+function CustomPage() {
+  const [isCustom, setIsCustom] = useState(false)
+  useLoad(() => {
+    const spaceHeight = getTopSafeHeight()
+    const { screenHeight, windowHeight } = Taro.getSystemInfoSync()
+    setIsCustom(spaceHeight + windowHeight > screenHeight)
+
+  })
+
   return (
     <View>
-      H5
+      {isCustom && <View>isCustom</View>}
+
+      CustomPage
     </View>
   )
 }
 
-export default H5
+export default CustomPage