Browse Source

chore: 代码格式化

await 8 months ago
parent
commit
306a29369e
2 changed files with 115 additions and 85 deletions
  1. 109 79
      src/component/layout/index.tsx
  2. 6 6
      src/pages/user/about/index.tsx

+ 109 - 79
src/component/layout/index.tsx

@@ -1,94 +1,124 @@
-import AppContext from '@/context/appContext';
-import BottomBarContext from '@/context/bottomBarContext';
-import UserHelper from '@/helper/userHelper';
-import useStore from '@/hooks/useRedux';
-import RouteUtil from '@/utils/routeUtil';
-import { FixedView } from '@taroify/core';
-import { Image, View, ViewProps } from '@tarojs/components';
-import { pxTransform } from '@tarojs/taro';
-import classNames from 'classnames';
-import { PropsWithChildren, useContext } from 'react';
-import Flex from '../flex';
-import Label from '../label';
-import './index.scss'
+import AppContext from "@/context/appContext";
+import BottomBarContext from "@/context/bottomBarContext";
+import UserHelper from "@/helper/userHelper";
+import useStore from "@/hooks/useRedux";
+import RouteUtil from "@/utils/routeUtil";
+import { FixedView } from "@taroify/core";
+import { Image, View, ViewProps } from "@tarojs/components";
+import { pxTransform } from "@tarojs/taro";
+import classNames from "classnames";
+import { PropsWithChildren, useContext } from "react";
+import Flex from "../flex";
+import Label from "../label";
+import "./index.scss";
 
 interface ILayoutProps extends ViewProps {
-    safe?: boolean;
-    bottomBarIndex?: number;
+  safe?: boolean;
+  bottomBarIndex?: number;
 }
 
 const BottomNavBar = () => {
-    const appContext = useContext(AppContext);
-    const bottomBarContext = useContext(BottomBarContext);
-    const menu = useStore(p => p.tabMenu);
-    return (
-        <FixedView style={{ height: pxTransform(104), paddingBottom: appContext.padding.bottom, zIndex: 110, background: "#fff" }} className="bottom-nav" placeholder position="bottom">
-            <Flex style={{ height: pxTransform(104) }} direction="row" alignItem="center" justifyContent="center" >
-                {
-                    menu.map(p => {
-                        let _index = ["home", "user_center"].findIndex(sp => sp === p.code);
-                        return (
-                            <Flex key={p.code} onClick={() => {
-                                UserHelper.afterLogin({
-                                    callback: async () => {
-                                        if (['home', 'user_center'].includes(p.code)) {
-                                            bottomBarContext.switchTo(_index as number);
-                                        }
-                                        else {
-                                            RouteUtil.toWebViewPage({
-                                                url: p.jumpTarget
-                                            });
-                                        }
-                                    }
-                                })
-                                return;
-                            }} flex={1} alignItem="center" justifyContent="center" >
-                                <Image className='bottom-nav-icon' src={_index === bottomBarContext?.index ? p.iconActive : p.icon} />
-                                <Label size="sm" type={_index === bottomBarContext?.index ? "default" : "secondary"} >
-                                    {p.name}
-                                </Label>
-                            </Flex>
-                        )
-                    })
+  const appContext = useContext(AppContext);
+  const bottomBarContext = useContext(BottomBarContext);
+  const menu = useStore((p) => p.tabMenu);
+  return (
+    <FixedView
+      style={{
+        height: pxTransform(104),
+        paddingBottom: appContext.padding.bottom,
+        zIndex: 110,
+        background: "#fff",
+      }}
+      className='bottom-nav'
+      placeholder
+      position='bottom'
+    >
+      <Flex
+        style={{ height: pxTransform(104) }}
+        direction='row'
+        alignItem='center'
+        justifyContent='center'
+      >
+        {menu.map((p) => {
+          let _index = ["home", "user_center"].findIndex((sp) => sp === p.code);
+          return (
+            <Flex
+              key={p.code}
+              onClick={() => {
+                UserHelper.afterLogin({
+                  forceLogin: false,
+                  callback: async () => {
+                    if (["home", "user_center"].includes(p.code)) {
+                      bottomBarContext.switchTo(_index as number);
+                    } else {
+                      RouteUtil.toWebViewPage({
+                        url: p.jumpTarget,
+                      });
+                    }
+                  },
+                });
+                return;
+              }}
+              flex={1}
+              alignItem='center'
+              justifyContent='center'
+            >
+              <Image
+                className='bottom-nav-icon'
+                src={_index === bottomBarContext?.index ? p.iconActive : p.icon}
+              />
+              <Label
+                size='sm'
+                type={
+                  _index === bottomBarContext?.index ? "default" : "secondary"
                 }
-
+              >
+                {p.name}
+              </Label>
             </Flex>
-        </FixedView>
-    )
-}
+          );
+        })}
+      </Flex>
+    </FixedView>
+  );
+};
 
 const InternalLayout = (props: PropsWithChildren<ILayoutProps>) => {
-    const { bottomBarIndex, safe = false, ...viewProps } = props;
-    const appContext = useContext(AppContext);
-    const bottomBarContext = useContext(BottomBarContext);
-    const safeStyle: React.CSSProperties = {}
-    if (safe) {
-        safeStyle.paddingTop = appContext.padding.top;
-        safeStyle.paddingBottom = appContext.padding.bottom; //(appContext.systemInfo?.screenHeight || 0) - (appContext.systemInfo?.safeArea?.bottom || 0);
-    }
-    return (
-        <View className={classNames({ "nav-bar-hide": (bottomBarIndex ?? false) === false ? false : bottomBarContext?.index !== bottomBarIndex })} >
-            <View  {...viewProps} style={safeStyle} className={classNames({
-                [viewProps.className || ""]: !!viewProps.className,
-
-            })} >
-                {props.children}
-            </View>
-            {
-                props.bottomBarIndex !== undefined &&
-                <BottomNavBar />
-            }
-        </View>
-    )
-}
-
+  const { bottomBarIndex, safe = false, ...viewProps } = props;
+  const appContext = useContext(AppContext);
+  const bottomBarContext = useContext(BottomBarContext);
+  const safeStyle: React.CSSProperties = {};
+  if (safe) {
+    safeStyle.paddingTop = appContext.padding.top;
+    safeStyle.paddingBottom = appContext.padding.bottom; //(appContext.systemInfo?.screenHeight || 0) - (appContext.systemInfo?.safeArea?.bottom || 0);
+  }
+  return (
+    <View
+      className={classNames({
+        "nav-bar-hide":
+          (bottomBarIndex ?? false) === false
+            ? false
+            : bottomBarContext?.index !== bottomBarIndex,
+      })}
+    >
+      <View
+        {...viewProps}
+        style={safeStyle}
+        className={classNames({
+          [viewProps.className || ""]: !!viewProps.className,
+        })}
+      >
+        {props.children}
+      </View>
+      {props.bottomBarIndex !== undefined && <BottomNavBar />}
+    </View>
+  );
+};
 
 type InternalLayoutType = typeof InternalLayout;
 
-interface LayoutInterface extends InternalLayoutType {
-
-}
+interface LayoutInterface extends InternalLayoutType {}
 
 const Layout = InternalLayout as LayoutInterface;
 
-export default Layout;
+export default Layout;

+ 6 - 6
src/pages/user/about/index.tsx

@@ -2,10 +2,10 @@ import Flex from "@/component/flex";
 import Layout from "@/component/layout";
 import { PropsWithChildren, useContext, useMemo } from "react";
 import { Image, View } from "@tarojs/components";
-import "./index.scss";
 import ImageUtil from "@/utils/imgUtils";
 import AppContext from "@/context/appContext";
 import Label from "@/component/label";
+import "./index.scss";
 
 interface IAboutProps {}
 
@@ -23,14 +23,14 @@ const About = (props: PropsWithChildren<IAboutProps>) => {
       <Flex style={{ height: "100vh" }}>
         <View style={imgBackStyle}>
           <Image
-            className="background-image"
+            className='background-image'
             src={require(`../../../assets/bg_aboutus@3x.png`)}
           />
-          <Flex rowGap="sm" className="background-content">
+          <Flex rowGap='sm' className='background-content'>
             <View style={{ height: 200 }} />
-            <Flex alignItem="center" className="login-back-logo-wrap">
+            <Flex alignItem='center' className='login-back-logo-wrap'>
               <Image
-                className="login-logo"
+                className='login-logo'
                 src={require("@/assets/logo.png")}
               />
             </Flex>
@@ -42,7 +42,7 @@ const About = (props: PropsWithChildren<IAboutProps>) => {
             marginBottom: Math.max(appContext.padding.bottom, 16),
             textAlign: "center",
           }}
-          type="secondary"
+          type='secondary'
         >
           贵州梵诚融资担保有限公司
         </Label>