mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-06-29 18:09:17 +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(() => [
|
||||
{
|
||||
specifiers: ['getRoutes', 'defineRouteMeta'],
|
||||
specifiers: ['getRoutes', 'getRouter', 'getHistory', 'destroyRouter', 'defineRouteMeta'],
|
||||
source: absCoreFilePath
|
||||
}
|
||||
]);
|
||||
|
@ -7,7 +7,8 @@ export function getRoutes() {
|
||||
}
|
||||
|
||||
const ROUTER_BASE = '{{{ routerBase }}}';
|
||||
|
||||
let router = null;
|
||||
let history = null;
|
||||
export const createRouter = (routes) => {
|
||||
const createHistory = plugin.applyPlugins({
|
||||
key: 'modifyCreateHistory',
|
||||
@ -17,14 +18,14 @@ export const createRouter = (routes) => {
|
||||
},
|
||||
initialValue: {{{ CREATE_HISTORY }}},
|
||||
});
|
||||
const history = createHistory(ROUTER_BASE);
|
||||
history = createHistory(ROUTER_BASE);
|
||||
// 修改routes
|
||||
plugin.applyPlugins({
|
||||
key: 'patchRoutes',
|
||||
type: ApplyPluginsType.event,
|
||||
args: { routes },
|
||||
});
|
||||
const router = createVueRouter({
|
||||
router = createVueRouter({
|
||||
history,
|
||||
routes
|
||||
});
|
||||
@ -38,6 +39,25 @@ export const createRouter = (routes) => {
|
||||
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)=>{
|
||||
return param
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user