UNPKG

@wgoo/cli

Version:

Wgoo Cli 是一个 React 组件库构建工具,通过 Wgoo Cli 可以快速搭建一套功能完备的 React 组件库。

26 lines (22 loc) 675 B
import { iframeReady, isMobile } from '.'; window.syncPath = function() { const router = window.vueRouter; const isInIframe = window !== window.top; const currentDir = router.currentRoute.value.path; if (isInIframe) { window.top.replacePath(currentDir); } else if (!isMobile) { const iframe = document.querySelector('iframe'); if (iframe) { iframeReady(iframe, () => { iframe.contentWindow.replacePath(currentDir); }); } } }; window.replacePath = function(path = '') { // should preserve hash for anchor if (window.vueRouter.currentRoute.value.path !== path) { window.vueRouter.replace(path).catch(() => {}); } };