换用el-image-viewer
This commit is contained in:
parent
3ca39fc010
commit
de58ca78be
@ -72,10 +72,16 @@
|
|||||||
:data="labels"
|
:data="labels"
|
||||||
></el-transfer>
|
></el-transfer>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
<el-image-viewer
|
||||||
|
v-if="previewVisible"
|
||||||
|
:url-list="previewUrlList"
|
||||||
|
:initial-index="previewIndex"
|
||||||
|
@close="previewVisible = false"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, h } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import { useStore } from 'vuex'
|
import { useStore } from 'vuex'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import prettyBytes from 'pretty-bytes'
|
import prettyBytes from 'pretty-bytes'
|
||||||
@ -94,6 +100,9 @@ const labelList = ref<string[]>([])
|
|||||||
const curId = ref<string | null>(null)
|
const curId = ref<string | null>(null)
|
||||||
const modifyModal = ref(false)
|
const modifyModal = ref(false)
|
||||||
const isUploading = ref(false)
|
const isUploading = ref(false)
|
||||||
|
const previewVisible = ref(false)
|
||||||
|
const previewUrlList = ref<string[]>([])
|
||||||
|
const previewIndex = ref(0)
|
||||||
|
|
||||||
function renderFunc(h: Function, option: any) {
|
function renderFunc(h: Function, option: any) {
|
||||||
return h('span', null, option.label)
|
return h('span', null, option.label)
|
||||||
@ -152,13 +161,10 @@ function uploadError(error: Error): void {
|
|||||||
ElMessage.error(error.message)
|
ElMessage.error(error.message)
|
||||||
}
|
}
|
||||||
function preview(row: SourceImageModel): void {
|
function preview(row: SourceImageModel): void {
|
||||||
ElMessageBox({
|
const index = sourceImageData.value.findIndex(item => item._id === row._id)
|
||||||
title: '图片预览',
|
previewUrlList.value = sourceImageData.value.map(item => `/api/v2/common/randomBg?id=${item._id}`)
|
||||||
message: h('img', { style: `width:500px`, src: `/api/v2/common/randomBg?id=${row._id}` }, ''),
|
previewIndex.value = index >= 0 ? index : 0
|
||||||
showCancelButton: false,
|
previewVisible.value = true
|
||||||
confirmButtonText: '关闭',
|
|
||||||
customStyle: {width: '530px', maxWidth: 'unset'}
|
|
||||||
}).catch(() => {})
|
|
||||||
}
|
}
|
||||||
function modifyTags(item: SourceImageModel): void {
|
function modifyTags(item: SourceImageModel): void {
|
||||||
curModifyLabels.value.length = 0
|
curModifyLabels.value.length = 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user