think/packages/domains/lib/util.js

76 lines
2.0 KiB
JavaScript
Raw Normal View History

2022-03-11 05:57:55 +00:00
"use strict";
2022-05-18 08:02:29 +00:00
exports.__esModule = true;
2022-03-11 05:57:55 +00:00
exports.isPublicDocument = exports.getWikiUserRoleText = exports.isPublicWiki = exports.getWikiStatusText = exports.DOCUMENT_STATUS = exports.WIKI_USER_ROLES = exports.WIKI_STATUS_LIST = void 0;
2022-05-18 08:02:29 +00:00
var models_1 = require("./models");
/**
* 知识库状态列表数据
*/
2022-03-11 05:57:55 +00:00
exports.WIKI_STATUS_LIST = [
{
value: models_1.WikiStatus.private,
2022-05-18 08:02:29 +00:00
label: '私有'
2022-03-11 05:57:55 +00:00
},
{
value: models_1.WikiStatus.public,
2022-05-18 08:02:29 +00:00
label: '公开'
2022-03-11 05:57:55 +00:00
},
];
2022-05-18 08:02:29 +00:00
/**
* 知识库成员角色列表数据
*/
2022-03-11 05:57:55 +00:00
exports.WIKI_USER_ROLES = [
{
2022-04-02 09:57:30 +00:00
value: 'admin',
2022-05-18 08:02:29 +00:00
label: '管理员'
2022-03-11 05:57:55 +00:00
},
{
2022-04-02 09:57:30 +00:00
value: 'normal',
2022-05-18 08:02:29 +00:00
label: '成员'
2022-03-11 05:57:55 +00:00
},
];
2022-05-18 08:02:29 +00:00
/**
* 文档状态列表数据
*/
2022-03-11 05:57:55 +00:00
exports.DOCUMENT_STATUS = [
{
value: models_1.DocumentStatus.private,
2022-05-18 08:02:29 +00:00
label: '私有'
2022-03-11 05:57:55 +00:00
},
{
value: models_1.DocumentStatus.public,
2022-05-18 08:02:29 +00:00
label: '公开'
2022-03-11 05:57:55 +00:00
},
];
2022-05-18 08:02:29 +00:00
/**
* 获取知识库状态对应文本
* @param wiki 实例数据
* @returns
*/
var getWikiStatusText = function (wiki) {
return exports.WIKI_STATUS_LIST.find(function (t) { return t.value === wiki.status; }).label;
2022-03-11 05:57:55 +00:00
};
exports.getWikiStatusText = getWikiStatusText;
2022-05-18 08:02:29 +00:00
/**
* 检查知识库是否公开
* @param currentStatus wiki 实例数据的 status 字段
* @returns
*/
var isPublicWiki = function (currentStatus) { return currentStatus === models_1.WikiStatus.public; };
2022-03-11 05:57:55 +00:00
exports.isPublicWiki = isPublicWiki;
2022-05-18 08:02:29 +00:00
/**
* 获取知识库成员角色对应文本
* @param role 实例数据的 role 字段
* @returns
*/
var getWikiUserRoleText = function (role) {
return exports.WIKI_USER_ROLES.find(function (d) { return d.value === role; }).label;
2022-03-11 05:57:55 +00:00
};
exports.getWikiUserRoleText = getWikiUserRoleText;
2022-05-18 08:02:29 +00:00
/**
* 检查文档是否公开
* @param currentStatus document 实例数据的 status 字段
* @returns
*/
var isPublicDocument = function (currentStatus) { return currentStatus === models_1.DocumentStatus.public; };
2022-03-11 05:57:55 +00:00
exports.isPublicDocument = isPublicDocument;