修复 gh-pages 编译生成的 html 中对部分 css 文件的 引用错误的问题

Change-Id: Ia131c4f0741bea760f17873b7d081cdc8ac5a7c6
This commit is contained in:
2betop 2020-11-19 19:22:56 +08:00
parent 7f454acc6b
commit 50753c8733
5 changed files with 31 additions and 61 deletions

View File

@ -249,7 +249,7 @@ export default class PlayGround extends React.Component {
className="mobile-frame"
ref={this.iframeRef}
// @ts-ignore
src={__uri('../index.html#mobileView')}
src={__uri('../mobile.html')}
></iframe>
);
}

View File

@ -179,7 +179,7 @@ export default function (schema) {
className="mobile-frame"
ref={this.iframeRef}
// @ts-ignore
src={__uri('../index.html#mobileView')}
src={__uri('../mobile.html')}
></iframe>
);
}

View File

@ -44,53 +44,21 @@
<div id="root" class="app-wrapper"></div>
<script src="./mod.js"></script>
<script type="text/javascript">
if (location.hash === '#mobileView') {
// TODO: 本来应该使用 mobile.html 的,但 gh-pages 编译时 themes 下的 scss hash 不一致导致出错,所以先和 index.html 放一起
const themes = [
{
label: '默认主题',
value: 'default'
},
{
label: '百度云舍',
value: 'cxd'
},
{
label: 'Dark',
value: 'dark'
}
];
const theme = themes[localStorage.getItem('themeIndex') || 0];
// mobile 下先禁掉所有外链避免影响
document.querySelectorAll('link').forEach(item => {
item.disabled = true;
});
document.querySelector(`link[title=${theme.value}]`).disabled = false;
if (theme.value === 'dark') {
document.querySelector('body').classList.add('dark');
}
var _hmt = _hmt || [];
amis.require(['./mobile.tsx'], function (app) {
app.bootstrap(document.getElementById('root'), {});
});
} else {
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);
})();
// 百度统计
(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 标记为同步依赖,提前加载 */
amis.require(['./index.jsx'], function (app) {
var initialState = {};
app.bootstrap(document.getElementById('root'), initialState);
});
}
/* @require ./index.jsx 标记为同步依赖,提前加载 */
amis.require(['./index.jsx'], function (app) {
var initialState = {};
app.bootstrap(document.getElementById('root'), initialState);
});
</script>
</body>
</html>

View File

@ -41,34 +41,29 @@
const themes = [
{
label: '默认主题',
ns: 'a-',
value: 'default'
},
{
label: '百度云舍',
ns: 'cxd-',
value: 'cxd'
},
{
label: 'Dark',
ns: 'dark-',
value: 'dark'
}
];
const theme = themes[localStorage.getItem('themeIndex') || 0];
if (theme.value !== 'default') {
document.querySelectorAll('link[title]').forEach(item => {
item.disabled = true;
});
document.querySelector(`link[title=${theme.value}]`).disabled = false;
if (theme.value === 'dark') {
document.querySelector('body').classList.add('dark');
}
// mobile 下先禁掉所有外链避免影响
document.querySelectorAll('link').forEach(item => {
item.disabled = true;
});
document.querySelector(`link[title=${theme.value}]`).disabled = false;
if (theme.value === 'dark') {
document.querySelector('body').classList.add('dark');
}
amis.require(['./mobile.tsx'], function (app) {
var initialState = {};
app.bootstrap(document.getElementById('root'), initialState);
app.bootstrap(document.getElementById('root'), {});
});
</script>
</body>

View File

@ -507,6 +507,13 @@ if (fis.project.currentMedia() === 'publish') {
} else if (fis.project.currentMedia() === 'gh-pages') {
const ghPages = fis.media('gh-pages');
ghPages.match('*.scss', {
parser: fis.plugin('sass', {
sourceMap: false
}),
rExt: '.css'
});
ghPages.match('/docs/**.md', {
rExt: 'js',
isMod: true,