Skip to content

Commit

Permalink
Merge pull request #67 from realhuhu/main
Browse files Browse the repository at this point in the history
允许为视频添加封面图
  • Loading branch information
traceless authored Jul 27, 2024
2 parents 77c3284 + 1015c59 commit 880df05
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions node-proxy/src/encNameRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,30 @@ encNameRouter.all('/api/fs/list', async (ctx, next) => {
fileInfo.name = convertShowName(passwdInfo.password, passwdInfo.encType, fileInfo.name)
}
}

const coverNameMap = {} //根据不含后缀的视频文件名找到对应的含后缀的封面文件名
const omitNames = [] //用于隐藏封面文件
const { path } = JSON.parse(ctx.req.reqBody)
result.data.content.forEach((fileInfo) => {
if (fileInfo.is_dir) {
return
}
if (fileInfo.type === 5) {
coverNameMap[fileInfo.name.split('.')[0]] = fileInfo.name
}
})
result.data.content.forEach((fileInfo) => {
if (fileInfo.is_dir) {
return
}
const coverName = coverNameMap[fileInfo.name.split('.')[0]]
if (fileInfo.type === 2 && coverName) {
omitNames.push(coverName)
fileInfo.thumb = `/d${path}/${coverName}`
}
})
//不展示封面文件,也许可以添加个配置让用户选择是否展示封面源文件
result.data.content = result.data.content.filter((fileInfo) => !omitNames.includes(fileInfo.name))
}
})

Expand Down

0 comments on commit 880df05

Please sign in to comment.