import { EntityDict } from 'oak-domain/lib/types'; import { Feature } from '../types/Feature'; import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain'; import { Cache } from './cache'; import { LocalStorage } from './localStorage'; interface UserFeature extends Feature { getUserId(allowUnloggedIn?: boolean): string | undefined; isRoot(): boolean; } /** * 1、destEntity如果不写,只对root可见 * 2、destEntity为一些特殊的Entity时,actions/path可以不写 * 当前只支持userRelation,对此entity可以授权的用户可见 */ export interface Menu { destEntity?: T | ''; actions?: Array; path?: string; url: string; } export interface ConsoleContext { entity: keyof ED; entityId: string; } export default abstract class Console> extends Feature { protected cache: Cache; protected localStorage: LocalStorage; protected abstract entities: (keyof ED)[]; protected abstract menus: OMenu[]; protected user: UserFeature; protected userId?: string; protected isRoot?: boolean; protected consoleContext?: ConsoleContext; private availMenus; private unsubFns; private initialize; private saveContext; private onUserChanged; private initAvailMenus; private checkAvailMenus; constructor(cache: Cache, localStorage: LocalStorage, user: UserFeature, getEntityProjection: (entity: T) => ED[T]['Projection']); private loadContext; setContext(entity: keyof ED, entityId: string): void; getContext(): ConsoleContext | undefined; getAvailMenus(): (OMenu & { sourceEntity?: keyof ED; available: boolean | null; })[]; /** * 检查当前url是否可以访问 * @param url * @returns * true: 可以访问 * false: 无权访问 * null: 上下文不匹配 * undefined: menu中没有此url */ checkUrlAvailable(url: string): boolean | null | undefined; } export {};