Commit eb3228d4c781ff21418acf93e8ed4036a72520db
1 parent
da0ba105
文件列表会显示图片缩略图,点击缩略图可以预览大图。非图片文件在列表页面会显示下载按钮。点击即可下载。
Showing
2 changed files
with
19 additions
and
8 deletions
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/file/FileRespVO.java
| ... | ... | @@ -13,6 +13,9 @@ public class FileRespVO { |
| 13 | 13 | @ApiModelProperty(value = "文件编号", required = true, example = "1024") |
| 14 | 14 | private Long id; |
| 15 | 15 | |
| 16 | + @ApiModelProperty(value = "配置编号", required = true, example = "11") | |
| 17 | + private Long configId; | |
| 18 | + | |
| 16 | 19 | @ApiModelProperty(value = "文件路径", required = true, example = "yudao.jpg") |
| 17 | 20 | private String path; |
| 18 | 21 | ... | ... |
yudao-ui-admin/src/views/infra/file/index.vue
| ... | ... | @@ -31,13 +31,17 @@ |
| 31 | 31 | <el-table-column :show-overflow-tooltip="true" label="文件 URL" align="center" min-width="400" prop="url" /> |
| 32 | 32 | <el-table-column label="文件大小" align="center" prop="size" width="120" :formatter="sizeFormat" /> |
| 33 | 33 | <el-table-column label="文件类型" align="center" prop="type" width="210" /> |
| 34 | -<!-- <el-table-column label="文件内容" align="center" prop="content">--> | |
| 35 | -<!-- <template slot-scope="scope">--> | |
| 36 | -<!-- <img v-if="scope.row.type&&scope.row.type.indexOf('image/') === 0"--> | |
| 37 | -<!-- width="200px" :src="getFileUrl + scope.row.id">--> | |
| 38 | -<!-- <i v-else>非图片,无法预览</i>--> | |
| 39 | -<!-- </template>--> | |
| 40 | -<!-- </el-table-column>--> | |
| 34 | + <el-table-column label="文件内容" align="center" prop="content" min-width="150px"> | |
| 35 | + <template slot-scope="scope"> | |
| 36 | + <image-preview v-if="scope.row.type&&scope.row.type.indexOf('image/') === 0" :src="scope.row.url" | |
| 37 | + :width="'100px'"></image-preview> | |
| 38 | + <i v-else>无法预览,点击 | |
| 39 | + <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" | |
| 40 | + :href="getFileUrl+scope.row.configId+'/get/' + scope.row.path">下载 | |
| 41 | + </el-link> | |
| 42 | + </i> | |
| 43 | + </template> | |
| 44 | + </el-table-column> | |
| 41 | 45 | <el-table-column label="上传时间" align="center" prop="createTime" width="180"> |
| 42 | 46 | <template slot-scope="scope"> |
| 43 | 47 | <span>{{ parseTime(scope.row.createTime) }}</span> |
| ... | ... | @@ -79,12 +83,16 @@ |
| 79 | 83 | <script> |
| 80 | 84 | import { deleteFile, getFilePage } from "@/api/infra/file"; |
| 81 | 85 | import {getAccessToken} from "@/utils/auth"; |
| 86 | +import ImagePreview from "@/components/ImagePreview"; | |
| 82 | 87 | |
| 83 | 88 | export default { |
| 84 | 89 | name: "File", |
| 90 | + components: { | |
| 91 | + ImagePreview | |
| 92 | + }, | |
| 85 | 93 | data() { |
| 86 | 94 | return { |
| 87 | - getFileUrl: process.env.VUE_APP_BASE_API + '/admin-api/infra/file/get/', | |
| 95 | + getFileUrl: process.env.VUE_APP_BASE_API + '/admin-api/infra/file/', | |
| 88 | 96 | // 遮罩层 |
| 89 | 97 | loading: true, |
| 90 | 98 | // 显示搜索条件 | ... | ... |