Sfoglia il codice sorgente

feat: title text media address 组件编辑

王晓东 1 mese fa
parent
commit
5897b2aa0b

+ 1 - 0
src/app.config.ts

@@ -25,6 +25,7 @@ export default defineAppConfig({
     'pages/editor-pages/editor-company/index',
     'pages/editor-pages/editor-position/index',
     'pages/editor-pages/editor-phone/index',
+    'pages/editor-pages/editor-tel/index',
     'pages/editor-pages/editor-email/index',
     'pages/editor-pages/editor-qrcode/index',
 

+ 33 - 0
src/app.less

@@ -331,4 +331,37 @@
 .picker-item {
   text-align: center;
   line-height: 50px;
+}
+
+// 组件卡片空数据显示
+.component-card-empty{
+  width: 100%;
+  height: 160px;
+  border-radius: 16px;
+  overflow: hidden;
+  background-color: rgba(240, 240, 240, 1);
+  
+  .component-card-content{
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: center;
+    height: 100%;
+    gap: 12px;
+  }
+  // 小蓝本灰色 logo
+  .component-card-empty-figure{
+    width: 68px;
+    height: 24px;
+    background: url(https://cdn.wehome.cn/cmn/png/67/META-H8UKVHWU-1JNUXQBKDFMDLDZZ7BUW3-68R2H1CM-ZU2.png) no-repeat;
+    background-size: 100%;
+  }
+  .component-card-empty-tips{
+    font-family: PingFang SC;
+    font-weight: 400;
+    font-size: 16px;
+    line-height: 24px;
+    text-align: center;
+    color:rgba(#000, .25);
+  }
 }

+ 2 - 2
src/components/BottomBar/index.tsx

@@ -1,6 +1,6 @@
 import { View } from "@tarojs/components";
 
-const Index = ({ children }) => {
+const BottomBar = ({ children }) => {
   return (
     <View className="bottom-bar">
       <View className="flex gap-8 px-20 py-12">
@@ -10,4 +10,4 @@ const Index = ({ children }) => {
   );
 };
 
-export default Index;
+export default BottomBar;

+ 58 - 0
src/components/component-list/components/address.ts

@@ -0,0 +1,58 @@
+import { TComponentItem } from "@/types/agent";
+import { EComponentType } from "@/consts/enum";
+import { useComponentStore } from "@/store/componentStore";
+
+export const saveAddress = async (value:any, component:TComponentItem) => {
+  const {
+    saveComponent,
+  } = useComponentStore();
+  if(!component?.data?.id){
+    return
+  }
+  if(!value.address.length){
+    return
+  }
+  
+  const c = {
+    data: {
+      address: value.address, 
+      name: value.name,
+      latitude: value.latitude,
+      longitude: value.longitude,
+      id: component?.data?.id,
+      index: component?.data?.index,
+    },
+    enabled: component?.enabled ?? true,
+    type: EComponentType.address,
+  };
+
+  
+  await saveComponent(c)
+};
+export const handleChooseAddress = async (value, c:TComponentItem) => {
+  const {
+    setCurrentComponent,
+    setInsertIndex,
+  } = useComponentStore();
+  setInsertIndex(-1);
+  setCurrentComponent(c);
+  // setMapVisible(true)
+
+  const option = {
+    address:  value.address,
+    latitude: value.latitude,
+    longitude: value.longitude,
+    success(result:Taro.chooseLocation.SuccessCallbackResult) {
+        console.log(result)
+        value = {
+          address: result.address, 
+          name: result.name,
+          latitude: result.latitude,
+          longitude: result.longitude
+        }
+        saveAddress(value, c)
+    }
+  }
+  Taro.chooseLocation(option)
+
+};

+ 10 - 9
src/components/component-list/components/card-link/index.tsx

@@ -8,25 +8,25 @@ import IconWechat from "@/components/icon/icon-wechat";
 import {  navToWebView } from '@/utils/index'
 import { CORP_DOMAINS } from '@/config'
 import type {
-  IEntityDocument,
-  TEntityComponent,
   TSocialMediaItem,
 } from "@/types/index";
+import { TComponentItem } from "@/types/agent";
+
 
 interface Props {
   index: number;
   editMode: boolean;
-  component: TEntityComponent;
-  components: TEntityComponent[];
-  onSwitchChanged: (c: TEntityComponent, checked: boolean) => void;
-  onDelete: (c: IEntityDocument) => void;
-  onMove: (c: TEntityComponent, direction: number) => void;
+  component: TComponentItem;
+  components: TComponentItem[];
+  onSwitchChanged: (c: TComponentItem, checked: boolean) => void;
+  onDelete: (c: TComponentItem) => void;
+  onMove: (c: TComponentItem, direction: number) => void;
   onClick: (
-    c: TEntityComponent,
+    c: TComponentItem,
     link: string,
     mediaItem: TSocialMediaItem
   ) => void;
-  onStyleChanged: (c: TEntityComponent) => void
+  onStyleChanged: (c: TComponentItem) => void
 }
 
 export default ({
@@ -40,6 +40,7 @@ export default ({
   onClick,
   onStyleChanged,
 }: Props) => {
+  
   const data = component?.data;
   const posterExist = data?.poster
   const mediaItem = {

+ 11 - 13
src/components/component-list/components/card-media/index.tsx

@@ -2,23 +2,21 @@ import Taro from "@tarojs/taro";
 import { View, Image } from "@tarojs/components";
 import WidgetCard from "@/components/widgets/widget-card/index";
 import WidgetMedia from "@/components/widgets/widget-media/index";
-import style from "./index.module.less";
-import IconArrowRight from "@/images/icon_24_right.png";
-import type {
-  IEntityDocument,
-  TEntityComponent,
-} from "@/types/index";
+
+
+
+import { TComponentItem } from "@/types/agent";
 
 interface Props {
   index: number;
   editMode: boolean;
-  component: TEntityComponent;
-  components: TEntityComponent[];
-  onSwitchChanged: (c: TEntityComponent, checked: boolean) => void;
-  onDelete: (c: IEntityDocument) => void;
-  onMove: (c: TEntityComponent, direction: number) => void;
+  component: TComponentItem;
+  components: TComponentItem[];
+  onSwitchChanged: (c: TComponentItem, checked: boolean) => void;
+  onDelete: (c: TComponentItem) => void;
+  onMove: (c: TComponentItem, direction: number) => void;
   onClick: () => void;
-  onStyleChanged: (c: TEntityComponent) => void
+  onStyleChanged: (c: TComponentItem) => void
 }
 
 export default ({
@@ -48,7 +46,7 @@ export default ({
   return (
     <>
       <WidgetCard
-        key={component.id}
+        key={component.data.id}
         enabled={component.enabled}
         onSwitchChanged={(checked) => onSwitchChanged(component, checked)}
         index={index}

+ 8 - 10
src/components/component-list/components/card-tel/index.tsx

@@ -2,22 +2,20 @@ import {View} from '@tarojs/components'
 import WidgetCard from "@/components/widgets/widget-card/index";
 import WidgetTypeRow, {
 } from "@/components/widgets/widget-type-row/index";
-import type {
-  IEntityDocument,
-  TEntityComponent,
-} from "@/types/index";
 import Taro from '@tarojs/taro';
 import IconPhone from '@/components/icon/icon-phone'
 
+import { TComponentItem } from "@/types/agent";
+
 interface Props {
   index: number
   editMode: boolean
-  component: TEntityComponent
-  components: TEntityComponent[]
-  onSwitchChanged: (c: TEntityComponent, checked: boolean)=> void
-  onDelete:(c: IEntityDocument)=> void
-  onMove: (c: TEntityComponent, direction: number) => void
-  onStyleChanged: (c: TEntityComponent) => void
+  component: TComponentItem
+  components: TComponentItem[]
+  onSwitchChanged: (c: TComponentItem, checked: boolean)=> void
+  onDelete:(c: TComponentItem)=> void
+  onMove: (c: TComponentItem, direction: number) => void
+  onStyleChanged: (c: TComponentItem) => void
   onClick: () => void;
 }
 export default ({

+ 2 - 2
src/components/component-list/components/new-comp-button/index.module.less

@@ -1,7 +1,7 @@
 .container{
-  border: 2px dashed rgba(black, .08);
+  border: 2px dashed rgba(black, .05);
   background-color: rgba(white, .5);
 }
 .textColor{
-  color: #6c6c6c;
+  color: rgba(#000, .65);
 }

+ 1 - 1
src/components/component-list/components/new-comp-button/index.tsx

@@ -4,7 +4,7 @@ interface Props {
   index?: number
 }
 export default ({index}:Props) => {
-  return <View className={`flex items-center justify-center gap-8 py-12 rounded-20 ${style.container}`}>
+  return <View className={`flex items-center justify-center gap-8 py-12 rounded-12 ${style.container}`}>
     <Text className={`iconfont icon-icon_20_add text-16 ${style.textColor}`}></Text><Text className={`text-14 font-medium leading-28 ${style.textColor}`}>添加组件{index}</Text>
   </View>
 }

+ 51 - 97
src/components/component-list/index.tsx

@@ -8,7 +8,6 @@ import WidgetTypeRow from "@/components/widgets/widget-type-row/index";
 import WidgetTitleRow from "@/components/widgets/widget-title-row/index";
 import PopupLinkCopyer from "@/components/popup-link-copyer";
 import type {
-  IEntityDocument,
   TEntityComponent,
   TSocialMediaItem,
 } from "@/types/index";
@@ -24,12 +23,10 @@ import CardMedia from "./components/card-media/index";
 import CardMiniProgram from "./components/card-mini-program/index";
 import CardLink from "./components/card-link/index";
 
-import IconMail from '@/components/icon/icon-email'
-import IconBag from '@/components/icon/icon-bag'
-import IconGroup from '@/components/icon/icon-group'
-import IconBuilding from '@/components/icon/icon-building'
+
 import { TComponentItem } from "@/types/agent";
-import { editAgentWebsite } from "@/service/agent";
+
+import { handleChooseAddress } from './components/address'
 
 interface Props {
   components: TComponentItem[];
@@ -37,7 +34,6 @@ interface Props {
 }
 export default ({ components, editMode = false }: Props) => {
   const {
-    saveComponent,
     delComponent,
     setCurrentComponent,
     setInsertIndex,
@@ -45,7 +41,7 @@ export default ({ components, editMode = false }: Props) => {
   } = useComponentStore();
 
   const [show, setShow] = useState(true);
-  const [mapVisible, setMapVisible] = useState(false);
+
 
   const [currentMediaItem, setCurrentMediaItem] =
     useState<TSocialMediaItem | null>(null);
@@ -71,64 +67,21 @@ export default ({ components, editMode = false }: Props) => {
     
     delComponent(c);
   };
-  const handleNavigate = (c: TEntityComponent, url: string) => {
+  const handleNavigate = (c: TComponentItem, url: string) => {
     setInsertIndex(-1);
     setCurrentComponent(c);
     let _url = url;
     if (_url.indexOf("?") > -1) {
-      _url += `&id=${c.id}`;
+      _url += `&id=${c.data.id}`;
     } else {
-      _url += `?id=${c.id}`;
+      _url += `?id=${c.data.id}`;
     }
     Taro.navigateTo({ url: _url });
   };
 
-  const saveAddress = async (value, component:TEntityComponent) => {
-    if(!value.address.length){
-      return
-    }
-    
-    const c = {
-      data: {
-        address: value.address, 
-        name: value.name,
-        latitude: value.latitude,
-        longitude: value.longitude,
-      },
-      enabled: component?.enabled ?? true,
-      id: component?.id,
-      name: component?.name ?? "地址",
-      characterProfileId: component?.characterProfileId,
-      type: "address",
-    };
-
-    
-    await saveComponent(c)
-  };
-
-  const handleChooseAddress = async (value, c:TEntityComponent) => {
-    // setInsertIndex(-1);
-    // setCurrentComponent(c);
-    // setMapVisible(true)
-
-    // const option = {
-    //   address:  value.address,
-    //   latitude: value.latitude,
-    //   longitude: value.longitude,
-    //   success(result:Taro.chooseLocation.SuccessCallbackResult) {
-    //       console.log(result)
-    //       value = {
-    //         address: result.address, 
-    //         name: result.name,
-    //         latitude: result.latitude,
-    //         longitude: result.longitude
-    //       }
-    //       saveAddress(value, c)
-    //   }
-    // }
-    // Taro.chooseLocation(option)
+  
 
-  };
+  
 
   const handleSort = async (c: TComponentItem, direction: number) => {
     console.log(c, direction)
@@ -359,47 +312,47 @@ export default ({ components, editMode = false }: Props) => {
 
         
 
-        if (c.type === "email") {
-          return {
-            component: c,
-            renderer: (
-              <>
-                <WidgetCard
-                  index={index}
-                  enabled={c.enabled}
-                  onSwitchChanged={(checked) => handleSwitchChanged(c, checked)}
-                  components={components}
-                  editMode={editMode}
-                  onDelete={() => handleDelete(c)}
-                  onMove={(direction) => handleSort(c, direction)}
-                  onChanged={()=> {
-                    if(c.data?.layout === 'center'){
-                      changeStyle({...c, data: {...c.data, layout: 'left'}})
-                    }else{
-                      changeStyle({...c, data: {...c.data, layout: 'center'}})
-                    }
-                  }}
-                >
-                  <WidgetTypeRow
-                    editMode={editMode}
-                    onClick={() =>
-                      editMode &&
-                      handleNavigate(
-                        c,
-                        "/pages/editor-pages/editor-email/index"
-                      )
-                    }
-                    type={IconMail()}
-                    layout={c.data.layout}
-                  >
-                    {c.data.text}
-                  </WidgetTypeRow>
-                </WidgetCard>
-              </>
-            ),
-          };
-        }
-
+        // if (c.type === "email") {
+        //   return {
+        //     component: c,
+        //     renderer: (
+        //       <>
+        //         <WidgetCard
+        //           index={index}
+        //           enabled={c.enabled}
+        //           onSwitchChanged={(checked) => handleSwitchChanged(c, checked)}
+        //           components={components}
+        //           editMode={editMode}
+        //           onDelete={() => handleDelete(c)}
+        //           onMove={(direction) => handleSort(c, direction)}
+        //           onChanged={()=> {
+        //             if(c.data?.layout === 'center'){
+        //               changeStyle({...c, data: {...c.data, layout: 'left'}})
+        //             }else{
+        //               changeStyle({...c, data: {...c.data, layout: 'center'}})
+        //             }
+        //           }}
+        //         >
+        //           <WidgetTypeRow
+        //             editMode={editMode}
+        //             onClick={() =>
+        //               editMode &&
+        //               handleNavigate(
+        //                 c,
+        //                 "/pages/editor-pages/editor-email/index"
+        //               )
+        //             }
+        //             type={IconMail()}
+        //             layout={c.data.layout}
+        //           >
+        //             {c.data.text}
+        //           </WidgetTypeRow>
+        //         </WidgetCard>
+        //       </>
+        //     ),
+        //   };
+        // }
+        // 电话
         if (c.type === "tel") {
           return {
             component: c,
@@ -425,6 +378,7 @@ export default ({ components, editMode = false }: Props) => {
           };
         }
 
+        // 图片/视频
         if (c.type === "media") {
           return {
             component: c,

+ 1 - 1
src/components/widgets/widget-card/index.module.less

@@ -1,7 +1,7 @@
 .widgetCardContainer{
   padding: 18px 0;
   background-color: white;
-  border-radius: 20px;
+  border-radius: 16px;
   width: 100%;
   box-sizing: border-box;
 }

+ 13 - 0
src/components/widgets/widget-media/index.tsx

@@ -26,8 +26,21 @@ const Index: React.FC<Props> = ({ layout, mediaList, editMode=false }) => {
     })
   };
 
+  const renderEmpty = ()=> {
+    return <View className="px-16"><View className="component-card-empty">
+      <View className="component-card-content">
+        <View className="component-card-empty-figure"></View>
+        <View className="component-card-empty-tips">点击配置图片/视频</View>
+      </View>
+    </View>
+    </View>
+  }
+
   // 渲染媒体列表
   const renderList = () => {
+    if(mediaList.length === 0){
+      return renderEmpty()
+    }
     // 单个媒体大尺寸显示
     if (mediaList.length === 1) {
       const item = mediaList[0];

+ 1 - 1
src/pages/agent/index.tsx

@@ -11,7 +11,7 @@ import { useRouter } from "@tarojs/taro";
 import { useComponentStore } from "@/store/componentStore";
 
 export default function Index() {
-  const [tabIndex, setTabIndex] = useState("1");
+  const [tabIndex, setTabIndex] = useState("2");
   const router = useRouter();
   const agentId = router.params.agentId;
   const { fetchAgent } = useAgentStore();

+ 79 - 137
src/pages/editor-pages/editor-link/index.tsx

@@ -1,198 +1,140 @@
 import { useState } from "react";
-import { View,Text,Image } from "@tarojs/components";
-import Taro from '@tarojs/taro'
+import { View, Text, Image } from "@tarojs/components";
+import Taro from "@tarojs/taro";
 import PageCustom from "@/components/page-custom/index";
 import NavBarNormal from "@/components/nav-bar-normal/index";
 import WemetaTextarea from "@/components/wemeta-textarea/index";
 import WemetaInput from "@/components/wemeta-input/index";
 
 import editorStyle from "../editor.module.less";
-import style from './index.module.less'
-import WemetaRadioGroup from "@/components/wemeta-radio-group/index";
-import { useCharacterStore } from '@/store/characterStore'
+import style from "./index.module.less";
+
+import BottomBar from "@/components/BottomBar";
+
 import { useComponentStore } from "@/store/componentStore";
 import { uploadImage } from "@/utils/http";
+import { EComponentType } from "@/consts/enum";
 export default function Index() {
-  const $instance = Taro.getCurrentInstance()
-  const id = $instance.router?.params.id
-  // 新建时获取 linkType 和 title 
-  const linkType = $instance.router?.params.linkType
-  const linkTitle = $instance.router?.params.title
 
-  const deltaNum = id ? 1:2;
-  let currentComponent = useComponentStore((state)=>  state.currentComponent);
-  const character = useCharacterStore((state)=> state.character);
+  let currentComponent = useComponentStore((state) => state.currentComponent);
+  if(!currentComponent){
+    return <></>;
+  }
+
   const { saveComponent } = useComponentStore();
-  const loading = useComponentStore((state)=> state.loading);
-  const componentData  = currentComponent?.data ?? {};
-  const {link, text, layout, poster} = componentData
+  const loading = useComponentStore((state) => state.loading);
+  const data = currentComponent?.data;
+  const { link, text, layout, poster } = data;
 
-  const [linkValue, setLinkValue] = useState( link ?? '');
-  const [linkText, setLinkText] = useState(text?? '');
-  const [linkPoster, setLinkPoster] = useState(poster?? '');
-  const [tabIndex, setTabIndex] = useState(0);
-  const [radioValue, setRadioValue] = useState(layout  ?? "center")
-  const radioList = [
-    {
-      text: "居中",
-      value: "center",
-      checked: false,
-    },
-    {
-      text: "左对齐",
-      value: "left",
-      checked: false,
-    },
-  ];
+  const [linkValue, setLinkValue] = useState(link ?? "");
+  const [linkText, setLinkText] = useState(text ?? "");
+  const [linkPoster, setLinkPoster] = useState(poster ?? "");
+  
 
-  const handleSave = async () => {    
-    if(!linkValue.length){
-      return
+  const handleSubmit = async () => {
+    if(!data?.id){
+      return;
     }
-    if(loading){
+    if (loading) {
       return;
     }
     const c = {
       data: {
         link: linkValue,
         text: linkText,
-        layout: radioValue,
+        layout: layout ?? 'center',
         poster: linkPoster,
-        linkType: componentData.linkType ?? linkType,
-        title: componentData.title ?? linkTitle,
+        linkType: data.linkType,
+        id: currentComponent?.data.id,
+        index: currentComponent?.data?.index,
       },
       enabled: currentComponent?.enabled ?? true,
-      id: currentComponent?.id,
-      name: currentComponent?.name ?? "链接",
-      characterProfileId: currentComponent?.characterProfileId ?? character?.profileId,
-      type: "link",
+      type: EComponentType.link,
     };
-    
-    await saveComponent(c)
-  };
-
 
-  const onRadioChange = (value: string) => {
-    setRadioValue(value)
-    return false;
+    await saveComponent(c);
+    Taro.navigateBack();
   };
 
-  const handleNavBack = async () => {
-    await handleSave()
-  }
-  
   const handleAddPoster = () => {
     Taro.chooseImage({
       count: 1,
-      sizeType: ['original', 'compressed'],
-      sourceType: ['album', 'camera'],
-      async success (chooseImageRes) {
-        const tempFilePaths = chooseImageRes.tempFilePaths
+      sizeType: ["original", "compressed"],
+      sourceType: ["album", "camera"],
+      async success(chooseImageRes) {
+        const tempFilePaths = chooseImageRes.tempFilePaths;
         const res = await uploadImage(tempFilePaths[0]);
-        if (res?.code === 0 && res.data) {
-          setLinkPoster(res.data)
+        if (res?.publicUrl) {
+          setLinkPoster(res.publicUrl);
         }
-        // Taro.cropImage({
-        //   src: tempFilePaths[0],
-        //   cropScale: "16:9",
-        //   success: async (cropRes) => {
-        //     const path = cropRes.tempFilePath;
-        //     const res = await uploadImage(path);
-        //     if (res?.code === 0 && res.data) {
-        //       setLinkPoster(res.data)
-        //     }
-        //   },
-        // });
-      }
-    })
+      },
+    });
   };
 
-  const renderPoster = (src?: string)=> {
-    if(src){
+  const renderPoster = (src?: string) => {
+    if (src) {
       return (
         <View className="w-full overflow-hidden">
-          <Image
-            className={style.cover}
-            mode="widthFix"
-            src={src}
-          ></Image>
+          <Image className={style.cover} mode="widthFix" src={src}></Image>
         </View>
-      )
+      );
     }
     return (
       <>
         <View>
-          <Image src='https://cdn.wehome.cn/cmn/png/100/META-H8UKVHWU-KIGP3BIL7M5AYC6XHNUA2-VDZCWI2M-O91.png' className={style.iconAdd}></Image>
+          <Image
+            src="https://cdn.wehome.cn/cmn/png/100/META-H8UKVHWU-KIGP3BIL7M5AYC6XHNUA2-VDZCWI2M-O91.png"
+            className={style.iconAdd}
+          ></Image>
         </View>
-        <View className="text-gray-45 text-12 leading-20 text-center">上传展示图</View>
-      </>
-    )
-  }
-
-  const renderTabContent = () => {
-    if (tabIndex == 0) {
-      return (
-        <View className={editorStyle.formContainer}>
-          <View className={editorStyle.formItem}>
-            <View className={editorStyle.formItemLabel}>
-              <View className={editorStyle.formLabel}>链接描述</View>
-              <View className={editorStyle.formLabelRequired}>(选填)</View>
-            </View>
-            <WemetaInput
-                value={linkText}
-                onInput={(value: string) => setLinkText(value)}
-                placeholder="请输入..."
-              />
-          </View>
-          <View className={editorStyle.formItem}>
-            <View className={editorStyle.formItemLabel}>
-              <View className="flex-1">封面图 <Text className="text-gray-45">(选填)</Text></View>
-            </View>
-            <View className={`${style.coverContainer}`} onClick={handleAddPoster}>
-              {renderPoster(linkPoster)}
-            </View>
-          </View>
+        <View className="text-gray-45 text-12 leading-20 text-center">
+          上传展示图
         </View>
-      );
-    }
-    return (
-      <WemetaRadioGroup
-        radioList={radioList}
-        value={radioValue}
-        onChange={onRadioChange}
-      ></WemetaRadioGroup>
+      </>
     );
   };
 
   return (
     <PageCustom>
-      <NavBarNormal backText="保存" navDelta={deltaNum} onNavBack={handleNavBack}>{linkTitle ? linkTitle : '链接'}</NavBarNormal>
+      <NavBarNormal>链接</NavBarNormal>
       <View className="flex flex-col items-center w-full">
-        <View className={editorStyle.container}>
+        <View className="px-16 w-full pb-120">
           <WemetaTextarea
             value={linkValue}
             onInput={(value: string) => setLinkValue(value)}
             placeholder="请输入URL..."
-          >
-          </WemetaTextarea>
-          
-          <View className="flex items-center gap-12 py-32">
-            <View
-              className={`button-rounded ${tabIndex === 0 ? "actived" : ""}`}
-              onClick={() => setTabIndex(0)}
-            >
-              内容
+          ></WemetaTextarea>
+
+          <View className={editorStyle.formContainer}>
+            <View className={editorStyle.formItem}>
+              <View className={editorStyle.formItemLabel}>
+                <View className={editorStyle.formLabel}>链接描述</View>
+                <View className={editorStyle.formLabelRequired}>(选填)</View>
+              </View>
+              <WemetaInput
+                value={linkText}
+                onInput={(value: string) => setLinkText(value)}
+                placeholder="请输入..."
+              />
             </View>
-            <View
-              className={`button-rounded ${tabIndex === 1 ? "actived" : ""}`}
-              onClick={() => setTabIndex(1)}
-            >
-              版式
+            <View className={editorStyle.formItem}>
+              <View className={editorStyle.formItemLabel}>
+                <View className="flex-1">
+                  封面图 <Text className="text-gray-45">(选填)</Text>
+                </View>
+              </View>
+              <View
+                className={`${style.coverContainer}`}
+                onClick={handleAddPoster}
+              >
+                {renderPoster(linkPoster)}
+              </View>
             </View>
           </View>
-
-          {renderTabContent()}
         </View>
+        <BottomBar>
+          <View className="button-rounded button-primary flex-1" onClick={handleSubmit}>保存</View>
+        </BottomBar>
       </View>
     </PageCustom>
   );

+ 27 - 69
src/pages/editor-pages/editor-media/index.tsx

@@ -6,27 +6,26 @@ import EmptyData from "@/components/empty-data/index";
 
 import editorStyle from "../editor.module.less";
 import style from "./index.module.less";
-import WemetaRadioGroup from "@/components/wemeta-radio-group/index";
-import WemetaTabs from "@/components/wemeta-tabs/index";
+
 import ButtonCardAdd from "@/components/button-card-add/index";
 import MediaItem from "@/components/media-item/index";
 import Taro, { useUnload } from "@tarojs/taro";
 import { uploadImage } from "@/utils/http";
 import { useComponentStore } from "@/store/componentStore";
-import { useCharacterStore } from "@/store/characterStore";
+
 import type { TMediaType } from "@/types/index";
+import { EComponentType } from "@/consts/enum";
+import BottomBar from "@/components/BottomBar";
 
 interface Props {
   editMode?: boolean;
 }
 
 export default function Index({ editMode }: Props) {
-  const $instance = Taro.getCurrentInstance();
-  const id = $instance.router?.params.id;
-  const deltaNum = id ? 1 : 2;
-  let isUploading = false;
+  
+  
   let currentComponent = useComponentStore((state) => state.currentComponent);
-  const character = useCharacterStore((state) => state.character);
+  
   const { saveComponent } = useComponentStore();
   const loading = useComponentStore((state) => state.loading);
 
@@ -34,25 +33,10 @@ export default function Index({ editMode }: Props) {
     currentComponent?.data?.media ?? []
   );
 
-  const [radioValue, setRadioValue] = useState(
-    currentComponent?.data?.layout ?? "mini"
-  );
-  const radioList = [
-    {
-      text: "缩略宫格",
-      value: "mini",
-      checked: false,
-    },
-    {
-      text: "大图平铺",
-      value: "full",
-      checked: false,
-    },
-  ];
-
-  const handleSave = async (_newValue?: string) => {
-    if (!mediaValue.length) {
-      return;
+
+  const handleSubmit = async () => {
+    if(!currentComponent?.data?.id){
+      return
     }
     if (loading) {
       return;
@@ -60,24 +44,19 @@ export default function Index({ editMode }: Props) {
     const c = {
       data: {
         media: mediaValue,
-        layout: radioValue,
+        layout: currentComponent.data.layout ?? 'mini',
+        id: currentComponent.data.id,
+        index: currentComponent.data.index,
       },
       enabled: currentComponent?.enabled ?? true,
-      id: currentComponent?.id,
-      name: currentComponent?.name ?? "图片/视频",
-      characterProfileId:
-        currentComponent?.characterProfileId ?? character?.profileId,
-      type: "images",
+      type: EComponentType.media,
     };
 
     await saveComponent(c);
+    Taro.navigateBack();
   };
 
-  const onRadioChange = (value: string) => {
-    setRadioValue(value);
-    return false;
-  };
-
+  let isUploading = false;
   const handleClick = () => {
     Taro.chooseMedia({
       count: 9,
@@ -92,20 +71,20 @@ export default function Index({ editMode }: Props) {
           Taro.showLoading();
           const res = await uploadImage(t.tempFilePath);
           Taro.hideLoading();
-          if (res?.code === 0 && res.data) {
+          if (res?.publicUrl) {
             arr.push({
               duration: t.duration,
               height: t.height,
               width: t.width,
               size: t.size,
-              url: res.data,
+              url: res.publicUrl,
               fileType: t.fileType,
             });
             console.log(arr);
           }else{
             Taro.showModal({
               title: '上传异常',
-              content: res?.msg ?? '文件上传失败',
+              content: '文件上传失败',
               showCancel: false,
             })
           }
@@ -125,9 +104,7 @@ export default function Index({ editMode }: Props) {
     setMediaValue([...results]);
   };
 
-  const handleNavBack = async () => {
-    await handleSave();
-  };
+  
 
   
 
@@ -154,44 +131,25 @@ export default function Index({ editMode }: Props) {
     return <EmptyData></EmptyData>;
   };
 
-  const tabList = [
-    {
-      key: "1",
-      label: "内容",
-      children: renderList(),
-    },
-    {
-      key: "2",
-      label: "版式",
-      children: (
-        <View>
-          <WemetaRadioGroup
-            radioList={radioList}
-            value={radioValue}
-            onChange={onRadioChange}
-          ></WemetaRadioGroup>
-        </View>
-      ),
-    },
-  ];
+  
 
   return (
     <PageCustom isflex={false} bgColor="global-light-green-bg">
       <NavBarNormal
-        backText="保存"
-        navDelta={deltaNum}
-        onNavBack={handleNavBack}
       >
         图片/视频
       </NavBarNormal>
 
-      <View className={editorStyle.container}>
+      <View className="flex flex-col w-full px-16 pt-12 gap-12">
         <ButtonCardAdd
           text="导入图片/视频"
           onClick={handleClick}
         ></ButtonCardAdd>
-        <WemetaTabs list={tabList} current="1"></WemetaTabs>
+        {renderList()}
       </View>
+      <BottomBar>
+          <View className="button-rounded button-primary flex-1" onClick={handleSubmit}>保存</View>
+        </BottomBar>
     </PageCustom>
   );
 }

+ 0 - 2
src/pages/editor-pages/editor-personality/index.module.less

@@ -1,2 +0,0 @@
-
-

+ 20 - 17
src/pages/editor-pages/editor-phone/index.tsx

@@ -4,34 +4,37 @@ import PageCustom from "@/components/page-custom/index";
 import NavBarNormal from "@/components/nav-bar-normal/index";
 import editorStyle from "../editor.module.less";
 
-import { useAgentStore } from '@/store/agentStore'
+import { useAgentStore } from "@/store/agentStore";
 import WemetaTextarea from "@/components/wemeta-textarea/index";
 import useEditContactCard from "@/hooks/useEditContactCard";
 export default function Index() {
-
-  const agentCard = useAgentStore((state)=> state.agentContactCard)
-  const {value, onChange, handleSubmit} = useEditContactCard('mobile', agentCard?.mobile)
-  
+  const agentCard = useAgentStore((state) => state.agentContactCard);
+  const { value, onChange, handleSubmit } = useEditContactCard(
+    "mobile",
+    agentCard?.mobile
+  );
 
   return (
     <PageCustom>
       <NavBarNormal backText="手机号码"></NavBarNormal>
       <View className="flex flex-col items-center w-full">
-        <View className={editorStyle.container}>
+        <View className="w-full p-16">
+          <WemetaTextarea
+            value={value}
+            onBlur={(value: string) => onChange(value)}
+            onInput={(value: string) => onChange(value)}
+            placeholder="填写手机号码"
+            autoFocus
+          />
+        </View>
+
+        <BottomBar>
           <View
-            className={`${editorStyle.textInputContainer} ${editorStyle.underline}`}
+            className="button-rounded button-primary flex-1"
+            onClick={handleSubmit}
           >
-            <WemetaTextarea
-              value={value}
-              onBlur={(value: string) => onChange(value)}
-              onInput={(value: string) => onChange(value)}
-              placeholder="填写手机号码"
-              autoFocus
-            />
+            保存
           </View>
-        </View>
-        <BottomBar>
-          <View className="button-rounded button-primary flex-1" onClick={handleSubmit}>保存</View>
         </BottomBar>
       </View>
     </PageCustom>

+ 14 - 44
src/pages/editor-pages/editor-tel/index.tsx

@@ -9,37 +9,22 @@ import { useComponentStore } from "@/store/componentStore";
 import { useCharacterStore } from "@/store/characterStore";
 import Taro, { useUnload } from "@tarojs/taro";
 import WemetaTextarea from "@/components/wemeta-textarea/index";
-
+import BottomBar from "@/components/BottomBar";
+import { EComponentType } from "@/consts/enum";
 export default function Index() {
-  const $instance = Taro.getCurrentInstance();
-  const id = $instance.router?.params?.id;
-  const deltaNum = id ? 1 : 2
+  
   let currentComponent = useComponentStore((state) => state.currentComponent);
-  const character = useCharacterStore((state) => state.character);
   const { saveComponent } = useComponentStore();
   const loading = useComponentStore((state) => state.loading);
   const [value, setValue] = useState(currentComponent?.data?.text ?? "");
-  const [radioValue, setRadioValue] = useState(currentComponent?.data?.layout ?? 'simple')
   
-  const radioList = [
-    {
-      text: "居中",
-      value: "simple",
-      checked: false,
-    },
-    {
-      text: "左对齐",
-      value: "default",
-      checked: false,
-    },
-  ];
 
   const onChange = (e: any) => {
     setValue(e);
   };
 
-  const handleSave = async (_newValue?: string) => {
-    if (!value.length) {
+  const handleSubmit = async () => {
+    if(!currentComponent?.data?.id){
       return;
     }
     if (loading) {
@@ -48,48 +33,33 @@ export default function Index() {
     const c = {
       data: {
         text: value,
-        layout: radioValue,
+        layout: currentComponent?.data?.layout ?? 'center',
+        id: currentComponent?.data?.id,
+        index: currentComponent?.data?.index,
       },
       enabled: currentComponent?.enabled ?? true,
-      id: currentComponent?.id,
-      name: currentComponent?.name ?? "电话",
-      characterProfileId:
-        currentComponent?.characterProfileId ?? character?.profileId,
-      type: "tel",
+      type: EComponentType.tel,
     };
 
     await saveComponent(c);
   };
 
-  const onRadioChange = (value: string) => {
-    setRadioValue(value)
-    return false;
-  };
-
-  const handleNavBack = async () => {
-    await handleSave()
-  }
-
   
 
   return (
     <PageCustom>
-      <NavBarNormal navDelta={deltaNum} onNavBack={handleNavBack} backText="保存">电话</NavBarNormal>
+      <NavBarNormal>电话</NavBarNormal>
       <View className="flex flex-col items-center w-full">
-        <View className={editorStyle.container}>
+        <View className="w-full p-16">
           <WemetaTextarea
               value={value}
               onInput={(value: string) => onChange(value)}
               placeholder="请输入电话..."
             />
-          <View className="pt-32">
-            <WemetaRadioGroup
-              radioList={radioList}
-              onChange={onRadioChange}
-              value={radioValue}
-            ></WemetaRadioGroup>
-          </View>
         </View>
+        <BottomBar>
+          <View className="button-rounded button-primary flex-1" onClick={handleSubmit}>保存</View>
+        </BottomBar>
       </View>
     </PageCustom>
   );

+ 23 - 52
src/pages/editor-pages/editor-textarea/index.tsx

@@ -2,60 +2,47 @@ import { useState } from "react";
 import { View } from "@tarojs/components";
 import PageCustom from "@/components/page-custom/index";
 import NavBarNormal from "@/components/nav-bar-normal/index";
-import WemetaRadioGroup from "@/components/wemeta-radio-group/index";
+import BottomBar from "@/components/BottomBar";
 import editorStyle from "../editor.module.less";
 import { useComponentStore } from "@/store/componentStore";
-import { useCharacterStore } from '@/store/characterStore'
 import Taro, { useUnload } from "@tarojs/taro";
 import WemetaTextarea from "@/components/wemeta-textarea/index";
+import { EComponentType } from "@/consts/enum";
 
 export default function Index() {
-  const $instance = Taro.getCurrentInstance();
-  const id = $instance.router?.params?.id;
-  const deltaNum = id ? 1 : 2
-  let maxIndex = useComponentStore((state)=>  state.maxIndex);
+  
   let currentComponent = useComponentStore((state)=>  state.currentComponent);
-  const character = useCharacterStore((state)=> state.character);
+  
   const { saveComponent } = useComponentStore();
   const loading = useComponentStore((state)=> state.loading);
   const [value, setValue] = useState<string>(currentComponent?.data?.text ?? '');
 
-  const [radioValue, setRadioValue] = useState(currentComponent?.data?.layout ?? 'center')
-  const radioList = [
-    {
-      text: "居中",
-      value: "center",
-      checked: false,
-    },
-    {
-      text: "左对齐",
-      value: "left",
-      checked: false,
-    },
-  ];
+  
 
-  const handleSave = async (_newValue?: string) => {
-    if(!value.length){
-      return
-    }
+  const handleSubmit = async () => {
+    
     if(loading){
       return;
     }
+    if(!currentComponent?.data.id){
+      return
+    }
+    
     const c = {
       data: {
         text: value,
-        layout: radioValue,
+        layout: currentComponent?.data?.layout ?? 'center',
+        id: currentComponent?.data.id,
+        index: currentComponent?.data?.index,
       },
       enabled: currentComponent?.enabled ?? true,
-      id: currentComponent?.id,
-      name: currentComponent?.name ?? "文本内容",
-      index: currentComponent?.index ?? (maxIndex+1),
-      characterProfileId: currentComponent?.characterProfileId ?? character?.profileId,
-      type: "textarea",
+      type: EComponentType.text,
     };
 
     
     await saveComponent(c)
+
+    Taro.navigateBack()
   };
 
   
@@ -63,42 +50,26 @@ export default function Index() {
     setValue(e);
   };
 
-  const onRadioChange = (value: string) => {
-    setRadioValue(value)
-    return false;
-  };
-
   
-  const handleNavBack =  async () => {
-    await handleSave()
-  }
 
   
 
   return (
     <PageCustom bgColor="global-light-green-bg">
-      <NavBarNormal backText="保存" navDelta={deltaNum} onNavBack={handleNavBack}>文本内容</NavBarNormal>
+      <NavBarNormal>文本内容</NavBarNormal>
       <View className="flex flex-col items-center w-full">
-        <View className={editorStyle.container}>
-          <View
-            className={`${editorStyle.textInputContainer} ${editorStyle.underline}`}
-          >
-            <WemetaTextarea
+        <View className="w-full p-16">
+          <WemetaTextarea
               value={value}
               onInput={(value: any) => onChange(value)}
               placeholder="文本内容"
               cursorSpacing={100}
               maxlength={2000}
             />
-          </View>
-          <View className="pt-32">
-            <WemetaRadioGroup
-              radioList={radioList}
-              onChange={onRadioChange}
-              value={radioValue}
-            ></WemetaRadioGroup>
-          </View>
         </View>
+        <BottomBar>
+          <View className="button-rounded button-primary flex-1" onClick={handleSubmit}>保存</View>
+        </BottomBar>
       </View>
     </PageCustom>
   );

+ 7 - 38
src/pages/editor-pages/editor-title/index.tsx

@@ -3,32 +3,17 @@ import { View } from "@tarojs/components";
 
 import PageCustom from "@/components/page-custom/index";
 import NavBarNormal from "@/components/nav-bar-normal/index";
-import editorStyle from "../editor.module.less";
-import WemetaRadioGroup from "@/components/wemeta-radio-group/index";
+
 import { useComponentStore } from '@/store/componentStore'
 import BottomBar from "@/components/BottomBar";
 import WemetaTextarea from "@/components/wemeta-textarea/index";
 import Taro, {useRouter, useUnload} from "@tarojs/taro";
+import { EComponentType } from "@/consts/enum";
 export default function Index() {
-  const router = useRouter();
-  const { id } = router.params;
-  const deltaNum = id ? 1 : 2
   let currentComponent = useComponentStore((state)=>  state.currentComponent);
   const { saveComponent } = useComponentStore();
   const [value, setValue] = useState(currentComponent?.data?.text ?? '');
-  const [radioValue, setRadioValue] = useState<string>(currentComponent?.data?.layout ?? 'center')
-  const radioList = [
-    {
-      text: "居中",
-      value: "center",
-      checked: false,
-    },
-    {
-      text: "左对齐",
-      value: "left",
-      checked: true,
-    },
-  ];
+  
   
   const handleSubmit = async () => {
     if(!currentComponent?.data.id){
@@ -40,12 +25,12 @@ export default function Index() {
     const c = {
       data: {
         text: value,
-        layout: radioValue,
+        layout: currentComponent?.data?.layout ?? 'center',
         id: currentComponent?.data.id,
         index: currentComponent?.data?.index,
       },
       enabled: currentComponent?.enabled ?? true,
-      type: "title",
+      type: EComponentType.title,
     };
 
     
@@ -57,12 +42,7 @@ export default function Index() {
   const onChange = (e: any) => {
     setValue(e);
   };
-  
 
-  const onRadioChange = (value: string) => {
-    setRadioValue(value)
-    return false;
-  };
 
   
   
@@ -70,12 +50,9 @@ export default function Index() {
 
   return (
     <PageCustom bgColor="global-light-green-bg">
-      <NavBarNormal backText="返回" >章节标题</NavBarNormal>
+      <NavBarNormal backText="返回">章节标题</NavBarNormal>
       <View className="flex flex-col items-center w-full">
-        <View className={editorStyle.container}>
-          <View
-            className={`${editorStyle.textInputContainer} ${editorStyle.underline}`}
-          >
+        <View className="w-full p-16">
             <WemetaTextarea
               value={value}
               onBlur={(value: string) => onChange(value)}
@@ -84,14 +61,6 @@ export default function Index() {
               autoFocus
             />
           </View>
-          <View className="pt-32">
-            <WemetaRadioGroup
-              radioList={radioList}
-              onChange={onRadioChange}
-              value={radioValue}
-            ></WemetaRadioGroup>
-          </View>
-        </View>
         <BottomBar>
           <View className="button-rounded button-primary flex-1" onClick={handleSubmit}>保存</View>
         </BottomBar>

+ 31 - 35
src/pages/editor-pages/editor.module.less

@@ -1,12 +1,10 @@
-.container{
-  padding: 16px;
-  width: 100%;
-  box-sizing: border-box;
-}
-.textInputContainer{
-  // background-color: white;
-  // border-radius: 20px;
-}
+// .container{
+//   padding: 16px;
+//   width: 100%;
+//   box-sizing: border-box;
+// }
+
+
 .textInput{
   color: #000;
   font-family: "PingFang SC";
@@ -21,9 +19,7 @@
   border: 1px solid transparent;
 }
 
-.underline{
-  // border-bottom: 1px solid rgba(0, 0, 0, 0.08);  
-}
+
 
 .textAreaContainer{
   display: flex;
@@ -79,29 +75,29 @@
   line-height: 22px;
 }
 
-.transitionBottom{
-  transition: bottom 0.2s linear;
-}
+// .transitionBottom{
+//   transition: bottom 0.2s linear;
+// }
 
 
-.formInputContainer{
-  padding: 12px 10px;
-  border-radius: 20px;
-  background-color: white;
-}
+// .formInputContainer{
+//   padding: 12px 10px;
+//   border-radius: 20px;
+//   background-color: white;
+// }
 
-.formLabel{
-  color: #000;
-  font-size: 14px;
-  font-style: normal;
-  font-weight: 500;
-  line-height: 28px; /* 183.333% */
-}
-.formLabelRequired{
-  color: rgba(0, 0, 0, 0.45);
-  font-family: "PingFang SC";
-  font-size: 14px;
-  font-style: normal;
-  font-weight: 500;
-  line-height: 28px;
-}
+// .formLabel{
+//   color: #000;
+//   font-size: 14px;
+//   font-style: normal;
+//   font-weight: 500;
+//   line-height: 28px; /* 183.333% */
+// }
+// .formLabelRequired{
+//   color: rgba(0, 0, 0, 0.45);
+//   font-family: "PingFang SC";
+//   font-size: 14px;
+//   font-style: normal;
+//   font-weight: 500;
+//   line-height: 28px;
+// }

+ 21 - 4
src/service/user.ts

@@ -1,11 +1,28 @@
 import { bluebookAiAgent } from "@/xiaolanbenlib/api/index";
-import Taro from "@tarojs/taro";
-import request from "@/xiaolanbenlib/module/axios.js";
-import { TUserInfo } from "@/types/user";
 
+import request from "@/xiaolanbenlib/module/axios.js";
+import { TUserInfo, TEntItem, TMyContact, TMyPrivacy } from "@/types/user";
 
 
 
+// 获取我的个人信息
 export const getMyInfo = () => {
   return request.get<TUserInfo>(`${bluebookAiAgent}api/v1/my/info`,)
-}
+}
+// 获取我的隐私设置
+export const getMyPrivacy = () => {
+  return request.get<TMyPrivacy>(`${bluebookAiAgent}api/v1/my/privacy/setting`,)
+}
+// 设置我的隐私设置
+export const saveMyPrivacy = (data: TMyPrivacy) => {
+  return request.put(`${bluebookAiAgent}api/v1/my/privacy/setting`, data)
+}
+// 获取我的归属企业列表
+export const getMyEntList = () => {
+  return request.get<TEntItem[]>(`${bluebookAiAgent}api/v1/my/entList`,)
+}
+// 提交联系我们
+export const saveMyContact = (data: TMyContact) => {
+  return request.put(`${bluebookAiAgent}api/v1/my/contactUs`, data)
+}
+

+ 80 - 71
src/store/componentStore.ts

@@ -1,10 +1,13 @@
 import { create } from "zustand";
-import { editAgentWebsite as _editAgentWebsite, editAgentAvatar, editAgentWebsite } from "@/service/agent";
+import {
+  editAgentWebsite as _editAgentWebsite,
+  editAgentAvatar,
+  editAgentWebsite,
+} from "@/service/agent";
 import { TComponentItem } from "@/types/agent";
 import { isSuccess } from "@/utils";
 
-
-function safeSwap(arr:any[], index1:number, index2: number) {
+function safeSwap(arr: any[], index1: number, index2: number) {
   if (
     index1 >= 0 &&
     index1 < arr.length &&
@@ -17,13 +20,14 @@ function safeSwap(arr:any[], index1:number, index2: number) {
 }
 
 export interface ComponentState {
-  agentId: string,
+  agentId: string;
   maxIndex: number; // 最大组件索引
   insertIndex: number; // 插入组件的索引
   components: TComponentItem[] | []; // 后期是否需要改成链表方便中间插入删除等操作??
   currentComponent: TComponentItem | null;
+  loading: boolean;
   setComponentList: (list: TComponentItem[], agentId: string) => void;
-  delComponent: (c: TComponentItem) => Promise<void>;
+  delComponent: (c: TComponentItem) => Promise<boolean>;
   saveComponent: (c: TComponentItem) => Promise<boolean>;
   insertComponent: (c: TComponentItem[]) => Promise<TComponentItem[] | null>;
   swapTwoComponent: (c: TComponentItem, direction: number) => Promise<void>;
@@ -50,27 +54,24 @@ export const sortComponentsByIndex = (a: TComponentItem, b: TComponentItem) => {
 
 export const useComponentStore = create<ComponentState>((set, get) => ({
   loading: false,
-  agentId: '',
+  agentId: "",
   components: [],
   currentComponent: null,
   maxIndex: 1,
   insertIndex: -1,
   setComponentList: (list: TComponentItem[], agentId: string) => {
     let sorted = list.sort(sortComponentsByIndex);
-    set({agentId, components: sorted, maxIndex: getMaxIndex(sorted) });
+    set({ agentId, components: sorted, maxIndex: getMaxIndex(sorted) });
   },
   insertComponent: async (list: TComponentItem[]) => {
-
-
     const insertIndex = get().insertIndex;
     let _components = get().components.sort(sortComponentsByIndex);
-    console.log('current components list:', _components)
-    const _componentsLen = _components.length
+    console.log("current components list:", _components);
+    const _componentsLen = _components.length;
 
-    
     console.log("insertIndex:", insertIndex);
     if (insertIndex === -1) {
-      console.log('顶部插入')
+      console.log("顶部插入");
       // 顶部插入, 原组件列表所有 index + list.length
       _components = _components.map((item: TComponentItem) => {
         item.data.index = item.data.index + list.length;
@@ -78,21 +79,21 @@ export const useComponentStore = create<ComponentState>((set, get) => ({
       });
       _components = [...list, ..._components];
     } else if (insertIndex === _componentsLen - 1) {
-      console.log('底部插入')
+      console.log("底部插入");
       // 底部插入, 所有新插入的组件 index 需要加上已存在组件列表长度
-      list = list.map( c => {
-        c.data.index =  c.data.index + _componentsLen
-        return c
-      })
+      list = list.map((c) => {
+        c.data.index = c.data.index + _componentsLen;
+        return c;
+      });
       _components = [..._components, ...list];
     } else {
-      // 中间插入, 
-      console.log('中间插入')
+      // 中间插入,
+      console.log("中间插入");
       const restIndex = insertIndex + 1;
-      list = list.map( c => {
-        c.data.index = c.data.index + restIndex
-        return c 
-      })
+      list = list.map((c) => {
+        c.data.index = c.data.index + restIndex;
+        return c;
+      });
 
       let rest = _components.slice(restIndex).map((item) => {
         if (item.data.index) {
@@ -103,51 +104,51 @@ export const useComponentStore = create<ComponentState>((set, get) => ({
       });
 
       _components = [..._components.slice(0, restIndex), ...list, ...rest];
-      console.log(_components,111)
+      console.log(_components, 111);
     }
 
+    set({ components: _components });
 
-    set({components: _components})
-    
     return _components;
   },
   saveComponent: async (c: TComponentItem) => {
     console.log("saveComponent");
 
     if (c.data.id === undefined) {
-      console.log('没有 id 无法编辑该组件')
-      return false
+      console.log("没有 id 无法编辑该组件");
+      return false;
     }
 
     const insertIndex = get().insertIndex;
     const agentId = get().agentId;
     const components = [...get().components];
     console.log(c.data.id, insertIndex);
-    
-    const edit = components.find(item => item.data.id === c.data.id)
 
-    if(edit){
-      edit.data = c.data
-      edit.enabled = c.enabled
+    const edit = components.find((item) => item.data.id === c.data.id);
+
+    if (edit) {
+      edit.data = c.data;
+      edit.enabled = c.enabled;
     }
 
     // 简单更新组件
     console.log("a: ", components);
     console.log("b: ", get().components);
-    
+
     // 普通更新或新建
-    const {status} = await editAgentWebsite(agentId, {components: components});
-    if(isSuccess(status)){
+    const { status } = await editAgentWebsite(agentId, {
+      components: components,
+    });
+    if (isSuccess(status)) {
       set({
-        components
-      })
-      return true
+        components,
+      });
+      return true;
     }
-    return false
-    
+    return false;
   },
   setInsertIndex: (index) => {
-    console.log(index,' setInsertIndex')
+    console.log(index, " setInsertIndex");
     set({ insertIndex: index });
   },
   setCurrentComponent: (component: TComponentItem | null) => {
@@ -156,27 +157,31 @@ export const useComponentStore = create<ComponentState>((set, get) => ({
     return component;
   },
   delComponent: async (c) => {
-    set({components: []})
-    
-    // if (!c.data.id) {
-    //   return;
-    // }
-    // set((state) => {
-    //   const filtered = state.components
-    //   .filter((item: TComponentItem) => item?.data.id !== c.data.id)
-    //   .sort(sortComponentsByIndex)
-    //   .map((item: TComponentItem, index) => {
-    //     return {
-    //       ...item,
-    //       index: index + 1,
-    //     };
-    //   });
-    //   return {
-    //     components: [...filtered],
-    //   };
-    // });
+    const { components, agentId } = get();
+    // todo: 此处是否需要过滤一些没有 id 的脏数据组件
+    if (!c.data.id || !agentId) {
+      return false;
+    }
+
+    const filtered = components
+      .filter((item: TComponentItem) => item?.data.id !== c.data.id)
+      .sort(sortComponentsByIndex)
+      .map((item: TComponentItem, index) => {
+        return {
+          ...item,
+          index: index + 1,
+        };
+      });
+    const { status } = await editAgentWebsite(agentId, {
+      components: filtered,
+    });
+    if (isSuccess(status)) {
+      set({ components: filtered });
+      return true;
+    }
+    return false;
   },
-  
+
   calcMaxIndex: (components?: TComponentItem[]) => {
     set((state) => {
       return { maxIndex: getMaxIndex(components ?? state.components) };
@@ -205,20 +210,24 @@ export const useComponentStore = create<ComponentState>((set, get) => ({
     } else if (direction === 1) {
       destComponent = components[arrIndex + 1];
     }
-    
-    
-    const tmpList = [...components]
 
-    
+    const tmpList = [...components];
+
     if (destComponent) {
       destComponent = { ...destComponent };
-      const destComponentIndex = components.findIndex((item) => item.data.id === destComponent?.data.id);
+      const destComponentIndex = components.findIndex(
+        (item) => item.data.id === destComponent?.data.id
+      );
       const i = cur.data.index;
       cur.data.index = destComponent.data.index;
       destComponent.data.index = i;
-      const r = safeSwap(tmpList, arrIndex, destComponentIndex) as TComponentItem[]
-      await editAgentWebsite(get().agentId, {components: r})
-      set({components: r})
+      const r = safeSwap(
+        tmpList,
+        arrIndex,
+        destComponentIndex
+      ) as TComponentItem[];
+      await editAgentWebsite(get().agentId, { components: r });
+      set({ components: r });
     }
   },
 }));

+ 1 - 1
src/types/agent.ts

@@ -22,7 +22,7 @@ export type TComponentItem = {
     [property: string]: any;
   },
   enabled: boolean,
-  type: string|EComponentType
+  type: EComponentType
 }
 export type TAgentDetail = {
   address?: string,

+ 25 - 1
src/types/user.ts

@@ -5,4 +5,28 @@ export type TUserInfo = {
   userId?: number;
   userName?: string;
 };
-    
+
+export type TEntItem = {
+  entId: number | string;
+  entName: string;
+  expireTime: string;
+  isExpired: boolean;
+  knowledgeCnt: number;
+};
+
+export type TMyContact = {
+  entName: string;
+  mobileOrWechat: string;
+  position: string;
+  reqDetail: string;
+};
+
+
+// contactVisibleMyInfo (boolean, optional): 我的联系人可见我的敏感信息 ,
+// directVisibleMyInfo (boolean, optional): 直接时敏感信息可见 ,
+// forwardVisibleMyInfo (boolean, optional): 转发时敏感信息可见
+export type TMyPrivacy = {
+  contactVisibleMyInfo: boolean,
+  directVisibleMyInfo: boolean,
+  forwardVisibleMyInfo: boolean
+}

+ 5 - 5
src/utils/http.ts

@@ -17,7 +17,7 @@ const _uploadFile = (
   callback: (
     data: {
       publicUrl: string;
-      fileId: string;
+      file: string;
     } | null
   ) => void
 ) => {
@@ -50,9 +50,9 @@ const _uploadFile = (
 };
 
 export async function uploadImage(tmpPath: string, scene: EUploadFileScene = EUploadFileScene.OTHER): Promise<{
-  code: number;
-  data: string;
-  msg: string;
+  publicUrl: string;
+  file: string;
+    
 } | null> {
   return new Promise((resolve) => {
     _uploadFile(tmpPath, "file", scene, (r) => {
@@ -65,7 +65,7 @@ export async function uploadFile(
   scene: EUploadFileScene = EUploadFileScene.OTHER
 ): Promise<{
   publicUrl: string;
-  fileId: string;
+  file: string;
 } | null> {
   return new Promise((resolve) => {
     _uploadFile(tmpPath, "file", scene, (data) => {