Merge pull request 'zxl' (#218) from zxl into main

Reviewed-on: #218
This commit is contained in:
zhangxuelin 2025-01-10 15:07:42 +08:00
commit 125d360c52
2 changed files with 33 additions and 14 deletions

View File

@ -5,14 +5,21 @@
</header>
<div class="flex material-list" v-loading="loading">
<div class="flex material-item" v-for="item in list" :key="item.id" >
<div class="flex">
<el-image :src="fileUrl(item)" class="img" />
<el-text truncated>{{ item.fileShowName }}</el-text>
<div class="flex material-item">
<el-image v-if="item.fileType.indexOf('image')!=-1" :src="fileUrl(item)" class="img" />
<svg v-if="item.fileType.indexOf('video')!=-1" class="icon file-icon" aria-hidden="true" :style="{ 'font-size': 100 + 'px' }">
<use :xlink:href="'#icon-video'"></use>
</svg>
<svg class="icon file-icon" v-if="item.fileType.indexOf('audio')!=-1" aria-hidden="true" :style="{ 'font-size': 100 + 'px' }">
<use :xlink:href="'#icon-mp'"></use>
</svg>
<div class="texts">{{ item.fileShowName }}</div>
<!-- <el-text truncated>{{ item.fileShowName }}</el-text> -->
</div>
<el-button type="primary" @click="onInsert(item)">插入</el-button>
<el-button style="margin-left: 10px;" type="primary" @click="onInsert(item)">插入</el-button>
</div>
<el-empty description="暂无素材" v-if="!list.length" />
</div>
</div>
</template>
<script setup>
@ -48,6 +55,7 @@ const init = () => {
if(res.rows && res.rows.length){
//
list.value = res.rows.filter( item => suffixAry.indexOf(getFileSuffix(item.fileShowName)) != -1)
console.log(list.value)
}
})
}
@ -64,16 +72,19 @@ const fileUrl = computed(() => (item) =>{
//
const onInsert = async (item) =>{
loading.value = true
const res = await fetch(item.fileFullPath)
const bolb = await res.blob()
const file = commUtils.blobToFile(bolb, item.fileShowName)
// const res = await fetch(item.fileFullPath)
// const bolb = await res.blob()
// const file = commUtils.blobToFile(bolb, item.fileShowName)
const data=item.fileFullPath
try {
const data = await PPTApi.toRousrceUrl(file)
console.log('item', item)
// const data = await PPTApi.toRousrceUrl(file)
if(videoSuffix.indexOf(getFileSuffix(item.fileShowName)) != -1){
emit('insertMaterial',{ type: 'video', data })
}
else{
emit('insertMaterial',{ type: 'video', data })
}else if(item.fileType.indexOf('audio') != -1){
emit('insertMaterial',{ type: 'audio', data })
}else{
emit('insertMaterial',{ type: 'img', data })
}
} finally {
@ -125,11 +136,17 @@ onMounted(() => {
align-items: center;
margin-bottom: 10px;
font-size: 14px;
justify-content: space-between;
.img{
width: 100px;
height: 100px;
margin-right: 20px;
}
}
.texts{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 600px;
}
</style>

View File

@ -287,6 +287,8 @@ const insertMaterial = async (item: MaterialParams) =>{
const { type, data } = item
if(type == 'video'){
createVideoElement(data)
}else if(type == 'audio'){
createAudioElement(data)
}
else{
createImageElement(data)