UNPKG

2.28 kBJavaScriptView Raw
1import { initNavigationBar } from './navigationBar.js';
2import { initTabbar } from './tabbar.js';
3export { getCurrentPages, navigateBack, navigateTo, reLaunch, redirectTo, switchTab } from './api.js';
4export { createMpaHistory, history, prependBasename, setHistory, setHistoryMode } from './history.js';
5export { createMultiRouter } from './router/mpa.js';
6export { createRouter } from './router/spa.js';
7export { routesAlias } from './utils/index.js';
8export { createBrowserHistory, createHashHistory } from 'history';
9export { isDingTalk, isWeixin, setMpaTitle, setNavigationBarLoading, setNavigationBarStyle, setTitle } from './utils/navigate.js';
10
11function handleAppMount(config, _, appId = config.appId || 'app') {
12 let app = document.getElementById(appId);
13 let isPosition = true;
14 if (!app) {
15 app = document.createElement('div');
16 app.id = appId;
17 isPosition = false;
18 }
19 const appWrapper = ((app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body);
20 app.classList.add('taro_router');
21 if (!isPosition)
22 appWrapper.appendChild(app);
23 initNavigationBar(config, appWrapper);
24}
25function handleAppMountWithTabbar(config, history, appId = config.appId || 'app') {
26 let app = document.getElementById(appId);
27 let isPosition = true;
28 if (!app) {
29 app = document.createElement('div');
30 app.id = appId;
31 isPosition = false;
32 }
33 const appWrapper = ((app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body);
34 app.classList.add('taro_router');
35 const container = document.createElement('div');
36 container.classList.add('taro-tabbar__container');
37 container.id = 'container';
38 const panel = document.createElement('div');
39 panel.classList.add('taro-tabbar__panel');
40 panel.appendChild(app.cloneNode(true));
41 container.appendChild(panel);
42 if (!isPosition) {
43 appWrapper.appendChild(container);
44 }
45 else {
46 appWrapper.replaceChild(container, app);
47 }
48 initTabbar(config, history);
49 initNavigationBar(config, container);
50}
51
52export { handleAppMount, handleAppMountWithTabbar };