2022-03-12 02:31:03 +00:00
|
|
|
import { WikiStatus, WikiUserRole, DocumentStatus, IWiki, IDocument } from './models';
|
2022-03-11 05:57:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 知识库状态列表数据
|
|
|
|
*/
|
|
|
|
export const WIKI_STATUS_LIST = [
|
|
|
|
{
|
|
|
|
value: WikiStatus.private,
|
2022-03-12 02:31:03 +00:00
|
|
|
label: '私有',
|
2022-03-11 05:57:55 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
value: WikiStatus.public,
|
2022-03-12 02:31:03 +00:00
|
|
|
label: '公开',
|
2022-03-11 05:57:55 +00:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 知识库成员角色列表数据
|
|
|
|
*/
|
|
|
|
export const WIKI_USER_ROLES = [
|
|
|
|
{
|
2022-03-12 02:31:03 +00:00
|
|
|
value: 'admin',
|
|
|
|
label: '管理员',
|
2022-03-11 05:57:55 +00:00
|
|
|
},
|
|
|
|
{
|
2022-03-12 02:31:03 +00:00
|
|
|
value: 'normal',
|
|
|
|
label: '成员',
|
2022-03-11 05:57:55 +00:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 文档状态列表数据
|
|
|
|
*/
|
|
|
|
export const DOCUMENT_STATUS = [
|
|
|
|
{
|
|
|
|
value: DocumentStatus.private,
|
2022-03-12 02:31:03 +00:00
|
|
|
label: '私有',
|
2022-03-11 05:57:55 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
value: DocumentStatus.public,
|
2022-03-12 02:31:03 +00:00
|
|
|
label: '公开',
|
2022-03-11 05:57:55 +00:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取知识库状态对应文本
|
|
|
|
* @param wiki 实例数据
|
|
|
|
* @returns
|
|
|
|
*/
|
|
|
|
export const getWikiStatusText = (wiki: IWiki): string => {
|
|
|
|
return WIKI_STATUS_LIST.find((t) => t.value === wiki.status).label;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 检查知识库是否公开
|
|
|
|
* @param currentStatus wiki 实例数据的 status 字段
|
|
|
|
* @returns
|
|
|
|
*/
|
2022-03-12 02:31:03 +00:00
|
|
|
export const isPublicWiki = (currentStatus: IWiki['status']) => currentStatus === WikiStatus.public;
|
2022-03-11 05:57:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取知识库成员角色对应文本
|
|
|
|
* @param role 实例数据的 role 字段
|
|
|
|
* @returns
|
|
|
|
*/
|
|
|
|
export const getWikiUserRoleText = (role: WikiUserRole) => {
|
|
|
|
return WIKI_USER_ROLES.find((d) => d.value === role).label;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 检查文档是否公开
|
|
|
|
* @param currentStatus document 实例数据的 status 字段
|
|
|
|
* @returns
|
|
|
|
*/
|
2022-03-22 05:37:53 +00:00
|
|
|
export const isPublicDocument = (currentStatus: IDocument['status']) => currentStatus === DocumentStatus.public;
|