mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
chore: 修复 office viewer 文件在 ghpages 里无法访问 (#6435)
This commit is contained in:
parent
3f1e39c560
commit
dc18814fb5
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -8,3 +8,4 @@
|
||||
*.svg binary
|
||||
*.ttf binary
|
||||
*.woff binary
|
||||
*.docx binary
|
||||
|
@ -32,7 +32,7 @@ order: 23
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "office-viewer",
|
||||
"src": "https://suda.cdn.bcebos.com/docx/simple.docx",
|
||||
"src": "/examples/static/simple.docx",
|
||||
"wordOptions": {
|
||||
"padding": "8px"
|
||||
}
|
||||
@ -116,7 +116,7 @@ order: 23
|
||||
{
|
||||
"type": "office-viewer",
|
||||
"id": "office-viewer",
|
||||
"src": "https://suda.cdn.bcebos.com/docx/info.docx",
|
||||
"src": "/examples/static/info.docx",
|
||||
"wordOptions": {
|
||||
"enableVar": true,
|
||||
"padding": "8px"
|
||||
@ -132,7 +132,7 @@ order: 23
|
||||
{
|
||||
"type": "office-viewer",
|
||||
"id": "office-viewer",
|
||||
"src": "https://suda.cdn.bcebos.com/docx/info.docx",
|
||||
"src": "/examples/static/info.docx",
|
||||
"wordOptions": {
|
||||
"padding": "8px"
|
||||
}
|
||||
@ -173,7 +173,7 @@ order: 23
|
||||
"type": "office-viewer",
|
||||
"id": "office-viewer-download",
|
||||
"display": false,
|
||||
"src": "https://suda.cdn.bcebos.com/docx/simple.docx"
|
||||
"src": "/examples/static/simple.docx"
|
||||
}
|
||||
]
|
||||
```
|
||||
@ -202,7 +202,7 @@ order: 23
|
||||
"type": "office-viewer",
|
||||
"id": "office-viewer-print",
|
||||
"display": false,
|
||||
"src": "https://suda.cdn.bcebos.com/docx/simple.docx"
|
||||
"src": "/examples/static/simple.docx"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
@ -4,7 +4,11 @@
|
||||
<meta charset="UTF-8" />
|
||||
<title>amis app 模式</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link type="image/x-icon" rel="shortcut icon" href="./static/favicon.png" />
|
||||
<link
|
||||
type="image/x-icon"
|
||||
rel="shortcut icon"
|
||||
href="../static/favicon.png"
|
||||
/>
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
|
@ -126,6 +126,7 @@ import Tab2Schema from './Tabs/Tab2';
|
||||
import Tab3Schema from './Tabs/Tab3';
|
||||
import Loading from './Loading';
|
||||
import CodeSchema from './Code';
|
||||
import OfficeViewer from './OfficeViewer';
|
||||
|
||||
import {Switch} from 'react-router-dom';
|
||||
import {navigations2route} from './App';
|
||||
@ -873,6 +874,13 @@ export const examples = [
|
||||
component: SdkTest
|
||||
},
|
||||
|
||||
{
|
||||
label: 'Office 文档预览',
|
||||
icon: 'fa fa-file-word',
|
||||
path: '/examples/office-viwewer',
|
||||
component: makeSchemaRenderer(OfficeViewer)
|
||||
},
|
||||
|
||||
{
|
||||
label: '多 loading',
|
||||
icon: 'fa fa-spinner',
|
||||
|
22
examples/components/OfficeViewer.jsx
Normal file
22
examples/components/OfficeViewer.jsx
Normal file
@ -0,0 +1,22 @@
|
||||
export default {
|
||||
type: 'page',
|
||||
body: {
|
||||
type: 'form',
|
||||
title: '',
|
||||
wrapWithPanel: false,
|
||||
body: [
|
||||
{
|
||||
type: 'input-file',
|
||||
name: 'file',
|
||||
label: '选择 Docx 文件预览效果(不会上传到服务器)',
|
||||
asBlob: true,
|
||||
accept: '.docx'
|
||||
},
|
||||
{
|
||||
type: 'office-viewer',
|
||||
id: 'office-viewer',
|
||||
name: 'file'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
@ -159,6 +159,15 @@ export default class PlayGround extends React.Component {
|
||||
fetcher: async api => {
|
||||
let {url, method, data, responseType, config, headers} = api;
|
||||
config = config || {};
|
||||
// 如果在 gh-pages 里面
|
||||
if (
|
||||
/^\/amis/.test(window.location.pathname) &&
|
||||
typeof url === 'string' &&
|
||||
url.startsWith('/examples/static/')
|
||||
) {
|
||||
url = url.replace('/examples/static/', '/amis/static/');
|
||||
}
|
||||
|
||||
config.url = url;
|
||||
responseType && (config.responseType = responseType);
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
<meta charset="UTF-8" />
|
||||
<title>MobileView</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link type="image/x-icon" rel="shortcut icon" href="./static/favicon.png" />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1"
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user