mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-15 17:42:15 +08:00
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import type { App } from "vue";
|
|
import {
|
|
createRouter as createVueRouter,
|
|
createWebHistory as createVueWebHistory,
|
|
createWebHashHistory as createVueWebHashHistory,
|
|
createMemoryHistory as createVueMemoryHistory,
|
|
} from "vue-router";
|
|
|
|
import { createIonRouter } from "./router";
|
|
import type { IonicVueRouterOptions } from "./types";
|
|
import { createViewStacks } from "./viewStacks";
|
|
|
|
export const createRouter = (opts: IonicVueRouterOptions) => {
|
|
const routerOptions = { ...opts };
|
|
delete routerOptions.tabsPrefix;
|
|
|
|
const router = createVueRouter(routerOptions);
|
|
const ionRouter = createIonRouter(opts, router);
|
|
const viewStacks = createViewStacks(router);
|
|
|
|
const oldInstall = router.install.bind(router);
|
|
router.install = (app: App) => {
|
|
app.provide("navManager", ionRouter);
|
|
app.provide("viewStacks", viewStacks);
|
|
|
|
oldInstall(app);
|
|
};
|
|
|
|
const oldIsReady = router.isReady.bind(router);
|
|
router.isReady = () => oldIsReady();
|
|
|
|
return router;
|
|
};
|
|
|
|
export const createWebHistory = (base?: string) => createVueWebHistory(base);
|
|
export const createWebHashHistory = (base?: string) =>
|
|
createVueWebHashHistory(base);
|
|
export const createMemoryHistory = (base?: string) =>
|
|
createVueMemoryHistory(base);
|