改了启动代码
This commit is contained in:
parent
8d7b2dd141
commit
b80d3b92d5
|
|
@ -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,27 +1,9 @@
|
|||
import './utils/polyfill';
|
||||
import { BasicFeatures, InitializeWechatMp, } from 'oak-frontend-base';
|
||||
import "./utils/polyfill";
|
||||
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';
|
||||
|
||||
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;
|
||||
}
|
||||
import { aspectDict, createFeatures, routers, triggers, checkers, data, token } from '../../src/initialize';
|
||||
|
||||
const { OakComponent, OakPage, features } = InitializeWechatMp<EntityDict, RuntimeContext, typeof aspectDict, ReturnType<typeof createFeatures>>(
|
||||
storageSchema,
|
||||
|
|
@ -34,6 +16,9 @@ const { OakComponent, OakPage, features } = InitializeWechatMp<EntityDict, Runti
|
|||
data as any,
|
||||
ActionDefDict);
|
||||
|
||||
// 因为依赖的问题,token中的Cache暂时只能在这里注入。以后再修改
|
||||
token.setCache(features.cache);
|
||||
|
||||
Object.assign(global, {
|
||||
OakPage,
|
||||
OakComponent,
|
||||
|
|
|
|||
|
|
@ -1,24 +1,12 @@
|
|||
import '../../../src/utils/polyfill';
|
||||
// getRandomValues在wechatMp下的实现
|
||||
async function getRandomValues(length: number) {
|
||||
if (length > 65536) {
|
||||
throw new Error('Can only request a maximum of 65536 bytes')
|
||||
}
|
||||
|
||||
const { randomValues } = await wx.getRandomValues({
|
||||
length,
|
||||
});
|
||||
return new Uint8Array(randomValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装wx环境下的fetch,注意有部分属性并非完全吻合,请谨慎使用
|
||||
* @param url
|
||||
* @param options
|
||||
* @returns
|
||||
*/
|
||||
// import '../../../src/utils/polyfill';
|
||||
|
||||
Object.assign(global, {
|
||||
/**
|
||||
* 封装wx环境下的fetch,注意有部分属性并非完全吻合,请谨慎使用
|
||||
* @param url
|
||||
* @param options
|
||||
* @returns
|
||||
*/
|
||||
fetch: async (url: string, options?: Parameters<typeof global.fetch>[1]) => {
|
||||
const params = Object.assign({
|
||||
method: 'GET',
|
||||
|
|
@ -73,5 +61,15 @@ Object.assign(global, {
|
|||
}
|
||||
);
|
||||
},
|
||||
getRandomValues,
|
||||
getRandomValues: async function getRandomValues(length: number) {
|
||||
if (length > 65536) {
|
||||
throw new Error('Can only request a maximum of 65536 bytes')
|
||||
}
|
||||
|
||||
const { randomValues } = await wx.getRandomValues({
|
||||
length,
|
||||
});
|
||||
return new Uint8Array(randomValues);
|
||||
}
|
||||
,
|
||||
});
|
||||
Loading…
Reference in New Issue