Pārlūkot izejas kodu

fix(bugs): 修改上传头像加载logo

tangning 3 gadi atpakaļ
vecāks
revīzija
7bf240dd8f

+ 3 - 1
src/components/Cropper/src/CopperModal.vue

@@ -15,6 +15,7 @@
             v-if="src"
             :src="src"
             height="300px"
+            :aspectRatio="aspectRatio"
             :circled="circled"
             @cropend="handleCropend"
             @ready="handleReady"
@@ -126,13 +127,14 @@
   type apiFunParams = { file: Blob; name: string; filename: string };
 
   const props = {
-    circled: { type: Boolean, default: true },
+    circled: { type: Boolean, default: false },
     src: { type: String, default: '' },
     title: { type: String },
     maxSize: { type: Number, default: 5 },
     uploadApi: {
       type: Function as PropType<(params: apiFunParams) => Promise<any>>,
     },
+    aspectRatio: { type: Number, default: 1 },
   };
 
   export default defineComponent({

+ 2 - 0
src/components/Cropper/src/Cropper.vue

@@ -47,6 +47,7 @@
     src: { type: String, required: true },
     alt: { type: String },
     circled: { type: Boolean, default: false },
+    aspectRatio: { type: Number, default: 1 },
     realTimePreview: { type: Boolean, default: true },
     height: { type: [String, Number], default: '360px' },
     crossorigin: {
@@ -104,6 +105,7 @@
         }
         cropper.value = new Cropper(imgEl, {
           ...defaultOptions,
+          aspectRatio: props.aspectRatio,
           ready: () => {
             isReady.value = true;
             realTimeCroppered();

+ 2 - 0
src/components/Cropper/src/CropperAvatar.vue

@@ -28,6 +28,7 @@
       :title="title"
       :maxSize="5"
       :circled="circled"
+      :aspectRatio="aspectRatio"
       :src="sourceValue"
     />
   </div>
@@ -56,6 +57,7 @@
     width: { type: [String, Number], default: '200px' },
     value: { type: String },
     maxSize: { type: Number, default: 5 },
+    aspectRatio: { type: Number, default: 1 },
     title: { type: String },
     showBtn: { type: Boolean, default: true },
     btnProps: { type: Object as PropType<ButtonProps> },

+ 2 - 0
src/views/corporation/index.vue

@@ -6,6 +6,8 @@
         <CropperAvatar
           :showBtn="false"
           :width="80"
+          :aspectRatio="2"
+          :circled="false"
           :uploadApi="uploadLogoApi"
           :value="record.sceneLogo"
           :title="t('routes.corporation.sceneLogo')"