Skip to content

Commit 01fbbba

Browse files
committed
Allow creating the browser as a standalone component
1 parent 37b771c commit 01fbbba

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/init.js renamed to src/app.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@ import { createApp } from "vue";
22
import { createRouter, createWebHistory, createWebHashHistory } from "vue-router";
33
import StacBrowser from "./StacBrowser.vue";
44
import i18n, { loadDefaultMessages } from './i18n';
5-
import CONFIG from './config';
65
import getRoutes from "./router";
76
import getStore from "./store";
87

98
import { createBootstrap } from 'bootstrap-vue-next/plugins/createBootstrap';
109
import { vBToggle } from 'bootstrap-vue-next/directives/BToggle';
1110
import visible from './directives/visible';
1211

13-
export default function init() {
12+
export default function createStacBrowser(config) {
1413
return loadDefaultMessages().then(() => {
1514
// Setup router
1615
const router = createRouter({
17-
history: CONFIG.historyMode === 'history' ? createWebHistory(CONFIG.pathPrefix) : createWebHashHistory(CONFIG.pathPrefix),
18-
routes: getRoutes(CONFIG),
16+
history: config.historyMode === 'history' ? createWebHistory(config.pathPrefix) : createWebHashHistory(config.pathPrefix),
17+
routes: getRoutes(config),
1918
scrollBehavior: (to, from, savedPosition) => {
2019
if (to.path !== from.path) {
2120
return { left: 0, top: 0 };
@@ -27,7 +26,7 @@ export default function init() {
2726
});
2827

2928
// Setup store
30-
const store = getStore(CONFIG, router);
29+
const store = getStore(config, router);
3130

3231
const app = createApp(StacBrowser);
3332

@@ -42,6 +41,6 @@ export default function init() {
4241
app.use(router);
4342
app.use(store);
4443

45-
return app.mount("body");
44+
return app;
4645
});
4746
}

src/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
import init from "./init";
1+
import createStacBrowser from "./app";
2+
import config from './config';
23

3-
init();
4+
createStacBrowser(config).mount("body");

0 commit comments

Comments
 (0)