@blocklet/ui-react
Version:
Some useful front-end web components that can be used in Blocklets.
71 lines (70 loc) • 2.01 kB
TypeScript
/**
* 通知对象的活动目标接口
*/
interface ActivityTarget {
type?: string;
id?: string;
}
/**
* 通知对象的活动元数据接口
*/
interface ActivityMeta {
id?: string;
}
/**
* 活动对象接口
*/
interface Activity {
type?: string;
actor?: string;
target?: ActivityTarget;
meta?: ActivityMeta;
}
/**
* 通知对象接口
*/
interface Notification {
activity?: Activity;
actorInfo?: any;
severity?: string;
title?: string;
description?: string;
items?: Notification[];
}
/**
* 合并相邻的通知数据
* 合并条件:
* 1. 数据必须是相邻的
* 2. activity.type 必须相同且不为 null 或 undefined
* 3. 如果存在target对象,activity.target.type和activity.target.id都必须相同
* 4. 如果相邻数据的 activity.type 相同但没有 activity.target 对象,则需要合并
*
* @param {Notification[]} notifications - 需要处理的通知数据
* @returns {Notification[]} - 合并后的通知数组
*/
export declare const mergeAdjacentNotifications: (notifications: Notification[]) => Notification[];
/**
* 判断通知是否包含activity
* @param {Notification} notification - 通知对象
* @returns {boolean} - 是否包含activity
*/
export declare const isIncludeActivity: (notification: Notification) => boolean;
/**
* 是否可以自动已读
*/
export declare const canAutoRead: (notification: Notification | null | undefined) => boolean;
/**
* 获取 activity 的链接
* 链接的来源有两种
* 1. activity.meta.id
* 2. activity.target.id
* @param {Activity} activity - 活动对象
* @returns {Object | null} - 活动的链接
*/
export declare const getActivityLink: (activity: Activity | null | undefined) => {
metaLink?: string | null;
targetLink?: string | null;
} | null;
export declare const toClickableSpan: (str: string, locale: string, isHighLight?: boolean) => Promise<string>;
export declare const sanitize: (innerHtml: string) => string;
export {};