mirror of
https://github.com/Powerful-517/yys-editor.git
synced 2026-03-05 15:05:27 +00:00
fix(selector): preserve image aspect ratio in dialog
This commit is contained in:
@@ -1,8 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog
|
<el-dialog v-model="show" :title="config.title">
|
||||||
v-model="show"
|
|
||||||
:title="config.title"
|
|
||||||
>
|
|
||||||
<span v-if="config.currentItem">
|
<span v-if="config.currentItem">
|
||||||
当前选择:{{ config.currentItem[config.itemRender.labelField] }}
|
当前选择:{{ config.currentItem[config.itemRender.labelField] }}
|
||||||
</span>
|
</span>
|
||||||
@@ -36,13 +33,14 @@
|
|||||||
style="display: flex; flex-direction: column; justify-content: center"
|
style="display: flex; flex-direction: column; justify-content: center"
|
||||||
>
|
>
|
||||||
<el-button
|
<el-button
|
||||||
|
class="selector-button"
|
||||||
:style="`width: ${imageSize}px; height: ${imageSize}px;`"
|
:style="`width: ${imageSize}px; height: ${imageSize}px;`"
|
||||||
@click="handleSelect(item)"
|
@click="handleSelect(item)"
|
||||||
>
|
>
|
||||||
<img
|
<span
|
||||||
:src="item[config.itemRender.imageField]"
|
class="selector-image-frame"
|
||||||
:style="`width: ${imageSize - 1}px; height: ${imageSize - 1}px;`"
|
:style="`width: ${imageSize - 1}px; height: ${imageSize - 1}px; background-image: url('${item[config.itemRender.imageField]}');`"
|
||||||
>
|
/>
|
||||||
</el-button>
|
</el-button>
|
||||||
<span style="text-align: center; display: block;">
|
<span style="text-align: center; display: block;">
|
||||||
{{ item[config.itemRender.labelField] }}
|
{{ item[config.itemRender.labelField] }}
|
||||||
@@ -114,3 +112,19 @@ const handleSelect = (item: any) => {
|
|||||||
activeTab.value = 'ALL'
|
activeTab.value = 'ALL'
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.selector-button {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selector-image-frame {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
overflow: hidden;
|
||||||
|
background-position: center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: contain;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user