Browse Source

上传优化

gzb
wangzhonglu 1 year ago
parent
commit
6b0331132a
2 changed files with 72 additions and 53 deletions
  1. 1
    1
      src/App.vue
  2. 71
    52
      src/views/news/index.vue

+ 1
- 1
src/App.vue View File

158
   padding: 16px 0;
158
   padding: 16px 0;
159
   text-align: right;
159
   text-align: right;
160
 }
160
 }
161
-.ivu-radio-group {
161
+.ivu-form-item .ivu-radio-group {
162
   display: flex;
162
   display: flex;
163
   justify-content: flex-start;
163
   justify-content: flex-start;
164
 }
164
 }

+ 71
- 52
src/views/news/index.vue View File

78
           </RadioGroup>
78
           </RadioGroup>
79
         </FormItem>
79
         </FormItem>
80
         <FormItem label="封面" prop="newspic">
80
         <FormItem label="封面" prop="newspic">
81
-          <Upload
82
-            :format="pictureFormat"
83
-            :max-size="10 * 1024"
84
-            action
85
-            :before-upload="
86
-              (file) => {
87
-                beforeUploadPicture(file, addForm);
88
-                return false;
89
-              }
90
-            "
91
-            :accept="getPictureAccept()"
92
-            :show-upload-list="false"
93
-          >
94
-            <img
95
-              style="width: 200px"
96
-              v-if="addForm.newspic"
97
-              :src="$api.showImageUrl + addForm.newspic"
98
-            />
99
-            <!-- <Button v-else icon="ios-cloud-upload-outline">上传封面</Button> -->
100
-            <div class="upload_img" v-else>
101
-              <Icon
102
-                type="ivu-icon ivu-icon- iconfont icon-shangchuan"
103
-                size="42"
104
-                color="#e6e6e6"
81
+          <div class="form_item_upload">
82
+            <Upload
83
+              :format="pictureFormat"
84
+              :max-size="10 * 1024"
85
+              action
86
+              :before-upload="
87
+                (file) => {
88
+                  beforeUploadPicture(file, addForm);
89
+                  return false;
90
+                }
91
+              "
92
+              :accept="getPictureAccept()"
93
+              :show-upload-list="false"
94
+            >
95
+              <img
96
+                style="width: 200px"
97
+                v-if="addForm.newspic"
98
+                :src="$api.showImageUrl + addForm.newspic"
105
               />
99
               />
106
-              <p class="shangchuan_btn">上传图片</p>
100
+              <!-- <Button v-else icon="ios-cloud-upload-outline">上传封面</Button> -->
101
+              <div class="upload_img" v-else>
102
+                <Icon
103
+                  type="ivu-icon ivu-icon- iconfont icon-shangchuan"
104
+                  size="42"
105
+                  color="#e6e6e6"
106
+                />
107
+                <p class="shangchuan_btn">上传图片</p>
108
+              </div>
109
+            </Upload>
110
+            <div class="uptype">
111
+              <p>支持上传格式(10MB以内):</p>
112
+              <p>jpg、jpeg、png、bmp、jfif、webp.</p>
107
             </div>
113
             </div>
108
-          </Upload>
114
+          </div>
109
         </FormItem>
115
         </FormItem>
110
         <FormItem label="置顶" prop="newsup">
116
         <FormItem label="置顶" prop="newsup">
111
           <RadioGroup v-model="addForm.newsup">
117
           <RadioGroup v-model="addForm.newsup">
161
         :model="modifyForm"
167
         :model="modifyForm"
162
       >
168
       >
163
         <FormItem label="封面" prop="newspic">
169
         <FormItem label="封面" prop="newspic">
164
-          <Upload
165
-            :format="pictureFormat"
166
-            :max-size="10 * 1024"
167
-            action
168
-            :before-upload="
169
-              (file) => {
170
-                beforeUploadPicture(file, modifyForm);
171
-                return false;
172
-              }
173
-            "
174
-            :accept="getPictureAccept()"
175
-            :show-upload-list="false"
176
-          >
177
-            <img
178
-              style="width: 200px"
179
-              v-if="modifyForm.newspic"
180
-              :src="$api.showImageUrl + modifyForm.newspic"
181
-            />
182
-            <!-- <Button v-else icon="ios-cloud-upload-outline">上传封面</Button> -->
183
-            <div class="upload_img" v-else>
184
-              <Icon
185
-                type="ivu-icon ivu-icon- iconfont icon-shangchuan"
186
-                size="42"
187
-                color="#e6e6e6"
170
+          <div class="form_item_upload">
171
+            <Upload
172
+              :format="pictureFormat"
173
+              :max-size="10 * 1024"
174
+              action
175
+              :before-upload="
176
+                (file) => {
177
+                  beforeUploadPicture(file, modifyForm);
178
+                  return false;
179
+                }
180
+              "
181
+              :accept="getPictureAccept()"
182
+              :show-upload-list="false"
183
+            >
184
+              <img
185
+                style="width: 200px"
186
+                v-if="modifyForm.newspic"
187
+                :src="$api.showImageUrl + modifyForm.newspic"
188
               />
188
               />
189
-              <p class="shangchuan_btn">上传图片</p>
189
+              <!-- <Button v-else icon="ios-cloud-upload-outline">上传封面</Button> -->
190
+              <div class="upload_img" v-else>
191
+                <Icon
192
+                  type="ivu-icon ivu-icon- iconfont icon-shangchuan"
193
+                  size="42"
194
+                  color="#e6e6e6"
195
+                />
196
+                <p class="shangchuan_btn">上传图片</p>
197
+              </div>
198
+            </Upload>
199
+            <div class="uptype">
200
+              <p>支持上传格式(10MB以内):</p>
201
+              <p>jpg、jpeg、png、bmp、jfif、webp.</p>
190
             </div>
202
             </div>
191
-          </Upload>
203
+          </div>
192
         </FormItem>
204
         </FormItem>
193
         <FormItem label="置顶" prop="newsup">
205
         <FormItem label="置顶" prop="newsup">
194
           <RadioGroup v-model="modifyForm.newsup">
206
           <RadioGroup v-model="modifyForm.newsup">
616
   padding: 16px 0;
628
   padding: 16px 0;
617
   text-align: right;
629
   text-align: right;
618
 }
630
 }
631
+.form_item_upload {
632
+  display: flex;
633
+  justify-content: flex-start;
634
+  .uptype {
635
+    padding-left: 10px;
636
+  }
637
+}
619
 .upload_img {
638
 .upload_img {
620
   padding-top: 10px;
639
   padding-top: 10px;
621
   width: 198px;
640
   width: 198px;

Loading…
Cancel
Save