From 597ef2c455cdb628e6ead2cdbfbd8b4a7bec67b5 Mon Sep 17 00:00:00 2001 From: RickCole21 Date: Fri, 31 Jul 2020 13:18:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=95=E9=83=A8=E5=AF=BC=E8=88=AA=E6=A0=8F?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/components/App.tsx | 3 ++- examples/components/Doc.tsx | 5 ++++- examples/components/MdRenderer.tsx | 8 +------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/examples/components/App.tsx b/examples/components/App.tsx index 336310671..e6e657870 100644 --- a/examples/components/App.tsx +++ b/examples/components/App.tsx @@ -391,7 +391,8 @@ export class App extends React.PureComponent { setHeaderVisible: this.setHeaderVisible, theme: theme.value, classPrefix: theme.ns, - locale: this.state.locale + locale: this.state.locale, + ContextPath })} diff --git a/examples/components/Doc.tsx b/examples/components/Doc.tsx index 587c70247..f241b5ca3 100644 --- a/examples/components/Doc.tsx +++ b/examples/components/Doc.tsx @@ -996,7 +996,9 @@ export default class Doc extends React.PureComponent { : null })); const flattenDocs = flattenTree(newDocs).filter(i => !!i.path); - const docIndex = flattenDocs.findIndex(d => d.path === location.pathname); + const docIndex = flattenDocs.findIndex( + d => `${this.props.ContextPath}${d.path}` === location.pathname + ); this.setState({ prevDoc: flattenDocs[docIndex - 1], nextDoc: flattenDocs[docIndex + 1] @@ -1011,6 +1013,7 @@ export default class Doc extends React.PureComponent { theme: this.props.theme, classPrefix: this.props.classPrefix, locale: this.props.locale, + ContextPath: this.props.ContextPath, prevDoc: this.state.prevDoc, nextDoc: this.state.nextDoc })} diff --git a/examples/components/MdRenderer.tsx b/examples/components/MdRenderer.tsx index 29369e652..7d903da34 100644 --- a/examples/components/MdRenderer.tsx +++ b/examples/components/MdRenderer.tsx @@ -12,12 +12,6 @@ import {Portal} from 'react-overlays'; import classnames from 'classnames'; import {Link} from 'react-router'; -let ContextPath = ''; - -if (process.env.NODE_ENV === 'production') { - ContextPath = '/amis'; -} - class CodePreview extends React.Component { state = { PlayGround: null @@ -190,7 +184,7 @@ export default function (doc) { } render() { - const {prevDoc, nextDoc} = this.props; + const {prevDoc, nextDoc, ContextPath} = this.props; return ( <>