think/packages/client/src/event/index.ts

52 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-04-03 03:06:21 +00:00
import { IUser, IDocument, IWiki } from '@think/domains';
import { EventEmitter } from 'helpers/event-emitter';
export const event = new EventEmitter();
export const REFRESH_TOCS = `REFRESH_TOCS`; // 刷新知识库目录
export const CREATE_DOCUMENT = `CREATE_DOCUMENT`;
/**
*
*/
export const triggerRefreshTocs = () => {
event.emit(REFRESH_TOCS);
};
/**
*
* @param data
*/
export const triggerCreateDocument = (data: { wikiId: IWiki['id']; documentId: IDocument['id'] | null }) => {
event.emit(CREATE_DOCUMENT, data);
};
export const CHANGE_DOCUMENT_TITLE = `CHANGE_DOCUMENT_TITLE`;
/**
*
* @param title
*/
export const triggerChangeDocumentTitle = (title: string) => {
event.emit(CHANGE_DOCUMENT_TITLE, title);
};
export const USE_DOCUMENT_VERSION = `USE_DOCUMENT_VERSION`;
/**
* 使
* @param data
*/
export const triggerUseDocumentVersion = (data: Record<string, unknown>) => {
event.emit(USE_DOCUMENT_VERSION, data);
};
export const JOIN_USER = `JOIN_USER`;
type CollaborationUser = {
clientId: number;
user: IUser;
};
/**
*
* @param users
*/
export const triggerJoinUser = (users: Array<CollaborationUser>) => {
event.emit(JOIN_USER, users);
};