oak-general-business/es/routines/start.js

37 lines
1.3 KiB
JavaScript

import { rewriteOperation, rewriteSelection } from '../utils/selectionRewriter';
import { registerGetMapService } from 'oak-common-aspect';
import AMap from 'oak-common-aspect/lib/map/amap';
import MapWorld from 'oak-common-aspect/lib/map/mapWorld';
let mapService;
const startRoutines = [
{
name: '注入对合并的user的selection的改写',
routine: async (context) => {
context.rowStore.registerSelectionRewriter(rewriteSelection);
context.rowStore.registerOperationRewriter(rewriteOperation);
return {};
},
},
{
name: '注入common-aspect取MapService逻辑',
routine: async () => {
registerGetMapService((context) => {
if (mapService) {
return mapService;
}
const application = context.getApplication();
const { config } = application.system;
if (config.Map?.mapWorld) {
mapService = new MapWorld(config.Map.mapWorld.webApiKey);
}
else if (config.Map?.amaps) {
mapService = new AMap(config.Map.amaps);
}
return mapService;
});
return {};
},
}
];
export default startRoutines;