template向5.0靠拢
This commit is contained in:
parent
ec4ce79d1f
commit
8e13f79be6
|
|
@ -4,4 +4,5 @@ import { Connector, EntityDict } from 'oak-domain/lib/types';
|
|||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
||||
export declare function startup<ED extends EntityDict & BaseEntityDict, FrontCxt extends SyncContext<ED>>(path: string, connector: Connector<ED, FrontCxt>, omitWatchers?: boolean, omitTimers?: boolean, routine?: (context: AsyncContext<EntityDict & BaseEntityDict>) => Promise<void>): Promise<void>;
|
||||
import { AccessConfiguration } from 'oak-domain/lib/types/Configuration';
|
||||
export declare function startup<ED extends EntityDict & BaseEntityDict, FrontCxt extends SyncContext<ED>>(path: string, connector: Connector<ED, FrontCxt>, accessConfiguration: AccessConfiguration, omitWatchers?: boolean, omitTimers?: boolean, routine?: (context: AsyncContext<EntityDict & BaseEntityDict>) => Promise<void>): Promise<void>;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ const tslib_1 = require("tslib");
|
|||
/// <reference path="../typings/polyfill.d.ts" />
|
||||
require("./polyfill");
|
||||
const http_1 = require("http");
|
||||
const path_1 = tslib_1.__importDefault(require("path"));
|
||||
const koa_1 = tslib_1.__importDefault(require("koa"));
|
||||
const koa_router_1 = tslib_1.__importDefault(require("koa-router"));
|
||||
const koa_body_1 = tslib_1.__importDefault(require("koa-body"));
|
||||
|
|
@ -16,7 +15,7 @@ const sticky_1 = require("@socket.io/sticky");
|
|||
const socket_io_1 = require("socket.io");
|
||||
const DATA_SUBSCRIBER_NAMESPACE = '/ds';
|
||||
const SERVER_SUBSCRIBER_NAMESPACE = process.env.OAK_SSUB_NAMESPACE || '/ssub';
|
||||
async function startup(path, connector, omitWatchers, omitTimers, routine) {
|
||||
async function startup(path, connector, accessConfiguration, omitWatchers, omitTimers, routine) {
|
||||
const koa = new koa_1.default();
|
||||
// socket
|
||||
const httpServer = (0, http_1.createServer)(koa.callback());
|
||||
|
|
@ -68,7 +67,6 @@ async function startup(path, connector, omitWatchers, omitTimers, routine) {
|
|||
multipart: true,
|
||||
}));
|
||||
const router = new koa_router_1.default();
|
||||
const serverConfig = require(path_1.default.join(path, '/configuration/server.json'));
|
||||
// 如果是开发环境,允许options
|
||||
if (['development', 'staging'].includes(process.env.NODE_ENV)) {
|
||||
koa.use(async (ctx, next) => {
|
||||
|
|
@ -109,7 +107,8 @@ async function startup(path, connector, omitWatchers, omitTimers, routine) {
|
|||
namespace: DATA_SUBSCRIBER_NAMESPACE,
|
||||
path: connector.getSubscribeRouter(),
|
||||
// 如果是开发环境就直连@socket.io/pm2的监听端口
|
||||
port: process.env.NODE_ENV === 'development' ? (process.env.PM2_PORT || 8080) : serverConfig.port,
|
||||
// 这里看不懂,似乎不对,要测试。by Xc 20240410
|
||||
port: process.env.NODE_ENV === 'development' ? (process.env.PM2_PORT || 8080) : accessConfiguration.http.port,
|
||||
};
|
||||
// 开发环境socket直接连接
|
||||
return;
|
||||
|
|
@ -119,7 +118,7 @@ async function startup(path, connector, omitWatchers, omitTimers, routine) {
|
|||
response.body = {
|
||||
namespace: DATA_SUBSCRIBER_NAMESPACE,
|
||||
path: connector.getSubscribeRouter(),
|
||||
port: serverConfig.port,
|
||||
port: accessConfiguration.http.port,
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
|
@ -145,12 +144,12 @@ async function startup(path, connector, omitWatchers, omitTimers, routine) {
|
|||
ctx.response.body = endpoints;
|
||||
});
|
||||
koa.use(router.routes());
|
||||
console.log(`server will listen on port ${serverConfig.port}`);
|
||||
console.log(`server will listen on port ${accessConfiguration.http.port || (accessConfiguration.http.ssl ? 443 : 80)}`);
|
||||
koa.on('error', (err) => {
|
||||
console.error(err);
|
||||
throw err;
|
||||
});
|
||||
httpServer.listen(serverConfig.port);
|
||||
httpServer.listen(accessConfiguration.http.port);
|
||||
if (!omitWatchers) {
|
||||
appLoader.startWatchers();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ function packageJsonContent({ name, version, description, cliName, cliBinName, i
|
|||
"scripts": {
|
||||
"make:domain": "${cliBinName} make:domain",
|
||||
"make:locale": "${cliBinName} make:locale",
|
||||
"make:dep": "${cliBinName} make:dependency",
|
||||
"clean:cache": "rimraf node_modules/.cache",
|
||||
"copy-config-json": "copyfiles -u 1 src/config/*.json lib/",
|
||||
"start:mp": "${cliBinName} start --target mp --mode development",
|
||||
|
|
@ -67,6 +68,7 @@ function packageJsonContent({ name, version, description, cliName, cliBinName, i
|
|||
"build-analyze:web": "${cliBinName} build --target web --mode production --analyze",
|
||||
"build-sourcemap-analyze:web": "${cliBinName} build --target web --mode production --sourcemap --analyze",
|
||||
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && npm run copy-config-json",
|
||||
"prebuild": "npm run make:locale && npm run make:dep",
|
||||
"run:ios": "oak-cli run -p ios",
|
||||
"run:android": "oak-cli run -p android",
|
||||
"server:init": "${serverInitScript}",
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
|||
import { createAdapter } from "@socket.io/cluster-adapter";
|
||||
import { setupWorker } from "@socket.io/sticky";
|
||||
import { Server } from "socket.io";
|
||||
import { AccessConfiguration } from 'oak-domain/lib/types/Configuration';
|
||||
|
||||
const DATA_SUBSCRIBER_NAMESPACE = '/ds';
|
||||
const SERVER_SUBSCRIBER_NAMESPACE = process.env.OAK_SSUB_NAMESPACE || '/ssub';
|
||||
|
|
@ -20,6 +21,7 @@ const SERVER_SUBSCRIBER_NAMESPACE = process.env.OAK_SSUB_NAMESPACE || '/ssub';
|
|||
export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt extends SyncContext<ED>>(
|
||||
path: string,
|
||||
connector: Connector<ED, FrontCxt>,
|
||||
accessConfiguration: AccessConfiguration,
|
||||
omitWatchers?: boolean,
|
||||
omitTimers?: boolean,
|
||||
routine?: (context: AsyncContext<EntityDict & BaseEntityDict>) => Promise<void>,
|
||||
|
|
@ -78,7 +80,6 @@ export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt e
|
|||
}));
|
||||
const router = new KoaRouter();
|
||||
|
||||
const serverConfig = require(PathLib.join(path, '/configuration/server.json'));
|
||||
// 如果是开发环境,允许options
|
||||
if (['development', 'staging'].includes(process.env.NODE_ENV!)) {
|
||||
koa.use(async (ctx, next) => {
|
||||
|
|
@ -123,7 +124,8 @@ export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt e
|
|||
namespace: DATA_SUBSCRIBER_NAMESPACE,
|
||||
path: connector.getSubscribeRouter(),
|
||||
// 如果是开发环境就直连@socket.io/pm2的监听端口
|
||||
port: process.env.NODE_ENV === 'development' ? (process.env.PM2_PORT || 8080) : serverConfig.port,
|
||||
// 这里看不懂,似乎不对,要测试。by Xc 20240410
|
||||
port: process.env.NODE_ENV === 'development' ? (process.env.PM2_PORT || 8080) : accessConfiguration.http.port,
|
||||
};
|
||||
// 开发环境socket直接连接
|
||||
return;
|
||||
|
|
@ -133,7 +135,7 @@ export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt e
|
|||
response.body = {
|
||||
namespace: DATA_SUBSCRIBER_NAMESPACE,
|
||||
path: connector.getSubscribeRouter(),
|
||||
port: serverConfig.port,
|
||||
port: accessConfiguration.http.port,
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
|
@ -165,12 +167,12 @@ export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt e
|
|||
|
||||
koa.use(router.routes());
|
||||
|
||||
console.log(`server will listen on port ${serverConfig.port}`);
|
||||
console.log(`server will listen on port ${accessConfiguration.http.port || (accessConfiguration.http.ssl ? 443 : 80)}`);
|
||||
koa.on('error', (err) => {
|
||||
console.error(err);
|
||||
throw err;
|
||||
});
|
||||
httpServer.listen(serverConfig.port);
|
||||
httpServer.listen(accessConfiguration.http.port);
|
||||
|
||||
if (!omitWatchers) {
|
||||
appLoader.startWatchers();
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ export function packageJsonContent({
|
|||
"scripts": {
|
||||
"make:domain": "${cliBinName} make:domain",
|
||||
"make:locale": "${cliBinName} make:locale",
|
||||
"make:dep": "${cliBinName} make:dependency",
|
||||
"clean:cache": "rimraf node_modules/.cache",
|
||||
"copy-config-json": "copyfiles -u 1 src/config/*.json lib/",
|
||||
"start:mp": "${cliBinName} start --target mp --mode development",
|
||||
|
|
@ -76,6 +77,7 @@ export function packageJsonContent({
|
|||
"build-analyze:web": "${cliBinName} build --target web --mode production --analyze",
|
||||
"build-sourcemap-analyze:web": "${cliBinName} build --target web --mode production --sourcemap --analyze",
|
||||
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && npm run copy-config-json",
|
||||
"prebuild": "npm run make:locale && npm run make:dep",
|
||||
"run:ios": "oak-cli run -p ios",
|
||||
"run:android": "oak-cli run -p android",
|
||||
"server:init": "${serverInitScript}",
|
||||
|
|
|
|||
|
|
@ -6,3 +6,7 @@ const aspectDict = {
|
|||
} as AspectDict;
|
||||
|
||||
export default aspectDict;
|
||||
export {
|
||||
AspectDict,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
import { ColorDict } from 'oak-domain/lib/types/Style';
|
||||
import { EntityDict } from '@oak-app-domain';
|
||||
|
||||
const colorDict: ColorDict<EntityDict> = {
|
||||
|
||||
};
|
||||
|
||||
export default colorDict;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import SimpleConnector from 'oak-domain/lib/utils/SimpleConnector';
|
||||
import accessConfiguration from '@project/configuration/access';
|
||||
import { makeException } from '@project/types/Exception';
|
||||
import { EntityDict } from '@project/oak-app-domain';
|
||||
import FrontendRuntimeContext from '@project/context/FrontendRuntimeContext';
|
||||
|
||||
const connector = new SimpleConnector<EntityDict, FrontendRuntimeContext>(accessConfiguration, makeException);
|
||||
|
||||
export default connector;
|
||||
|
|
@ -1 +0,0 @@
|
|||
["oak-general-business"]
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
import { AccessConfiguration } from 'oak-domain/lib/types/Configuration';
|
||||
|
||||
const accessConfiguration: AccessConfiguration = {
|
||||
http: {
|
||||
hostname: 'localhost',
|
||||
port: 3001,
|
||||
},
|
||||
};
|
||||
|
||||
export default accessConfiguration;
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
import { AccessConfiguration } from 'oak-domain/lib/types/Configuration';
|
||||
|
||||
const accessConfiguration: AccessConfiguration = {
|
||||
http: {
|
||||
hostname: 'www.oak-framework.test',
|
||||
ssl: true,
|
||||
path: 'oak-api', // 配置在nginx中的映射
|
||||
},
|
||||
};
|
||||
|
||||
export default accessConfiguration;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
import accessConfiguration from './access.dev';
|
||||
export default accessConfiguration;
|
||||
console.log('不应该跑到这里');
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
import { AttrUpdateMatrix } from 'oak-domain/lib/types/EntityDesc';
|
||||
import { EntityDict } from '@project/oak-app-domain';
|
||||
|
||||
|
||||
const attrUpdateMatrix: AttrUpdateMatrix<EntityDict> = {
|
||||
store: {
|
||||
name: {
|
||||
filter: {
|
||||
iState: 'offline',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export default attrUpdateMatrix;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { EntityDict } from '@project/oak-app-domain';
|
||||
const cacheSavedEntities: (keyof EntityDict)[] = [];
|
||||
|
||||
export default cacheSavedEntities;
|
||||
export default cacheSavedEntities;
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
import { DependencyConfiguration } from 'oak-domain/lib/types/Configuration';
|
||||
|
||||
const dependencyConfiguration: DependencyConfiguration = ['oak-general-business'];
|
||||
|
||||
export default dependencyConfiguration;
|
||||
|
|
@ -1,6 +1,19 @@
|
|||
import { AttrUpdateMatrix } from 'oak-domain/lib/types/EntityDesc';
|
||||
/**
|
||||
* index中汇总了前端启动需要的引用配置
|
||||
*/
|
||||
import attrUpdateMatrix from './attrUpdateMatrix';
|
||||
import { CommonConfiguration } from 'oak-domain/lib/types/Configuration';
|
||||
import { actionDefDict } from '@project/oak-app-domain/ActionDefDict';
|
||||
import { selectFreeEntities, authDeduceRelationMap, updateFreeDict } from './relation';
|
||||
import cacheSavedEntities from './cache';
|
||||
import { EntityDict } from '@project/oak-app-domain';
|
||||
|
||||
export const attrUpdateMatrix: AttrUpdateMatrix<EntityDict> = {
|
||||
|
||||
}
|
||||
export default {
|
||||
attrUpdateMatrix,
|
||||
actionDefDict,
|
||||
authDeduceRelationMap,
|
||||
selectFreeEntities,
|
||||
updateFreeDict,
|
||||
cacheSavedEntities,
|
||||
// cacheKeepFreshPeriod: 600 * 1000, // cache默认对缓存对象的刷新间隔时长(在这个间隔内不刷新)
|
||||
} as CommonConfiguration<EntityDict>;
|
||||
|
|
@ -1,16 +1,13 @@
|
|||
import { AuthDeduceRelationMap, SelectFreeEntities, UpdateFreeDict } from 'oak-domain/lib/types/Entity';
|
||||
import { selectFreeEntities as ogbSFF, authDeduceRelationMap as ogbADR, updateFreeDict as obgUFD } from 'oak-general-business/lib/config/relation';
|
||||
import { EntityDict } from '@project/oak-app-domain';
|
||||
|
||||
// 此对象所标识的entity的权限由其外键指向的父对象判定
|
||||
export const authDeduceRelationMap: AuthDeduceRelationMap<EntityDict> = {
|
||||
...ogbADR,
|
||||
};
|
||||
|
||||
export const selectFreeEntities = (ogbSFF as SelectFreeEntities<EntityDict>).concat([
|
||||
|
||||
]);
|
||||
export const selectFreeEntities = [
|
||||
'store',
|
||||
];
|
||||
|
||||
export const updateFreeDict: UpdateFreeDict<EntityDict> = {
|
||||
...obgUFD
|
||||
};
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
import { RenderConfiguration } from 'oak-domain/lib/types/Configuration';
|
||||
import { styleDict } from '@project/oak-app-domain/StyleDict';
|
||||
import { EntityDict } from '@project/oak-app-domain';
|
||||
|
||||
export default {
|
||||
styleDict,
|
||||
} as RenderConfiguration<EntityDict>;
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import { ServerConfiguration } from 'oak-domain/lib/types/Configuration';
|
||||
import { EntityDict } from '@project/oak-app-domain';
|
||||
import { BackendRuntimeContext } from '@project/context/BackendRuntimeContext';
|
||||
import { join } from 'path';
|
||||
|
||||
const serverConfiguration: ServerConfiguration<EntityDict, BackendRuntimeContext> = {
|
||||
database: require('../../configuration/mysql.json'),
|
||||
workDir: {
|
||||
path: join(__dirname, '..', '..'),
|
||||
},
|
||||
};
|
||||
|
||||
export default serverConfiguration;
|
||||
|
|
@ -1,27 +1,12 @@
|
|||
import { EntityDict } from '@oak-app-domain';
|
||||
import { AsyncRowStore } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { EntityDict } from '@project/oak-app-domain';
|
||||
import { RuntimeContext } from './RuntimeContext';
|
||||
import { BackendRuntimeContext as GeneralBackendRuntimeContext } from 'oak-general-business';
|
||||
import { IncomingHttpHeaders } from 'http';
|
||||
import { BackendRuntimeContext as GeneralBackendRuntimeContext } from './DependentContext';
|
||||
|
||||
export class BackendRuntimeContext
|
||||
extends GeneralBackendRuntimeContext<EntityDict>
|
||||
implements RuntimeContext
|
||||
{
|
||||
static FromSerializedString(str?: string) {
|
||||
const data = str && JSON.parse(str);
|
||||
|
||||
return async (
|
||||
store: AsyncRowStore<EntityDict, BackendRuntimeContext>
|
||||
) => {
|
||||
const context = new BackendRuntimeContext(store);
|
||||
await context.initialize(data);
|
||||
return context;
|
||||
};
|
||||
}
|
||||
|
||||
async toString(): Promise<string> {
|
||||
export class BackendRuntimeContext extends GeneralBackendRuntimeContext<EntityDict> implements RuntimeContext {
|
||||
async toString() {
|
||||
const data = await this.getSerializedData();
|
||||
return JSON.stringify(data);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default BackendRuntimeContext;
|
||||
|
|
@ -1,28 +1,17 @@
|
|||
import { EntityDict } from '@oak-app-domain';
|
||||
import { EntityDict } from '@project/oak-app-domain';
|
||||
import {
|
||||
FrontendRuntimeContext as GeneralFrontendRuntimeContext,
|
||||
GeneralAspectDict,
|
||||
} from 'oak-general-business';
|
||||
import { CommonAspectDict } from 'oak-common-aspect/lib/AspectDict';
|
||||
} from './DependentContext';
|
||||
import { RuntimeContext } from './RuntimeContext';
|
||||
import { AspectDict } from '../aspects/AspectDict';
|
||||
import { BackendRuntimeContext } from './BackendRuntimeContext';
|
||||
import { SyncContext, SyncRowStore } from 'oak-domain/lib/store/SyncRowStore';
|
||||
|
||||
type FullAspectDict = CommonAspectDict<EntityDict, BackendRuntimeContext> &
|
||||
AspectDict &
|
||||
GeneralAspectDict<EntityDict, BackendRuntimeContext>;
|
||||
|
||||
export class FrontendRuntimeContext
|
||||
extends GeneralFrontendRuntimeContext<
|
||||
EntityDict,
|
||||
BackendRuntimeContext,
|
||||
FullAspectDict
|
||||
>
|
||||
extends GeneralFrontendRuntimeContext<EntityDict>
|
||||
implements RuntimeContext
|
||||
{
|
||||
async toString(): Promise<string> {
|
||||
async toString() {
|
||||
const data = await this.getSerializedData();
|
||||
return JSON.stringify(data);
|
||||
}
|
||||
}
|
||||
|
||||
export default FrontendRuntimeContext;
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
// 本文件为自动编译产生,请勿直接修改
|
||||
|
||||
import { CreateOperationData as I18n } from "../oak-app-domain/I18n/Schema";
|
||||
import i18ns0 from "oak-general-business/lib/data/i18n";
|
||||
const i18ns: I18n[] = [];
|
||||
export default i18ns.concat(i18ns0);
|
||||
export default i18ns;
|
||||
|
|
@ -18,14 +18,14 @@ export interface Schema extends EntityShape {
|
|||
files: Array<ExtraFile>; //封面图
|
||||
}
|
||||
|
||||
type IAction = 'online' | 'offline' | 'disabled';
|
||||
type IAction = 'online' | 'offline' | 'disable';
|
||||
type IState = 'online' | 'offline' | 'disabled';
|
||||
|
||||
const IActionDef: ActionDef<IAction, IState> = {
|
||||
stm: {
|
||||
online: ['offline', 'online'],
|
||||
offline: ['online', 'offline'],
|
||||
disabled: [['online', 'offline'], 'disabled'],
|
||||
disable: [['online', 'offline'], 'disabled'],
|
||||
},
|
||||
is: 'offline',
|
||||
};
|
||||
|
|
@ -67,7 +67,7 @@ const entityDesc: EntityDesc<
|
|||
action: {
|
||||
online: '上线',
|
||||
offline: '下线',
|
||||
disabled: '禁用',
|
||||
disable: '禁用',
|
||||
},
|
||||
v: {
|
||||
iState: {
|
||||
|
|
@ -78,4 +78,18 @@ const entityDesc: EntityDesc<
|
|||
},
|
||||
},
|
||||
},
|
||||
style: {
|
||||
icon: {
|
||||
offline: '',
|
||||
online: '',
|
||||
disable: ''
|
||||
},
|
||||
color: {
|
||||
iState: {
|
||||
offline: '#FFFFFF',
|
||||
online: '#FF0000',
|
||||
disabled: '#00FF00',
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,15 +1,11 @@
|
|||
import { EntityDict } from '@project/oak-app-domain';
|
||||
import { Feature } from 'oak-frontend-base';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { AspectDict } from '../aspects/AspectDict';
|
||||
import { BackendRuntimeContext } from '@project/context/BackendRuntimeContext';
|
||||
import { FrontendRuntimeContext } from '@project/context/FrontendRuntimeContext';
|
||||
import { Cache } from 'oak-frontend-base/es/features/cache';
|
||||
|
||||
export default class Console extends Feature {
|
||||
private cache: Cache<EntityDict, BackendRuntimeContext, FrontendRuntimeContext, CommonAspectDict<EntityDict, BackendRuntimeContext>>;
|
||||
private cache: Cache<EntityDict>;
|
||||
|
||||
constructor(cache: Cache<EntityDict, BackendRuntimeContext, FrontendRuntimeContext, CommonAspectDict<EntityDict, BackendRuntimeContext>>) {
|
||||
constructor(cache: Cache<EntityDict>) {
|
||||
super();
|
||||
this.cache = cache;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,5 @@
|
|||
import { EntityDict } from '@project/oak-app-domain';
|
||||
import { Feature } from 'oak-frontend-base';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { AspectDict } from '../aspects/AspectDict';
|
||||
import { BackendRuntimeContext } from '@project/context/BackendRuntimeContext';
|
||||
import { FrontendRuntimeContext } from '@project/context/FrontendRuntimeContext';
|
||||
import { groupBy } from 'oak-domain/lib/utils/lodash';
|
||||
import { ContextMenuFactory } from 'oak-frontend-base/es/features/contextMenuFactory';
|
||||
import Console from './Console';
|
||||
|
||||
|
|
@ -58,18 +53,12 @@ const menus: IMenu<keyof EntityDict>[] = [
|
|||
];
|
||||
|
||||
export default class Menu extends Feature {
|
||||
private contextMenuFactory: ContextMenuFactory<EntityDict,
|
||||
BackendRuntimeContext,
|
||||
FrontendRuntimeContext,
|
||||
AspectDict & CommonAspectDict<EntityDict, BackendRuntimeContext>>;
|
||||
private contextMenuFactory: ContextMenuFactory<EntityDict>;
|
||||
private console: Console;
|
||||
private menus?: OMenu[];
|
||||
|
||||
constructor(
|
||||
contextMenuFactory: ContextMenuFactory<EntityDict,
|
||||
BackendRuntimeContext,
|
||||
FrontendRuntimeContext,
|
||||
AspectDict & CommonAspectDict<EntityDict, BackendRuntimeContext>>,
|
||||
contextMenuFactory: ContextMenuFactory<EntityDict>,
|
||||
console: Console
|
||||
) {
|
||||
super();
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
import { EntityDict } from '@oak-app-domain';
|
||||
import { BasicFeatures, Feature } from 'oak-frontend-base';
|
||||
import { CommonAspectDict } from 'oak-common-aspect/lib/AspectDict';
|
||||
import { AspectDict } from '../aspects/AspectDict';
|
||||
import { BackendRuntimeContext } from '@project/context/BackendRuntimeContext';
|
||||
import { FrontendRuntimeContext } from '@project/context/FrontendRuntimeContext';
|
||||
|
||||
type DoSthAcion = {
|
||||
type: 'doSth';
|
||||
|
|
@ -19,20 +15,10 @@ export default class Sample extends Feature {
|
|||
action(action: DoSthAcion) {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
cache: BasicFeatures<
|
||||
EntityDict,
|
||||
BackendRuntimeContext,
|
||||
FrontendRuntimeContext,
|
||||
AspectDict & CommonAspectDict<EntityDict, BackendRuntimeContext>
|
||||
>['cache'];
|
||||
cache: BasicFeatures<EntityDict>['cache'];
|
||||
|
||||
constructor(
|
||||
cache: BasicFeatures<
|
||||
EntityDict,
|
||||
BackendRuntimeContext,
|
||||
FrontendRuntimeContext,
|
||||
AspectDict & CommonAspectDict<EntityDict, BackendRuntimeContext>
|
||||
>['cache']
|
||||
cache: BasicFeatures<EntityDict>['cache']
|
||||
) {
|
||||
super();
|
||||
this.cache = cache;
|
||||
|
|
|
|||
|
|
@ -1,32 +1,12 @@
|
|||
import { EntityDict } from '@oak-app-domain';
|
||||
import { BasicFeatures } from 'oak-frontend-base';
|
||||
import { GeneralFeatures, GeneralAspectDict } from 'oak-general-business';
|
||||
import { CommonAspectDict } from 'oak-common-aspect/lib/AspectDict';
|
||||
import { AspectDict } from '../aspects/AspectDict';
|
||||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext';
|
||||
import { AAD, AFD } from '@project/types/RuntimeCxt';
|
||||
import { FeatureDict as GeneralFeatureDict } from 'oak-general-business';
|
||||
import Sample from './Sample';
|
||||
import Console from './Console';
|
||||
import Menu from './Menu';
|
||||
|
||||
export function initialize(
|
||||
generalFeatures: BasicFeatures<
|
||||
EntityDict,
|
||||
BackendRuntimeContext,
|
||||
FrontendRuntimeContext,
|
||||
AspectDict &
|
||||
CommonAspectDict<EntityDict, BackendRuntimeContext> &
|
||||
GeneralAspectDict<EntityDict, BackendRuntimeContext>
|
||||
> &
|
||||
GeneralFeatures<
|
||||
EntityDict,
|
||||
BackendRuntimeContext,
|
||||
FrontendRuntimeContext,
|
||||
AspectDict &
|
||||
CommonAspectDict<EntityDict, BackendRuntimeContext> &
|
||||
GeneralAspectDict<EntityDict, BackendRuntimeContext>
|
||||
>
|
||||
export function create(
|
||||
generalFeatures: BasicFeatures<EntityDict> & GeneralFeatureDict<EntityDict>
|
||||
) {
|
||||
const {
|
||||
cache,
|
||||
|
|
@ -48,4 +28,4 @@ export function initialize(
|
|||
};
|
||||
}
|
||||
|
||||
export type FeatureDict = ReturnType<typeof initialize>;
|
||||
export type FeatureDict = ReturnType<typeof create>;
|
||||
|
|
|
|||
|
|
@ -1,74 +0,0 @@
|
|||
import { initialize as init } from 'oak-general-business/es/initialize.dev';
|
||||
import { GFD, GAD } from 'oak-general-business';
|
||||
|
||||
import { EntityDict, storageSchema, ActionDefDict } from '@oak-app-domain';
|
||||
import { BackendRuntimeContext } from './context/BackendRuntimeContext';
|
||||
import { FrontendRuntimeContext } from './context/FrontendRuntimeContext';
|
||||
|
||||
import { initialize as initializeFeatures, FeatureDict } from './features';
|
||||
|
||||
// dev需要将下面内容也传入
|
||||
import { AspectDict } from './aspects/AspectDict';
|
||||
import aspectDict from './aspects';
|
||||
import triggers from './triggers';
|
||||
import watchers from './watchers';
|
||||
import data from './data';
|
||||
import checkers from './checkers';
|
||||
import timers from './timers';
|
||||
import { importations, exportations } from './ports';
|
||||
import startRoutines from './routines/start';
|
||||
import colorDict from './config/color';
|
||||
import cacheSavedEntities from './config/cache';
|
||||
import {
|
||||
selectFreeEntities,
|
||||
updateFreeDict,
|
||||
authDeduceRelationMap,
|
||||
} from './config/relation';
|
||||
|
||||
import { AppType } from '@oak-app-domain/Application/Schema';
|
||||
|
||||
export default function initialize(type: AppType, hostname: string) {
|
||||
const wholeFeatures = {} as GFD<
|
||||
EntityDict,
|
||||
BackendRuntimeContext,
|
||||
FrontendRuntimeContext,
|
||||
AspectDict & GAD<EntityDict, BackendRuntimeContext>
|
||||
> &
|
||||
FeatureDict;
|
||||
const { features } = init<
|
||||
EntityDict,
|
||||
BackendRuntimeContext,
|
||||
AspectDict,
|
||||
FrontendRuntimeContext
|
||||
>(
|
||||
type,
|
||||
hostname,
|
||||
storageSchema,
|
||||
(store) => new FrontendRuntimeContext(store, wholeFeatures),
|
||||
(store) => new BackendRuntimeContext(store),
|
||||
aspectDict,
|
||||
triggers,
|
||||
checkers,
|
||||
watchers,
|
||||
timers,
|
||||
startRoutines,
|
||||
data as any,
|
||||
{
|
||||
actionDict: ActionDefDict,
|
||||
colorDict,
|
||||
importations,
|
||||
exportations,
|
||||
authDeduceRelationMap,
|
||||
selectFreeEntities,
|
||||
updateFreeDict,
|
||||
cacheSavedEntities,
|
||||
}
|
||||
);
|
||||
|
||||
const appFeatures = initializeFeatures(features);
|
||||
|
||||
Object.assign(wholeFeatures, appFeatures, features);
|
||||
return {
|
||||
features: wholeFeatures,
|
||||
};
|
||||
}
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
import { initialize as init } from 'oak-general-business/es/initialize.prod';
|
||||
|
||||
import { SimpleConnector } from 'oak-domain/lib/utils/SimpleConnector';
|
||||
import {
|
||||
EntityDict,
|
||||
storageSchema,
|
||||
ActionDefDict,
|
||||
} from '@oak-app-domain';
|
||||
import { BackendRuntimeContext } from './context/BackendRuntimeContext';
|
||||
import { FrontendRuntimeContext } from './context/FrontendRuntimeContext';
|
||||
|
||||
import { initialize as initializeFeatures } from './features';
|
||||
import checkers from './checkers';
|
||||
import { makeException } from './types/Exception';
|
||||
import { AspectDict } from './aspects/AspectDict';
|
||||
import colorDict from './config/color';
|
||||
import cacheSavedEntities from './config/cache';
|
||||
import { selectFreeEntities, updateFreeDict, authDeduceRelationMap } from './config/relation';
|
||||
|
||||
import { AppType } from '@oak-app-domain/Application/Schema';
|
||||
import { AFD } from '@project/types/RuntimeCxt';
|
||||
|
||||
const NGINX_PROXY_PATH = '/oak-api'; // nginx反射代理到系统的映射
|
||||
|
||||
export default function initialize(
|
||||
type: AppType,
|
||||
hostname: string,
|
||||
protocol?: 'http:' | 'https:',
|
||||
apiPath?: string,
|
||||
port?: number
|
||||
) {
|
||||
const connector = new SimpleConnector<EntityDict, FrontendRuntimeContext>(
|
||||
{
|
||||
protocol: protocol || 'http:',
|
||||
hostname,
|
||||
port,
|
||||
apiPath: typeof apiPath === 'string' ? apiPath : NGINX_PROXY_PATH,
|
||||
},
|
||||
makeException
|
||||
);
|
||||
const wholeFeatures = {} as AFD;
|
||||
const { features } = init<
|
||||
EntityDict,
|
||||
BackendRuntimeContext,
|
||||
AspectDict,
|
||||
FrontendRuntimeContext
|
||||
>(
|
||||
type,
|
||||
hostname,
|
||||
storageSchema,
|
||||
(store) =>
|
||||
new FrontendRuntimeContext(
|
||||
store,
|
||||
wholeFeatures
|
||||
),
|
||||
connector,
|
||||
checkers,
|
||||
{
|
||||
actionDict: ActionDefDict,
|
||||
colorDict,
|
||||
authDeduceRelationMap,
|
||||
selectFreeEntities,
|
||||
updateFreeDict,
|
||||
cacheSavedEntities,
|
||||
}
|
||||
);
|
||||
|
||||
const appFeatures = initializeFeatures(features);
|
||||
|
||||
Object.assign(wholeFeatures, appFeatures, features);
|
||||
return {
|
||||
features: wholeFeatures,
|
||||
};
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
export { createComponent } from 'oak-general-business/es/page.mp';
|
||||
export { createComponent } from 'oak-frontend-base/es/page.mp';
|
||||
|
|
@ -0,0 +1 @@
|
|||
export { createComponent } from 'oak-frontend-base/es/page.native';
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
// for 编译
|
||||
export { createComponent } from 'oak-general-business/es/page.web';
|
||||
export { createComponent } from 'oak-frontend-base/es/page.web';
|
||||
|
|
@ -1 +1 @@
|
|||
export { createComponent } from 'oak-general-business/es/page.web';
|
||||
export { createComponent } from 'oak-frontend-base/es/page.web';
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { OakException } from 'oak-domain/lib/types';
|
||||
import { EntityDict } from '@oak-app-domain';
|
||||
import { EntityDict } from '@project/oak-app-domain';
|
||||
import { makeException as makeGeneralException } from 'oak-general-business';
|
||||
|
||||
export class ExampleException extends OakException<EntityDict> {}
|
||||
|
|
@ -7,7 +7,7 @@ export class ExampleException extends OakException<EntityDict> {}
|
|||
export function makeException(msg: string | object) {
|
||||
const data = typeof msg === 'string' ? JSON.parse(msg) : msg;
|
||||
|
||||
const exception = makeGeneralException(data);
|
||||
const exception = makeGeneralException<EntityDict>(data);
|
||||
if (exception) {
|
||||
return exception;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
import { AspectDict } from "@project/aspects/AspectDict";
|
||||
import { FeatureDict } from "@project/features";
|
||||
import { EntityDict } from "@oak-app-domain";
|
||||
import { BasicFeatures } from "oak-frontend-base";
|
||||
import { GFD, GAD } from "oak-general-business";
|
||||
import { BackendRuntimeContext } from "../context/BackendRuntimeContext";
|
||||
import { FrontendRuntimeContext } from "../context/FrontendRuntimeContext";
|
||||
|
||||
|
||||
type BRC = BackendRuntimeContext;
|
||||
type FRC = FrontendRuntimeContext;
|
||||
export type RuntimeCxt = FRC | BRC;
|
||||
|
||||
export type AAD = AspectDict & GAD<EntityDict, BackendRuntimeContext>;
|
||||
export type AFD = FeatureDict & GFD<EntityDict, BackendRuntimeContext, FrontendRuntimeContext, AAD>;
|
||||
|
|
@ -4,10 +4,7 @@ import ReactDOM from 'react-dom/client';
|
|||
import { createBrowserHistory } from 'history';
|
||||
import { unstable_HistoryRouter as HistoryRouter } from 'react-router-dom';
|
||||
import { ConfigProvider } from 'antd';
|
||||
import {
|
||||
StyleProvider,
|
||||
legacyLogicalPropertiesTransformer,
|
||||
} from '@ant-design/cssinjs';
|
||||
import { StyleProvider, legacyLogicalPropertiesTransformer } from '@ant-design/cssinjs';
|
||||
import dayjs from 'dayjs';
|
||||
import 'dayjs/locale/zh-cn';
|
||||
import zhCN from 'antd/locale/zh_CN';
|
||||
|
|
@ -20,6 +17,7 @@ import './index.less';
|
|||
import App from './App';
|
||||
import reportWebVitals from './reportWebVitals';
|
||||
import { handler as exceptionHandler } from '@project/exceptionHandler';
|
||||
import initializeFeatures from '@project/initializeFeatures';
|
||||
|
||||
import { features } from './initialize';
|
||||
dayjs.locale('zh-cn');
|
||||
|
|
@ -42,11 +40,8 @@ features.navigator.setHistory(history);
|
|||
|
||||
const init = async () => {
|
||||
let error;
|
||||
const location = features.navigator.getLocation();
|
||||
const searchParams = new URLSearchParams(location.search);
|
||||
const appId = searchParams.get('appId');
|
||||
try {
|
||||
await features.application.initialize(appId);
|
||||
await initializeFeatures(features);
|
||||
} catch (err) {
|
||||
error = err;
|
||||
}
|
||||
|
|
@ -54,18 +49,20 @@ const init = async () => {
|
|||
const application = features.application.getApplication();
|
||||
const folder = application?.system?.folder;
|
||||
|
||||
//微信JSSDK验签时, 在IOS上,无论路由切换到哪个页面,实际真正有效的的签名URL是【第一次进入应用时的URL】
|
||||
features.weiXinJsSdk.setLandingUrl(window.location.href);
|
||||
|
||||
// 抓到异常处理 1、token过期 2、网络断了 3、接口请求失败
|
||||
root.render(
|
||||
<HistoryRouter history={history as any}>
|
||||
<ResponsiveProvider>
|
||||
<FeaturesProvider features={features as any}>
|
||||
<ConfigProvider locale={zhCN}>
|
||||
<ConfigProvider
|
||||
locale={zhCN}
|
||||
>
|
||||
|
||||
<StyleProvider
|
||||
hashPriority="high"
|
||||
transformers={[legacyLogicalPropertiesTransformer]}
|
||||
transformers={[
|
||||
legacyLogicalPropertiesTransformer,
|
||||
]}
|
||||
>
|
||||
<App folder={folder as any} error={error} />
|
||||
</StyleProvider>
|
||||
|
|
|
|||
|
|
@ -1,26 +1,15 @@
|
|||
|
||||
import { getAppType } from './utils/env';
|
||||
import initialize from '@project/initialize';
|
||||
import { createComponent } from '@project/page';
|
||||
// import { port } from '../../configuration/server.json';
|
||||
const configuration = require('../../configuration/server.json');
|
||||
|
||||
const appType = getAppType();
|
||||
|
||||
const { features } = initialize(
|
||||
appType,
|
||||
window.location.hostname,
|
||||
// 以下三行打开为dev模式
|
||||
undefined,
|
||||
'',
|
||||
configuration.port,
|
||||
);
|
||||
const { features } = initialize();
|
||||
|
||||
Object.assign(global, {
|
||||
features,
|
||||
OakComponent: (options: any) => createComponent(options, features),
|
||||
});
|
||||
|
||||
|
||||
export {
|
||||
features,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
import { AspectDict } from "@project/aspects/AspectDict";
|
||||
import { FeatureDict } from "@project/features";
|
||||
import { EntityDict } from "@project/oak-app-domain";
|
||||
import { BasicFeatures } from "oak-frontend-base";
|
||||
import { BackendRuntimeContext } from "@project/context/BackendRuntimeContext";
|
||||
import { FrontendRuntimeContext } from "@project/context/FrontendRuntimeContext";
|
||||
|
||||
|
||||
type BRC = BackendRuntimeContext;
|
||||
type FRC = FrontendRuntimeContext;
|
||||
export type RuntimeCxt = FRC | BRC;
|
||||
|
||||
export type AAD = AspectDict;
|
||||
export type AFD = FeatureDict & BasicFeatures<EntityDict>;
|
||||
|
|
@ -11,7 +11,7 @@ import data from '@project/data';
|
|||
import startRoutines from '@project/routines/start';
|
||||
import { importations, exportations } from '@project/ports';
|
||||
import { create as createFeatures, FeatureDict } from '@project/features';
|
||||
import aspects, { AspectDict } from '@project/aspects';
|
||||
import aspects from '@project/aspects';
|
||||
import common from '@project/configuration';
|
||||
import render from '@project/configuration/render';
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ export default function initialize() {
|
|||
);
|
||||
|
||||
const totalFeatures = {} as FeatureDict & BasicFeatures<EntityDict>;
|
||||
const { features } = initFrontend<EntityDict, BackendRuntimeContext, FrontendRuntimeContext, AspectDict>(
|
||||
const { features } = initFrontend<EntityDict, BackendRuntimeContext, FrontendRuntimeContext>(
|
||||
storageSchema,
|
||||
(store) => new FrontendRuntimeContext(store, totalFeatures),
|
||||
debugConnector,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { mergeConcatMany } from 'oak-domain/lib/utils/lodash';
|
||||
import BackendRuntimeContext from '@project/context/BackendRuntimeContext';
|
||||
import FrontendRuntimeContext from '@project/context/FrontendRuntimeContext';
|
||||
import Connector from '@project/connector';
|
||||
import connector from '@project/config/connector';
|
||||
|
||||
import { EntityDict, storageSchema } from '@project/oak-app-domain';
|
||||
import checkers from '@project/checkers';
|
||||
|
|
@ -17,7 +17,6 @@ import render from '@project/configuration/render';
|
|||
|
||||
import { initialize as initFrontend } from 'oak-frontend-base/es/initialize';
|
||||
import { BasicFeatures } from 'oak-frontend-base/es/features';
|
||||
import { AspectDict } from './aspects';
|
||||
|
||||
export default function initialize() {
|
||||
const totalCheckers = mergeConcatMany([checkers] as Array<typeof checkers>),
|
||||
|
|
@ -25,10 +24,10 @@ export default function initialize() {
|
|||
totalRender = mergeConcatMany([render] as Array<typeof render>);
|
||||
|
||||
const totalFeatures = {} as FeatureDict & BasicFeatures<EntityDict>;
|
||||
const { features } = initFrontend<EntityDict, BackendRuntimeContext, FrontendRuntimeContext, AspectDict>(
|
||||
const { features } = initFrontend<EntityDict, BackendRuntimeContext, FrontendRuntimeContext>(
|
||||
storageSchema,
|
||||
(store) => new FrontendRuntimeContext(store, totalFeatures),
|
||||
Connector,
|
||||
connector,
|
||||
totalCheckers,
|
||||
totalCommon,
|
||||
totalRender
|
||||
|
|
|
|||
Loading…
Reference in New Issue