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 { features } from './init';
|
||||||
import { WechatMpEnv } from 'oak-app-domain/Token/Schema';
|
|
||||||
import { features } from './init';
|
|
||||||
export interface IAppOption {
|
export interface IAppOption {
|
||||||
globalData: {
|
globalData: {
|
||||||
features: typeof features;
|
features: typeof features;
|
||||||
|
|
@ -12,25 +11,7 @@ App<IAppOption>({
|
||||||
features,
|
features,
|
||||||
},
|
},
|
||||||
async onLaunch() {
|
async onLaunch() {
|
||||||
const { code } = await wx.login();
|
await features.token.loginWechatMp('app:onLaunch');
|
||||||
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);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onHide() {
|
onHide() {
|
||||||
|
|
|
||||||
|
|
@ -1,44 +1,47 @@
|
||||||
import './utils/polyfill';
|
import './utils/polyfill';
|
||||||
import { BasicFeatures, 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 { 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 { RuntimeContext } from '../../src/RuntimeContext';
|
||||||
|
import {
|
||||||
|
aspectDict,
|
||||||
|
createFeatures,
|
||||||
|
routers,
|
||||||
|
triggers,
|
||||||
|
checkers,
|
||||||
|
data,
|
||||||
|
token,
|
||||||
|
} from '../../src/initialize';
|
||||||
|
|
||||||
const { token } = initializeGeneralFeatures<EntityDict, RuntimeContext, typeof aspectDict>();
|
const { OakComponent, OakPage, features } = InitializeWechatMp<
|
||||||
|
EntityDict,
|
||||||
export const createFeatures = (basicFeatures: BasicFeatures<EntityDict, RuntimeContext, typeof aspectDict>) => {
|
RuntimeContext,
|
||||||
const features = initialize(basicFeatures);
|
typeof aspectDict,
|
||||||
const wholeFeatures = Object.assign({
|
ReturnType<typeof createFeatures>
|
||||||
token,
|
>(
|
||||||
}, features);
|
|
||||||
return wholeFeatures;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { OakComponent, OakPage, features } = InitializeWechatMp<EntityDict, RuntimeContext, typeof aspectDict, ReturnType<typeof createFeatures>>(
|
|
||||||
storageSchema,
|
storageSchema,
|
||||||
createFeatures,
|
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,
|
routers,
|
||||||
triggers,
|
triggers,
|
||||||
checkers,
|
checkers,
|
||||||
aspectDict,
|
aspectDict,
|
||||||
data as any,
|
data as any,
|
||||||
ActionDefDict);
|
ActionDefDict
|
||||||
|
);
|
||||||
|
|
||||||
|
// 因为依赖的问题,token中的Cache暂时只能在这里注入。以后再修改
|
||||||
|
token.setCache(features.cache);
|
||||||
|
|
||||||
Object.assign(global, {
|
Object.assign(global, {
|
||||||
OakPage,
|
OakPage,
|
||||||
OakComponent,
|
OakComponent,
|
||||||
});
|
});
|
||||||
|
|
||||||
export {
|
export { features };
|
||||||
features,
|
|
||||||
};
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue