chore: 修复 office viewer 文件在 ghpages 里无法访问 (#6435)

This commit is contained in:
吴多益 2023-03-21 19:27:34 +08:00 committed by GitHub
parent 3f1e39c560
commit dc18814fb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 50 additions and 7 deletions

1
.gitattributes vendored
View File

@ -8,3 +8,4 @@
*.svg binary
*.ttf binary
*.woff binary
*.docx binary

View File

@ -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"
}
]
```

View File

@ -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"

View File

@ -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',

View 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'
}
]
}
};

View 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);

View File

@ -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.