Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
reruin committed Jun 1, 2020
1 parent 35eb787 commit d869dc5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
12 changes: 6 additions & 6 deletions app/controllers/sharelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,13 @@ const output = async (ctx , data)=>{

return
}



if(isPreview){
let re = await service.preview(data)
let enableDownload = true
let displayDownloadLabel = true
if(!download){
if(re.isConv){
enableDownload = false
if(re.convertible){
displayDownloadLabel = false
}else{
ctx.status = 401
return
Expand All @@ -87,7 +85,7 @@ const output = async (ctx , data)=>{
let purl = ctx.path + ( querystr ? ('?' + querystr) : '')

await ctx.renderSkin('detail',{
data : re , enableDownload,
data : re , displayDownloadLabel,
url : isProxy ? purl : url
})
}
Expand Down Expand Up @@ -264,7 +262,9 @@ module.exports = {
let ignorepaths = config.getIgnorePaths()
let isAdmin = ctx.runtime.isAdmin
let base_url = ctx.path == '/' ? '' : ctx.path

const data = await service.path(ctx.runtime)

//data is readonly
if( data === false || data === 401){
ctx.status = 404
Expand Down
2 changes: 1 addition & 1 deletion app/views/default/detail.pug
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ block content
header
.wrap.detail
a.home.ellipsis #{data.name}
-if(enableDownload)
-if(displayDownloadLabel)
a.download-menu(href=url)
i.ic.ic-download
section
Expand Down
3 changes: 1 addition & 2 deletions plugins/drive.caiyun.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,8 @@ module.exports = ({ request, cache, getConfig, querystring, base64, saveDrive, g

if (!resp || !resp.body) {
return { id, type: 'folder', protocol: defaultProtocol,body:'解析错误' }

}
let children = [].concat(resp.body.dci.cataloginfos,resp.body.dci.contents).map( file => {
let children = [].concat(resp.body.dci.cataloginfos || [],resp.body.dci.contents || []).map( file => {
let folder = !!file.ETagOprType
let subid = path + '/' + (folder ? file.catalogID : file.contentID)
let item = {
Expand Down
6 changes: 4 additions & 2 deletions plugins/preview.document.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ module.exports = ({ getSource , getConfig, request }) => {
delete fileMap[req.path]
return {
...data,
isConv:true,
convertible:true,
outputType:'stream',
body:request({url})
}
}

let rawUrl = createUrl(req,true)
rawUrl = 'https://sharelist.reruin.net/%E6%9C%AC%E5%9C%B0%E6%96%87%E4%BB%B6/preview/work.docx'
let WOPISrc = encodeURIComponent(`http:https://us1-view-wopi.wopi.live.net:808/oh/wopi/files/@/wFileId?wFileId=${encodeURIComponent(rawUrl)}`)

let url = `https://us1-word-view.officeapps.live.com/wv/wordviewerframe.aspx?ui=zh-CN&rs=zh-CN&WOPISrc=${WOPISrc}&access_token_ttl=0`
Expand All @@ -79,13 +80,14 @@ module.exports = ({ getSource , getConfig, request }) => {
let body = `<iframe src="//mozilla.github.io/pdf.js/web/viewer.html?file=${encodeURIComponent(url)}"></iframe>`
return {
...data,
convertible:true,
body
}

}else{
return {
...data,
isConv:true,
convertible:true,
body:'无法预览'
}
}
Expand Down

0 comments on commit d869dc5

Please sign in to comment.