This commit is contained in:
李鹏宇
2026-02-27 20:57:48 +08:00
parent cbf34d6486
commit 368814896d
+17 -15
View File
@@ -36,21 +36,23 @@ class preview(http.Controller):
# return template.render(html=html)
elif attach.mimetype in excel or word:
# 'http://view.officeapps.live.com/op/view.aspx?src=https://oa.thtzjt.com/web/content/office_preview/'
office_view_url = 'http://view.officeapps.live.com/op/view.aspx?src='
base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url')
html = f'{office_view_url}{quote(base_url + "/web/content/office_preview/" + str(attach.id))}'
return werkzeug.wrappers.Response(f"""
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<body onLoad="parent.location='{html}'">
</body>
</html>
""", status=200, headers=[('Content-Type', 'text/html'), ('charset', 'utf-8')])
# office_view_url = 'http://view.officeapps.live.com/op/view.aspx?src='
# base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url')
# html = f'{office_view_url}{quote(base_url + "/web/content/office_preview/" + str(attach.id))}'
target_url = f'/onlyoffice/editor/{str(attach.id)}'
return self.redirect(target_url)
# return werkzeug.wrappers.Response(f"""
# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
# "http://www.w3.org/TR/html4/loose.dtd">
# <html>
# <head>
# <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
# <title></title>
# </head>
# <body onLoad="parent.location='{html}'">
# </body>
# </html>
# """, status=200, headers=[('Content-Type', 'text/html'), ('charset', 'utf-8')])
else:
return werkzeug.wrappers.Response('This format is not currently supported', status=200, headers=[('Content-Type', 'text/html'),('charset','utf-8')])