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

63 lines
1.6 KiB
TypeScript
Raw Normal View History

2022-05-16 09:23:59 +00:00
import { IDocument, IUser, IWiki } from '@think/domains';
2022-04-03 03:06:21 +00:00
import { EventEmitter } from 'helpers/event-emitter';
export const event = new EventEmitter();
export const REFRESH_TOCS = `REFRESH_TOCS`; // 刷新知识库目录
export const CREATE_DOCUMENT = `CREATE_DOCUMENT`;
2022-05-24 11:29:30 +00:00
export const TOGGLE_COLLECT_WIKI = `TOGGLE_COLLECT_WIKI`; // 收藏或取消收藏知识库
export const TOGGLE_COLLECT_DOUCMENT = `TOGGLE_COLLECT_DOUCMENT`; // 收藏或取消收藏文档
2022-04-03 03:06:21 +00:00
/**
*
*/
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);
};
2022-05-24 11:29:30 +00:00
export const triggerToggleCollectWiki = () => {
event.emit(TOGGLE_COLLECT_WIKI);
};
export const triggerToggleCollectDocument = () => {
event.emit(TOGGLE_COLLECT_DOUCMENT);
};