Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-frontend-base into dev
This commit is contained in:
commit
5a7d753868
|
|
@ -28,7 +28,7 @@ export function initializeStep2<
|
|||
ED extends EntityDict & BaseEntityDict,
|
||||
Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>,
|
||||
AD extends Record<string, Aspect<ED, Cxt>>>(
|
||||
features: Pick<BasicFeatures<ED, Cxt, FrontCxt, AD>, 'localStorage' | 'environment'>,
|
||||
features: Pick<BasicFeatures<ED, Cxt, FrontCxt, AD>, 'localStorage' | 'environment' | 'message'>,
|
||||
aspectWrapper: AspectWrapper<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>,
|
||||
storageSchema: StorageSchema<ED>,
|
||||
frontendContextBuilder: () => (store: CacheStore<ED, FrontCxt>) => FrontCxt,
|
||||
|
|
@ -48,7 +48,7 @@ export function initializeStep2<
|
|||
updateFreeEntities?: (keyof ED)[],
|
||||
savedEntities?: (keyof ED)[],
|
||||
keepFreshPeriod?: number) {
|
||||
const { localStorage, environment } = features;
|
||||
const { localStorage, environment, message } = features;
|
||||
const cache = new Cache<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>(storageSchema, aspectWrapper,
|
||||
frontendContextBuilder, checkers, getFullDataFn, localStorage, savedEntities, keepFreshPeriod);
|
||||
const relationAuth = new RelationAuth<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>(cache,
|
||||
|
|
@ -59,7 +59,7 @@ export function initializeStep2<
|
|||
const style = new Style<ED>(colorDict);
|
||||
const locales = new Locales(cache, localStorage, environment, 'zh-CN', makeBridgeUrlFn); // 临时性代码,应由上层传入
|
||||
const contextMenuFactory = new ContextMenuFactory<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>(cache, relationAuth, actionCascadePathGraph);
|
||||
const subscriber = new SubScriber(cache, getSubscribePointFn);
|
||||
const subscriber = new SubScriber(cache, message, getSubscribePointFn);
|
||||
return {
|
||||
cache,
|
||||
relationAuth,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { CommonAspectDict } from 'oak-common-aspect';
|
|||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { pull, omit } from 'oak-domain/lib/utils/lodash';
|
||||
import { Cache } from './cache';
|
||||
import { Message } from './message';
|
||||
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
||||
import io, { Socket } from '../utils/socket.io/socket.io';
|
||||
import { Feature } from '../types/Feature';
|
||||
|
|
@ -18,6 +19,7 @@ export class SubScriber<
|
|||
AD extends CommonAspectDict<ED, Cxt> & Record<string, Aspect<ED, Cxt>>
|
||||
> extends Feature {
|
||||
private cache: Cache<ED, Cxt, FrontCxt, AD>;
|
||||
private message: Message;
|
||||
private getSubscribePointFn: () => Promise<{
|
||||
url: string;
|
||||
path: string;
|
||||
|
|
@ -43,6 +45,7 @@ export class SubScriber<
|
|||
|
||||
constructor(
|
||||
cache: Cache<ED, Cxt, FrontCxt, AD>,
|
||||
message: Message,
|
||||
getSubscribePointFn: () => Promise<{
|
||||
url: string;
|
||||
path: string;
|
||||
|
|
@ -50,6 +53,7 @@ export class SubScriber<
|
|||
) {
|
||||
super();
|
||||
this.cache = cache;
|
||||
this.message = message;
|
||||
this.getSubscribePointFn = getSubscribePointFn;
|
||||
}
|
||||
|
||||
|
|
@ -110,8 +114,17 @@ export class SubScriber<
|
|||
});
|
||||
|
||||
if (Object.keys(this.subDataMap).length > 0) {
|
||||
socket.emit('sub', this.subDataMap, (success: boolean) => {
|
||||
|
||||
const data = Object.values(this.subDataMap).map(
|
||||
ele => omit(ele, 'callback')
|
||||
);
|
||||
socket.emit('sub', data, (result: string) => {
|
||||
if (result) {
|
||||
this.message.setMessage({
|
||||
type: 'error',
|
||||
title: 'sub data error',
|
||||
content: result,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
|
@ -160,7 +173,15 @@ export class SubScriber<
|
|||
if (this.socketState === 'unconnected') {
|
||||
this.connect();
|
||||
} else if (this.socketState === 'connected') {
|
||||
this.socket?.emit('sub', data);
|
||||
this.socket!.emit('sub', data, (result: string) => {
|
||||
if (result) {
|
||||
this.message.setMessage({
|
||||
type: 'error',
|
||||
title: 'sub data error',
|
||||
content: result,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue