UNPKG

@ginstone/nga-api

Version:

48 lines (47 loc) 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CustomLevel = exports.SubForum = exports.Forum = void 0; const StrUtils_1 = require("../../utils/StrUtils"); const axios_1 = require("axios"); const ForumType_1 = require("../../enums/ForumType"); class Forum { constructor(raw) { this.forumName = raw.name; this.forumId = raw.fid; this.colTitle = raw.set_topic_subject; this.colTid = raw.set_topic_tid; this.toppedTopicId = raw.topped_topic; this.icon = (0, StrUtils_1.getIcon)(false, this.forumId); this.iconBig = (0, StrUtils_1.getBigIcon)(this.forumId); if (raw.custom_level) { let s = raw.custom_level .replace(/{r:/g, "{\"rank\":") .replace(/,n:/g, ",\"name\":"); this.customLevels = JSON.parse(s); } axios_1.default.post; if (raw.sub_forums) { this.subForums = Object.keys(raw.sub_forums).map(key => new SubForum(key, raw.sub_forums[key])); } } } exports.Forum = Forum; class SubForum { constructor(key, raw) { this.type = key.startsWith("t") ? ForumType_1.ForumType.COLLECTION : ForumType_1.ForumType.FORUM; this.id = raw[0]; this.name = raw[1]; this.mirrorId = raw[3]; } } exports.SubForum = SubForum; /** * 版面自定义的声望等级 */ class CustomLevel { constructor(rank, name) { this.rank = rank; this.name = name; } } exports.CustomLevel = CustomLevel;