mirror of
https://github.com/youzan/vant.git
synced 2025-10-22 03:44:48 +00:00
[Doc] optimzie demo display (#626)
This commit is contained in:
@@ -10,19 +10,21 @@ window.syncPath = function(dir) {
|
||||
const router = window.vueRouter;
|
||||
const isInIframe = window !== window.top;
|
||||
const currentDir = router.history.current.path;
|
||||
const iframe = document.querySelector('iframe');
|
||||
const pathParts = currentDir.split('/');
|
||||
let lang = pathParts[0];
|
||||
if (currentDir[0] === '/') {
|
||||
lang = pathParts[1];
|
||||
}
|
||||
|
||||
if (!isInIframe && !isMobile && iframe) {
|
||||
const pathParts = currentDir.split('/');
|
||||
let lang = pathParts[0];
|
||||
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);
|
||||
|
||||
iframeReady(iframe, () => {
|
||||
iframe.contentWindow.changePath(lang, currentDir);
|
||||
});
|
||||
} else if (isInIframe) {
|
||||
window.top.changePath(lang, currentDir);
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -12,6 +12,7 @@ const langMap = {
|
||||
messages: zhCN
|
||||
}
|
||||
};
|
||||
let currentLang = '';
|
||||
|
||||
setLang(getDefaultLang());
|
||||
|
||||
@@ -30,6 +31,11 @@ function getDefaultLang() {
|
||||
}
|
||||
|
||||
export function setLang(lang) {
|
||||
if (currentLang === lang) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentLang = lang;
|
||||
if (window.localStorage) {
|
||||
localStorage.setItem('VANT_LANGUAGE', lang);
|
||||
}
|
||||
|
Reference in New Issue
Block a user