浏览代码

fix: 用原生组件button 代替View 避免穿透至input

王晓东 4 周之前
父节点
当前提交
122ba791b8

+ 17 - 0
src/components/BottomBar/indexNative.tsx

@@ -0,0 +1,17 @@
+import { CoverView } from "@tarojs/components";
+interface IProps {
+  className?: string
+  isStatic?: boolean
+  children: JSX.Element|JSX.Element[]
+}
+const BottomBar = ({className='', isStatic=false, children }:IProps) => {
+  return (
+    <CoverView className={`${isStatic ? 'bottom-bar-static' : 'bottom-bar'}`}>
+      <CoverView className={`flex gap-8 px-20 py-12 ${className}`}>
+        {children}
+      </CoverView>
+    </CoverView>
+  );
+};
+
+export default BottomBar;

+ 29 - 0
src/components/buttons/WemetaButtonNative.tsx

@@ -0,0 +1,29 @@
+import { Button, View } from "@tarojs/components";
+
+interface IProps {
+  onClick?: (e:any)=> void
+  disabled?: boolean
+  className?: string
+  type?: 'primary'|'normal'|'danger'
+  children: JSX.Element|JSX.Element[]|string
+  style?: React.CSSProperties
+}
+export default function WemetaButton({ onClick, type = 'primary', disabled = false, className='', style, children }:IProps) {
+  let typeClass = ''
+  if(type ==='danger'){
+    typeClass = 'bg-white text-red'
+  }else if(type ==='primary'){
+    typeClass = 'bg-primary text-white'
+  }else{
+    typeClass = 'bg-white'
+  }
+
+  const handleClick = (e:any)=> {
+    if(!disabled){
+      onClick && onClick(e)
+    }
+  }
+  return (
+    <Button style={style} className={`p-14 text-14 leading-20 block font-normal rounded-8 items-center justify-center font-pingfangSCMedium  ${typeClass} ${disabled ? 'opacity-50': ''} ${className}`} onClick={handleClick}>{children}</Button>
+  );
+}

+ 3 - 2
src/pages/agent/components/AgentSetting/index.tsx

@@ -4,8 +4,9 @@ import AgentSettingList from './components/AgentSettingList'
 import AgentKnowledgeLib from './components/AgentKnowledgeLib'
 import AgentCard from './components/AgentCard'
 import AgentContactCard from './components/AgentContactCard'
-import BottomBar from "@/components/BottomBar";
+import BottomBar from "@/components/BottomBar/indexNative";
 import WemetaButton from "@/components/buttons/WemetaButton";
+import WemetaButtonNative from "@/components/buttons/WemetaButtonNative";
 
 
 
@@ -47,7 +48,7 @@ export default forwardRef(function Index({save}: {save: ()=> void}, ref) {
         <AgentKnowledgeLib></AgentKnowledgeLib>
       </View>
       <BottomBar>
-        <WemetaButton disabled={isDisabled} className="flex-1" onClick={save}>{buttonText}</WemetaButton>
+        <WemetaButtonNative disabled={isDisabled} className="flex-1" onClick={save}>{buttonText}</WemetaButtonNative>
       </BottomBar>
     </View>
   );