cli 文件调整
This commit is contained in:
parent
f58fcae410
commit
31487ecdb6
|
|
@ -0,0 +1,32 @@
|
|||
import './utils/polyfill';
|
||||
import { initializeFeatures as initializeGeneralFeatures } from 'oak-general-business';
|
||||
import { BasicFeatures, } from 'oak-frontend-base';
|
||||
import { EntityDict } from 'oak-app-domain';
|
||||
import { RuntimeContext } from './RuntimeContext';
|
||||
import { aspectDict } from './aspects';
|
||||
import { initialize } from './features';
|
||||
import { checkers } from './checkers';
|
||||
import { triggers } from './triggers';
|
||||
import { data } from './data';
|
||||
import { routers } from './exceptionRouters';
|
||||
|
||||
const { token } = initializeGeneralFeatures<EntityDict, RuntimeContext, typeof aspectDict>();
|
||||
|
||||
const createFeatures = (basicFeatures: BasicFeatures<EntityDict, RuntimeContext, typeof aspectDict>) => {
|
||||
const features = initialize(basicFeatures);
|
||||
const wholeFeatures = Object.assign({
|
||||
token,
|
||||
}, features);
|
||||
return wholeFeatures;
|
||||
};
|
||||
|
||||
export {
|
||||
createFeatures,
|
||||
aspectDict,
|
||||
triggers,
|
||||
checkers,
|
||||
data,
|
||||
routers,
|
||||
|
||||
token,
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
import { pick } from 'lodash';
|
||||
import { WechatMpEnv } from 'oak-app-domain/Token/Schema';
|
||||
import { features } from './init';
|
||||
import { features } from './init';
|
||||
|
||||
export interface IAppOption {
|
||||
globalData: {
|
||||
features: typeof features;
|
||||
|
|
@ -12,25 +11,7 @@ App<IAppOption>({
|
|||
features,
|
||||
},
|
||||
async onLaunch() {
|
||||
const { code } = await wx.login();
|
||||
const env = await wx.getSystemInfo();
|
||||
const env2 = pick(env, [
|
||||
'brand',
|
||||
'model',
|
||||
'pixelRatio',
|
||||
'screenWidth',
|
||||
'screenHeight',
|
||||
'windowWidth',
|
||||
'windowHeight',
|
||||
'statusBarHeight',
|
||||
'language',
|
||||
'version',
|
||||
'system',
|
||||
'platform',
|
||||
'fontSizeSetting',
|
||||
'SDKVersion'
|
||||
]);
|
||||
await features.token.loginWechatMp(code, Object.assign(env2, { type: 'wechatMp' }) as WechatMpEnv);
|
||||
await features.token.loginWechatMp('app:onLaunch');
|
||||
},
|
||||
|
||||
onHide() {
|
||||
|
|
|
|||
|
|
@ -1,44 +1,47 @@
|
|||
import './utils/polyfill';
|
||||
import { BasicFeatures, InitializeWechatMp, } from 'oak-frontend-base';
|
||||
import { InitializeWechatMp } from 'oak-frontend-base';
|
||||
import { EntityDict } from 'oak-app-domain';
|
||||
import { storageSchema, ActionDefDict } from 'oak-app-domain';
|
||||
import { aspectDict } from '../../src/aspects';
|
||||
import { initialize } from '../../src/features';
|
||||
import { checkers } from '../../src/checkers';
|
||||
import { triggers } from '../../src/triggers';
|
||||
import { data } from '../../src/data';
|
||||
import { routers } from '../../src/exceptionRouters';
|
||||
|
||||
|
||||
import { initializeFeatures as initializeGeneralFeatures } from 'oak-general-business';
|
||||
import { RuntimeContext } from '../../src/RuntimeContext';
|
||||
import {
|
||||
aspectDict,
|
||||
createFeatures,
|
||||
routers,
|
||||
triggers,
|
||||
checkers,
|
||||
data,
|
||||
token,
|
||||
} from '../../src/initialize';
|
||||
|
||||
const { token } = initializeGeneralFeatures<EntityDict, RuntimeContext, typeof aspectDict>();
|
||||
|
||||
export const createFeatures = (basicFeatures: BasicFeatures<EntityDict, RuntimeContext, typeof aspectDict>) => {
|
||||
const features = initialize(basicFeatures);
|
||||
const wholeFeatures = Object.assign({
|
||||
token,
|
||||
}, features);
|
||||
return wholeFeatures;
|
||||
}
|
||||
|
||||
const { OakComponent, OakPage, features } = InitializeWechatMp<EntityDict, RuntimeContext, typeof aspectDict, ReturnType<typeof createFeatures>>(
|
||||
const { OakComponent, OakPage, features } = InitializeWechatMp<
|
||||
EntityDict,
|
||||
RuntimeContext,
|
||||
typeof aspectDict,
|
||||
ReturnType<typeof createFeatures>
|
||||
>(
|
||||
storageSchema,
|
||||
createFeatures,
|
||||
(store, scene) => new RuntimeContext(store, data.application[0].id, () => token.getToken(), scene),
|
||||
(store, scene) =>
|
||||
new RuntimeContext(
|
||||
store,
|
||||
data.application[0].id,
|
||||
() => token.getToken(),
|
||||
scene
|
||||
),
|
||||
routers,
|
||||
triggers,
|
||||
checkers,
|
||||
aspectDict,
|
||||
data as any,
|
||||
ActionDefDict);
|
||||
ActionDefDict
|
||||
);
|
||||
|
||||
// 因为依赖的问题,token中的Cache暂时只能在这里注入。以后再修改
|
||||
token.setCache(features.cache);
|
||||
|
||||
Object.assign(global, {
|
||||
OakPage,
|
||||
OakComponent,
|
||||
});
|
||||
|
||||
export {
|
||||
features,
|
||||
};
|
||||
export { features };
|
||||
|
|
|
|||
Loading…
Reference in New Issue