shenwu 6 kuukautta sitten
vanhempi
commit
1d2c1533a5

+ 4 - 3
src/components/CropperImg/index.tsx

@@ -1,4 +1,4 @@
-import { dataURLtoFile } from '@/utils/compress';
+import { dataURLtoFile } from '@/utils/index';
 import { useDebounce } from 'ahooks';
 import { Button, Col, Form, InputNumber, Modal, Row } from 'antd';
 import { RcFile } from 'antd/lib/upload';
@@ -70,7 +70,7 @@ const CropperImg: React.FC<Props> = (props) => {
   useEffect(() => {
     if (cropperRef.current && debouncedValue?.width) {
       console.log(cropperRef.current?.cropper, debouncedValue);
-      cropperRef.current?.cropper.setData(debouncedValue);
+      // cropperRef.current?.cropper.setData(debouncedValue);
     }
   }, [debouncedValue]);
 
@@ -140,6 +140,7 @@ const CropperImg: React.FC<Props> = (props) => {
                 border: '1px solid #efefef',
               }}
               initialAspectRatio={1}
+              aspectRatio={size && size?.width / size?.height}
               preview=".img-preview"
               src={image}
               viewMode={1}
@@ -159,7 +160,7 @@ const CropperImg: React.FC<Props> = (props) => {
               //     cropperRef.current = instance;
               //     instance.zoomTo(0.6);
               // }}
-              crop={() => {}}
+              crop={() => { }}
             />
           </Col>
           <Col span={8}>

+ 6 - 6
src/components/uploadImg/index.tsx

@@ -1,11 +1,11 @@
 import CropperImg from '@/components/CropperImg';
 import { useOss } from '@/Hook/useOss';
+import { PlusOutlined } from '@ant-design/icons';
 import { message, Upload } from 'antd';
 import { RcFile } from 'antd/es/upload';
 import dayjs from 'dayjs';
 import React, { useEffect, useState } from 'react';
 import styles from './index.less';
-import { PlusOutlined } from '@ant-design/icons';
 type CompareType = '<' | '<=' | '>' | '>=' | '=' | '!=';
 
 interface Props {
@@ -34,13 +34,13 @@ const UploadImg: React.FC<Props> = ({ value, onChange, size, type, isCropper, is
     <div>
       <div style={{ height: 45, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
         {' '}
-        <PlusOutlined/>
+        <PlusOutlined />
       </div>
       <div style={{ display: 'flex', flexFlow: 'column' }}>
         <span>上传图片</span>
-        <span style={{ color: '#999', fontSize: 10 }}>
-          {size?.width} * {size?.height}
-        </span>
+        {size && <span style={{ color: '#999', fontSize: 10 }}>
+          &gt;={size?.width} *  &gt;={size?.height}
+        </span>}
       </div>
     </div>
   );
@@ -63,7 +63,7 @@ const UploadImg: React.FC<Props> = ({ value, onChange, size, type, isCropper, is
         accept="image/png,image/jpg,image/jpeg"
         action="#"
         showUploadList={false}
-        customRequest={() => {}}
+        customRequest={() => { }}
         className={imageUrl ? styles.upLoadTrue : ''}
         beforeUpload={(file: RcFile): any => {
           if (file.size > 10485760) {

+ 6 - 4
src/pages/distribution/miniprogram/pagesManage/formComp.tsx

@@ -37,7 +37,7 @@ const FormComp = forwardRef((props: any, ref?: any) => {
             <ProFormList
                 name="appPageConfigDTOList"
                 creatorButtonProps={
-                    {creatorButtonText:"新增页面"}
+                    { creatorButtonText: "新增页面" }
                 }
                 // label="页面配置"
                 itemRender={({ listDom, action }, { record }) => {
@@ -66,16 +66,18 @@ const FormComp = forwardRef((props: any, ref?: any) => {
                     </ProFormGroup>
                     <ProFormGroup direction='vertical'>
                         <ProFormText name="shareTitles" label="分享标题" />
-                        <ProFormTextArea name="pageDesc" label="页面描述" />
+                        <ProFormTextArea name="pageDesc" label="页面描述" fieldProps={{
+                            rows: 1,  // 设置初始行数为 1
+                        }} />
                     </ProFormGroup>
                     <ProForm.Item name="sharePicUrl" label="分享图片" >
                         <UploadImg
                             size={{
                                 width: 300,
-                                height: 400,
+                                height: 300,
                                 evalW: '!=',
                                 evalH: '!=',
-                                msg: '需要图片大小300*400',
+                                msg: '需要图片大小300*300',
                             }}
                             isEdit={true}
                             type="image"

+ 4 - 1
src/pages/distribution/miniprogram/pagesManage/tableConfig.tsx

@@ -1,5 +1,5 @@
 import { ProColumns } from '@ant-design/pro-components';
-import { Badge, Button, Popconfirm, Space, TableColumnsType } from 'antd';
+import { Badge, Button, Image, Space, TableColumnsType } from 'antd';
 
 export const columns = (edit: (params: any) => void): ProColumns<any>[] => {
   return [
@@ -63,6 +63,9 @@ export const childrenColumns = (openAdd:(id:any)=>void): TableColumnsType<any> =
       title: "分享图片",
       dataIndex: 'sharePicUrl',
       align: "center",
+      render:(_,row)=>{
+        return <Image src={row.sharePicUrl} style={{width:25}} />
+      }
     },
     {
       title: "分享标题",

+ 12 - 0
src/utils/index.ts

@@ -96,3 +96,15 @@ export function convertMenu(onlineMenu: any, localMenu: any) {
 
   return convert(onlineMenu, localMenuMap);
 }
+/** base64转File */
+export const dataURLtoFile = (dataurl: any, filename: any) => {
+  let arr = dataurl.split(','),
+      mime = arr[0].match(/:(.*?);/)[1],
+      bstr = atob(arr[1]),
+      n = bstr.length,
+      u8arr = new Uint8Array(n);
+  while (n--) {
+      u8arr[n] = bstr.charCodeAt(n);
+  }
+  return new File([u8arr], filename, { type: mime });
+};