mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-10-15 12:02:18 +08:00
fix: preset-build-in的route api 兼容
This commit is contained in:
parent
7c689db1aa
commit
00effaaa53
@ -328,7 +328,7 @@ export default function (api) {
|
|||||||
|
|
||||||
api.addCoreExports(() => [
|
api.addCoreExports(() => [
|
||||||
{
|
{
|
||||||
specifiers: ['getRoutes', 'defineRouteMeta'],
|
specifiers: ['getRoutes', 'getRouter', 'getHistory', 'destroyRouter', 'defineRouteMeta'],
|
||||||
source: absCoreFilePath
|
source: absCoreFilePath
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
@ -7,7 +7,8 @@ export function getRoutes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ROUTER_BASE = '{{{ routerBase }}}';
|
const ROUTER_BASE = '{{{ routerBase }}}';
|
||||||
|
let router = null;
|
||||||
|
let history = null;
|
||||||
export const createRouter = (routes) => {
|
export const createRouter = (routes) => {
|
||||||
const createHistory = plugin.applyPlugins({
|
const createHistory = plugin.applyPlugins({
|
||||||
key: 'modifyCreateHistory',
|
key: 'modifyCreateHistory',
|
||||||
@ -17,14 +18,14 @@ export const createRouter = (routes) => {
|
|||||||
},
|
},
|
||||||
initialValue: {{{ CREATE_HISTORY }}},
|
initialValue: {{{ CREATE_HISTORY }}},
|
||||||
});
|
});
|
||||||
const history = createHistory(ROUTER_BASE);
|
history = createHistory(ROUTER_BASE);
|
||||||
// 修改routes
|
// 修改routes
|
||||||
plugin.applyPlugins({
|
plugin.applyPlugins({
|
||||||
key: 'patchRoutes',
|
key: 'patchRoutes',
|
||||||
type: ApplyPluginsType.event,
|
type: ApplyPluginsType.event,
|
||||||
args: { routes },
|
args: { routes },
|
||||||
});
|
});
|
||||||
const router = createVueRouter({
|
router = createVueRouter({
|
||||||
history,
|
history,
|
||||||
routes
|
routes
|
||||||
});
|
});
|
||||||
@ -38,6 +39,25 @@ export const createRouter = (routes) => {
|
|||||||
return router;
|
return router;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getRouter = ()=>{
|
||||||
|
if(!router){
|
||||||
|
console.warn(`[preset-build-in] router is null`)
|
||||||
|
}
|
||||||
|
return router;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getHistory = ()=>{
|
||||||
|
if(!history){
|
||||||
|
console.warn(`[preset-build-in] history is null`)
|
||||||
|
}
|
||||||
|
return history;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const destroyRouter = ()=>{
|
||||||
|
router = null;
|
||||||
|
history = null;
|
||||||
|
}
|
||||||
|
|
||||||
export const defineRouteMeta = (param)=>{
|
export const defineRouteMeta = (param)=>{
|
||||||
return param
|
return param
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user