change
This commit is contained in:
parent
3790a332c5
commit
f92240a4ea
|
@ -40,20 +40,13 @@ export default function useResource(tag: Ref<string>, type: string) {
|
||||||
if (videoArr.includes(suffix)) {
|
if (videoArr.includes(suffix)) {
|
||||||
// 内部视频
|
// 内部视频
|
||||||
// 先显示截图,再去数据库看是否有存货
|
// 先显示截图,再去数据库看是否有存货
|
||||||
|
|
||||||
resource.video = ''
|
resource.video = ''
|
||||||
resource.image = val + '?x-oss-process=video/snapshot,t_0,f_jpg,m_fast'
|
resource.image = val + '?x-oss-process=video/snapshot,t_0,f_jpg,m_fast'
|
||||||
resource.brief = val + '?x-oss-process=video/snapshot,t_0,f_jpg,w_400,h_225,m_fast'
|
resource.brief = val + '?x-oss-process=video/snapshot,t_0,f_jpg,w_400,h_225,m_fast'
|
||||||
db.getItem<{ tag: string; file: Blob }[]>('videoList').then((res) => {
|
db.getItem<{ tag: string; file: Blob }[]>('videoList').then((res) => {
|
||||||
if (!res) return
|
const handle = (res: any[] | undefined) => {
|
||||||
const item = res.find((item) => item.tag === val)
|
res = res || []
|
||||||
if (item) {
|
|
||||||
|
|
||||||
resource.video = URL.createObjectURL(item.file)
|
|
||||||
resource.type = 'local'
|
|
||||||
} else {
|
|
||||||
// 不存在,需要存入
|
// 不存在,需要存入
|
||||||
|
|
||||||
fetch(val)
|
fetch(val)
|
||||||
.then((res) => res.blob())
|
.then((res) => res.blob())
|
||||||
.then((blob) => {
|
.then((blob) => {
|
||||||
|
@ -61,12 +54,23 @@ export default function useResource(tag: Ref<string>, type: string) {
|
||||||
res.pop()
|
res.pop()
|
||||||
}
|
}
|
||||||
res.unshift({ tag: val, file: blob })
|
res.unshift({ tag: val, file: blob })
|
||||||
|
db.setItem('videoList', res)
|
||||||
resource.video = URL.createObjectURL(blob)
|
resource.video = URL.createObjectURL(blob)
|
||||||
resource.type = 'own'
|
resource.type = 'own'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if (!res) {
|
||||||
|
handle(undefined)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const item = res.find((item) => item.tag === val)
|
||||||
|
if (item) {
|
||||||
|
resource.video = URL.createObjectURL(item.file)
|
||||||
|
resource.type = 'local'
|
||||||
|
} else {
|
||||||
|
handle(res)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// 图片
|
// 图片
|
||||||
resource.image = val
|
resource.image = val
|
||||||
|
@ -100,7 +104,6 @@ export default function useResource(tag: Ref<string>, type: string) {
|
||||||
|
|
||||||
const url = URL.createObjectURL(item.file)
|
const url = URL.createObjectURL(item.file)
|
||||||
|
|
||||||
|
|
||||||
resource.image = item.type === 'image' ? url : ''
|
resource.image = item.type === 'image' ? url : ''
|
||||||
resource.video = item.type === 'video' ? url : ''
|
resource.video = item.type === 'video' ? url : ''
|
||||||
resource.brief = url
|
resource.brief = url
|
||||||
|
|
Loading…
Reference in New Issue