mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[Doc] fix tree shaking when build site
This commit is contained in:
parent
8564a5b1f1
commit
6e93c93d46
@ -49,6 +49,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.less$/,
|
test: /\.less$/,
|
||||||
|
sideEffects: true,
|
||||||
use: [
|
use: [
|
||||||
'style-loader',
|
'style-loader',
|
||||||
'css-loader',
|
'css-loader',
|
||||||
@ -63,10 +64,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.md$/,
|
test: /\.md$/,
|
||||||
use: [
|
use: ['vue-loader', '@vant/markdown-loader']
|
||||||
'vue-loader',
|
|
||||||
'@vant/markdown-loader'
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.(ttf|svg)$/,
|
test: /\.(ttf|svg)$/,
|
||||||
|
@ -3,7 +3,9 @@ import docConfig from './doc.config';
|
|||||||
import DemoList from './components/DemoList';
|
import DemoList from './components/DemoList';
|
||||||
import DemoPages from './components/DemoPages';
|
import DemoPages from './components/DemoPages';
|
||||||
import { demoWrapper } from './demo-common';
|
import { demoWrapper } from './demo-common';
|
||||||
import './utils/iframe-router';
|
import { initIframeRouter } from './utils/iframe-router';
|
||||||
|
|
||||||
|
initIframeRouter();
|
||||||
|
|
||||||
const registerRoute = ({ mobile, componentMap }) => {
|
const registerRoute = ({ mobile, componentMap }) => {
|
||||||
const route = [
|
const route = [
|
||||||
|
@ -5,30 +5,32 @@
|
|||||||
import { setLang } from './lang';
|
import { setLang } from './lang';
|
||||||
import { iframeReady, isMobile } from '.';
|
import { iframeReady, isMobile } from '.';
|
||||||
|
|
||||||
window.syncPath = function () {
|
export function initIframeRouter() {
|
||||||
const router = window.vueRouter;
|
window.syncPath = function () {
|
||||||
const isInIframe = window !== window.top;
|
const router = window.vueRouter;
|
||||||
const currentDir = router.history.current.path;
|
const isInIframe = window !== window.top;
|
||||||
const pathParts = currentDir.split('/');
|
const currentDir = router.history.current.path;
|
||||||
let lang = pathParts[0];
|
const pathParts = currentDir.split('/');
|
||||||
if (currentDir[0] === '/') {
|
let lang = pathParts[0];
|
||||||
lang = pathParts[1];
|
if (currentDir[0] === '/') {
|
||||||
}
|
lang = pathParts[1];
|
||||||
|
|
||||||
if (!isInIframe && !isMobile) {
|
|
||||||
const iframe = document.querySelector('iframe');
|
|
||||||
if (iframe) {
|
|
||||||
iframeReady(iframe, () => {
|
|
||||||
iframe.contentWindow.changePath(lang, currentDir);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
setLang(lang);
|
|
||||||
} else if (isInIframe) {
|
|
||||||
window.top.changePath(lang, currentDir);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
window.changePath = function (lang, path = '') {
|
if (!isInIframe && !isMobile) {
|
||||||
setLang(lang);
|
const iframe = document.querySelector('iframe');
|
||||||
window.vueRouter.replace(path);
|
if (iframe) {
|
||||||
};
|
iframeReady(iframe, () => {
|
||||||
|
iframe.contentWindow.changePath(lang, currentDir);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
setLang(lang);
|
||||||
|
} else if (isInIframe) {
|
||||||
|
window.top.changePath(lang, currentDir);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.changePath = function (lang, path = '') {
|
||||||
|
setLang(lang);
|
||||||
|
window.vueRouter.replace(path);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user