|
|
@@ -268,7 +268,7 @@
|
|
|
v-for="(source, index) in sources"
|
|
|
:key="index"
|
|
|
class="c-card u-pointer"
|
|
|
- @click="onView(source.keyName)"
|
|
|
+ @click="onView(source)"
|
|
|
>
|
|
|
<div class="c-card__content">
|
|
|
<i
|
|
|
@@ -278,16 +278,11 @@
|
|
|
@click.stop="onDelAsset(index)"
|
|
|
/>
|
|
|
<i
|
|
|
- v-if="isImage"
|
|
|
+ v-if="source.thumbnailUrl"
|
|
|
class="o-image"
|
|
|
- :style="{ 'background-image': `url('${source.url}')` }"
|
|
|
+ :style="{ 'background-image': `url('${source.thumbnailUrl}')` }"
|
|
|
/>
|
|
|
- <div
|
|
|
- v-else
|
|
|
- class="c-card__text u-ellipsis"
|
|
|
- >
|
|
|
- {{ source.name }}
|
|
|
- </div>
|
|
|
+ <div class="c-card__text u-ellipsis">{{ source.name }}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</draggable>
|
|
|
@@ -332,7 +327,7 @@
|
|
|
>
|
|
|
<div
|
|
|
class="o-image"
|
|
|
- :style="{ 'background-image': `url('${item.url}')` }"
|
|
|
+ :style="{ 'background-image': `url('${item.thumbnailUrl}')` }"
|
|
|
>
|
|
|
<span class="c-card__name u-ellipsis">{{ item.originalName }}</span>
|
|
|
</div>
|
|
|
@@ -409,6 +404,7 @@ export default {
|
|
|
list: this.getAssets,
|
|
|
transform: this.transformAsset,
|
|
|
cols: [
|
|
|
+ { prop: 'file', label: '缩略图', type: 'asset' },
|
|
|
{ prop: 'originalName', label: '名称' },
|
|
|
{
|
|
|
type: 'invoke', render: [
|
|
|
@@ -592,12 +588,6 @@ export default {
|
|
|
this.selectedWidgetIndex -= 1
|
|
|
}
|
|
|
},
|
|
|
- transformImage (asset) {
|
|
|
- return {
|
|
|
- ...asset,
|
|
|
- url: getThumbnailUrl(asset.keyName)
|
|
|
- }
|
|
|
- },
|
|
|
onEditAssets (attr) {
|
|
|
this.widgetAttr = attr
|
|
|
if (attr.options && attr.options.solo) {
|
|
|
@@ -605,9 +595,17 @@ export default {
|
|
|
} else {
|
|
|
this.sources = this.widget[attr.key].map(
|
|
|
this.isImage
|
|
|
- ? this.transformImage
|
|
|
+ ? asset => {
|
|
|
+ return {
|
|
|
+ ...asset,
|
|
|
+ thumbnailUrl: getThumbnailUrl(asset.keyName)
|
|
|
+ }
|
|
|
+ }
|
|
|
: asset => {
|
|
|
- return { ...asset }
|
|
|
+ return {
|
|
|
+ ...asset,
|
|
|
+ thumbnailUrl: asset.thumbnail && getThumbnailUrl(asset.thumbnail)
|
|
|
+ }
|
|
|
}
|
|
|
)
|
|
|
this.dialogVisibleAssets = true
|
|
|
@@ -626,9 +624,12 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
onSaveAssets () {
|
|
|
- this.changeAttr(this.sources.map(({ name, keyName, duration, size, md5 }) => {
|
|
|
+ this.changeAttr(this.sources.map(({ name, keyName, thumbnail, duration, size, md5 }) => {
|
|
|
const source = { name, keyName, size, md5 }
|
|
|
if (!this.isImage) {
|
|
|
+ if (thumbnail) {
|
|
|
+ source.thumbnail = thumbnail
|
|
|
+ }
|
|
|
source.duration = duration
|
|
|
}
|
|
|
return source
|
|
|
@@ -649,10 +650,13 @@ export default {
|
|
|
if (asset.type === AssetType.IMAGE) {
|
|
|
return {
|
|
|
...asset,
|
|
|
- url: getThumbnailUrl(asset.keyName)
|
|
|
+ thumbnailUrl: getThumbnailUrl(asset.thumbnail)
|
|
|
}
|
|
|
}
|
|
|
- return asset
|
|
|
+ return {
|
|
|
+ ...asset,
|
|
|
+ file: { thumbnail: asset.thumbnail }
|
|
|
+ }
|
|
|
},
|
|
|
onView (keyName) {
|
|
|
this.onViewAsset({ type: this.widgetAttr.options.type, keyName })
|
|
|
@@ -660,7 +664,7 @@ export default {
|
|
|
onViewAsset ({ type, keyName }) {
|
|
|
this.$refs.previewDialog.show({ type, url: keyName })
|
|
|
},
|
|
|
- onChoosenAsset ({ originalName, keyName, url, duration, size, md5 }) {
|
|
|
+ onChoosenAsset ({ originalName, keyName, thumbnail, thumbnailUrl, duration, size, md5 }) {
|
|
|
const source = {
|
|
|
name: originalName,
|
|
|
keyName,
|
|
|
@@ -669,8 +673,12 @@ export default {
|
|
|
}
|
|
|
if (this.dialogVisibleAssets) {
|
|
|
if (this.isImage) {
|
|
|
- source.url = url
|
|
|
+ source.thumbnailUrl = thumbnailUrl
|
|
|
} else {
|
|
|
+ if (thumbnail) {
|
|
|
+ source.thumbnail = thumbnail
|
|
|
+ source.thumbnailUrl = getThumbnailUrl(thumbnail)
|
|
|
+ }
|
|
|
source.duration = duration
|
|
|
}
|
|
|
this.sources.unshift(source)
|