修复 gh-pages 主题切换功能

This commit is contained in:
liaoxuezhi 2019-05-20 12:03:25 +08:00
parent cb43b6c9b3
commit ad9e10009f
3 changed files with 21 additions and 3 deletions

View File

@ -6,7 +6,7 @@ import {AlertComponent, ToastComponent} from '../../src/components/index';
import {
mapTree
} from '../../src/utils/helper';
import { Router, Route, IndexRoute, browserHistory, hashHistory, Link, Redirect } from 'react-router';
import { Router, Route, IndexRoute, browserHistory, hashHistory, Link, Redirect, withRouter } from 'react-router';
import makeSchemaRenderer from './SchemaRender';
@ -527,6 +527,7 @@ const themes = [
}
];
@withRouter
export class App extends React.PureComponent {
state = {
@ -556,10 +557,17 @@ export class App extends React.PureComponent {
}
componentDidUpdate(preProps, preState) {
const props = this.props;
if (preState.theme.value !== this.state.theme.value) {
document.querySelector(`link[title=${preState.theme.value}]`).disabled = true;
document.querySelector(`link[title=${this.state.theme.value}]`).disabled = false;
}
if (props.location.pathname !== prevProps.location.pathname) {
const pageURL = props.location.pathname;
_hmt && _hmt.push(['_trackPageview', pageURL]);
}
}
toggleAside() {

View File

@ -34,6 +34,16 @@
<div id="root" class="app-wrapper"></div>
<script src="./mod.js"></script>
<script type="text/javascript">
var _hmt = _hmt || [];
// 百度统计
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?1f80f2c9dbe21dc3af239cf9eee90f1f";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
/* @require ./index.jsx 标记为同步依赖,提前加载 */
require(['./index.jsx'], function (app) {
var initialState = {};

View File

@ -326,8 +326,8 @@ if (fis.project.currentMedia() === 'publish') {
'pkg/style.css': [
'node_modules/*/**.css',
'*.scss',
'!/scss/*.scss',
'/scss/*.scss',
'!/scss/themes/*.scss',
// 要切换主题,不能打在一起。'/scss/*.scss',
'!monaco-editor/**',
]
})