template
This commit is contained in:
parent
5ac542309a
commit
49eb0a0a8b
|
|
@ -10,13 +10,18 @@ import { triggers } from './triggers';
|
||||||
import { data } from './data';
|
import { data } from './data';
|
||||||
import { routers } from './exceptionRouters';
|
import { routers } from './exceptionRouters';
|
||||||
|
|
||||||
const { token } = initializeGeneralFeatures<EntityDict, RuntimeContext, typeof aspectDict>();
|
const { token, extraFile, application } = initializeGeneralFeatures<EntityDict, RuntimeContext, typeof aspectDict>();
|
||||||
|
|
||||||
const createFeatures = (basicFeatures: BasicFeatures<EntityDict, RuntimeContext, typeof aspectDict>) => {
|
const createFeatures = (basicFeatures: BasicFeatures<EntityDict, RuntimeContext, typeof aspectDict>) => {
|
||||||
const features = initialize(basicFeatures);
|
const features = initialize(basicFeatures);
|
||||||
const wholeFeatures = Object.assign({
|
const wholeFeatures = Object.assign(
|
||||||
token,
|
{
|
||||||
}, features);
|
token,
|
||||||
|
extraFile,
|
||||||
|
application,
|
||||||
|
},
|
||||||
|
features
|
||||||
|
);
|
||||||
return wholeFeatures;
|
return wholeFeatures;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -29,4 +34,5 @@ export {
|
||||||
routers,
|
routers,
|
||||||
|
|
||||||
token,
|
token,
|
||||||
|
application,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,47 +1,35 @@
|
||||||
import './utils/polyfill';
|
import "./utils/polyfill";
|
||||||
import { InitializeWechatMp } from 'oak-frontend-base';
|
import { InitializeWechatMp } from 'oak-frontend-base';
|
||||||
import { EntityDict } from 'oak-app-domain';
|
import { EntityDict } from 'oak-app-domain';
|
||||||
import { storageSchema, ActionDefDict } from 'oak-app-domain';
|
import { storageSchema, ActionDefDict } from 'oak-app-domain';
|
||||||
import { RuntimeContext } from '../../src/RuntimeContext';
|
import { RuntimeContext } from '../../src/RuntimeContext';
|
||||||
import {
|
import { aspectDict, createFeatures, routers, triggers, checkers, data, token, application } from '../../src/initialize';
|
||||||
aspectDict,
|
|
||||||
createFeatures,
|
|
||||||
routers,
|
|
||||||
triggers,
|
|
||||||
checkers,
|
|
||||||
data,
|
|
||||||
token,
|
|
||||||
} from '../../src/initialize';
|
|
||||||
|
|
||||||
const { OakComponent, OakPage, features } = InitializeWechatMp<
|
// 每个应用都要初始化applicationId(generalbusiness的要求)
|
||||||
EntityDict,
|
const applicationId = data.application[0].id;
|
||||||
RuntimeContext,
|
const { OakComponent, OakPage, features } = InitializeWechatMp<EntityDict, RuntimeContext, typeof aspectDict, ReturnType<typeof createFeatures>>(
|
||||||
typeof aspectDict,
|
|
||||||
ReturnType<typeof createFeatures>
|
|
||||||
>(
|
|
||||||
storageSchema,
|
storageSchema,
|
||||||
createFeatures,
|
createFeatures,
|
||||||
(store, scene) =>
|
(store, scene) => new RuntimeContext(store, applicationId, () => token.getToken(), scene),
|
||||||
new RuntimeContext(
|
|
||||||
store,
|
|
||||||
data.application[0].id,
|
|
||||||
() => token.getToken(),
|
|
||||||
scene
|
|
||||||
),
|
|
||||||
routers,
|
routers,
|
||||||
triggers,
|
triggers,
|
||||||
checkers,
|
checkers,
|
||||||
aspectDict,
|
aspectDict,
|
||||||
data as any,
|
data as any,
|
||||||
ActionDefDict
|
ActionDefDict);
|
||||||
);
|
|
||||||
|
|
||||||
// 因为依赖的问题,token中的Cache暂时只能在这里注入。以后再修改
|
// 因为依赖的问题,general库中的部分feature暂时只能在这里注入。以后再修改
|
||||||
token.setCache(features.cache);
|
token.setCache(features.cache);
|
||||||
|
application.setCache(features.cache);
|
||||||
|
application.setApplicationId(applicationId);
|
||||||
|
|
||||||
|
|
||||||
Object.assign(global, {
|
Object.assign(global, {
|
||||||
OakPage,
|
OakPage,
|
||||||
OakComponent,
|
OakComponent,
|
||||||
});
|
});
|
||||||
|
|
||||||
export { features };
|
export {
|
||||||
|
features,
|
||||||
|
createFeatures,
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue