模板wechatMp的初始化登录以及注入stm
This commit is contained in:
parent
4ab80560db
commit
7d7ba2a1e8
|
|
@ -1,13 +1,36 @@
|
|||
import './init';
|
||||
import { pick } from 'lodash';
|
||||
import { WechatMpEnv } from 'oak-app-domain/Token/Schema';
|
||||
import { features } from './init';
|
||||
export interface IAppOption {
|
||||
globalData: {};
|
||||
globalData: {
|
||||
features: typeof features;
|
||||
};
|
||||
}
|
||||
|
||||
App<IAppOption>({
|
||||
globalData: {
|
||||
features,
|
||||
},
|
||||
async onLaunch() {
|
||||
console.log('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);
|
||||
},
|
||||
|
||||
onHide() {
|
||||
|
|
|
|||
|
|
@ -1,33 +1,44 @@
|
|||
import { InitializeWechatMp, } from 'oak-frontend-base';
|
||||
import './utils/polyfill';
|
||||
import { BasicFeatures, InitializeWechatMp, } from 'oak-frontend-base';
|
||||
import { EntityDict } from 'oak-app-domain';
|
||||
import { storageSchema } from 'oak-app-domain/Storage';
|
||||
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';
|
||||
|
||||
const { token } = initializeGeneralFeatures();
|
||||
const { token } = initializeGeneralFeatures<EntityDict, RuntimeContext, typeof aspectDict>();
|
||||
|
||||
const { OakComponent, OakPage } = InitializeWechatMp<EntityDict, RuntimeContext, typeof aspectDict, {}>(
|
||||
storageSchema,
|
||||
(basicFeatures) => {
|
||||
export const createFeatures = (basicFeatures: BasicFeatures<EntityDict, RuntimeContext, typeof aspectDict>) => {
|
||||
const features = initialize(basicFeatures);
|
||||
return Object.assign({
|
||||
const wholeFeatures = Object.assign({
|
||||
token,
|
||||
}, features);
|
||||
},
|
||||
return wholeFeatures;
|
||||
}
|
||||
|
||||
const { OakComponent, OakPage, features } = InitializeWechatMp<EntityDict, RuntimeContext, typeof aspectDict, ReturnType<typeof createFeatures>>(
|
||||
storageSchema,
|
||||
createFeatures,
|
||||
(store) => new RuntimeContext(store, data.application[0].id, token.getToken()),
|
||||
routers,
|
||||
triggers,
|
||||
checkers,
|
||||
aspectDict,
|
||||
data as any);
|
||||
data as any,
|
||||
ActionDefDict);
|
||||
|
||||
Object.assign(global, {
|
||||
OakPage,
|
||||
OakComponent,
|
||||
});
|
||||
|
||||
export {
|
||||
features,
|
||||
};
|
||||
Loading…
Reference in New Issue