## 文档预览
~~~[api:auth]
post:/CompetitionProjectFile/docPreview
*string:url#文档URL
<<<
success
{
"code": 0,
"msg": "获取成功",
"data": {
"RefreshToken": "27ec8ff354434d63a938a4b7ba23986dv3",
"RequestId": "1CE3744C-29F7-500D-A3AF-52B70A62C069",
"AccessToken": "7939155b0de34089a3a45655da1f4850v3",
"RefreshTokenExpiredTime": "2021-10-28T03:42:08.497412839Z",
"WebofficeURL": "https://office-cn-shenzhen.imm.aliyuncs.com/office/f/eaa7dd9a5f87c759d4919f88e7daea4f27fbcf8d?_w_tokentype=1&hidecmb=1&simple=1",
"AccessTokenExpiredTime": "2021-10-27T04:12:08.497412839Z"
},
"file": [
{
"Modifier": {
"ID": "U16",
"Avatar": "https://sxb2.xtow.net/favicon.ico",
"Name": "张负责"
},
"Name": "d181f41ac4c8daad0e6f09b15469624c.pdf",
"Creator": {
"ID": "U16",
"Avatar": "https://sxb2.xtow.net/favicon.ico",
"Name": "张负责"
},
"SrcUri": "oss://test/3/project-382/d181f41ac4c8daad0e6f09b15469624c.pdf",
"Version": 1,
"TgtUri": "oss://test/3/project-382/d181f41ac4c8daad0e6f09b15469624c.pdf"
}
]
}
~~~
## 支持预览的格式
```js
let officeRegex = /\.(et|xls|xlt|xlsx|xlsm|xltx|xltm|csv|doc|docx|txt|dot|wps|wpt|dotx|docm|dotm|rtf|ppt|pptx|pptm|ppsx|ppsm|pps|potx|potm|dpt|dps|pdf)$/i;
```
>[danger] 其它格式请使用其它方式预览 ,如图片使用`img`标签,视频使用`video`标签等
## 参考预览页代码
```html
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>文档预览</title>
</head>
<body>
<script src="/public/static/admin/js/jquery-3.6.0.min.js"></script>
<script src="https://g.alicdn.com/IMM/office-js/1.1.9/aliyun-web-office-sdk.min.js"></script>
<script>
$(document).ready(function () {
$.post('/index/CompetitionProjectFile/docPreview', {"url": atob("https://abc.makercas.com/3/project-382/d181f41ac4c8daad0e6f09b15469624c.pdf")}, function (result) {
if (result.code != 0) {
return alert(result.msg);
}
console.log(result);
let instance = aliyun.config({
url: result.data.WebofficeURL //设置文档预览URL地址。
})
//设置AccessToken。
instance.setToken({
token: result.data.AccessToken
})
});
});
</script>
</body>
</html>
```