"use strict";
const common_vendor = require("../common/vendor.js");
const config_config = require("../config/config.js");
const framework_http = require("./http.js");
const framework_log = require("./log.js");
const _tools = class {
static initPlatform() {
_tools.platform = config_config.config.Platform.TOUTIAO;
framework_log.log.Debug("当前运行平台:", _tools.platform);
}
static getCurPlatform() {
return _tools.platform;
}
static setNavigationBar() {
if (_tools.getCurPlatform() == config_config.config.Platform.TOUTIAO) {
common_vendor.index.setNavigationBarTitle({
title: "卿卿小屋"
});
}
}
static getChapterList(chapter_path, cb) {
framework_http.http.StaticRequest(chapter_path, (err, data) => {
if (err) {
return;
}
cb(data);
});
}
static getCurChapterTxt(base_path, chapter_id, emspWidth, cb) {
let url = `${base_path}${chapter_id}.txt`;
framework_http.http.getStaticText(url, (err, data) => {
if (err) {
framework_log.log.Error(err);
return;
}
cb(_tools.autoParagraph(data, emspWidth));
});
}
static getChapterReadChapterIdByData(chapter_data) {
if (chapter_data.cur_read_chapter_id == void 0 || chapter_data.cur_read_chapter_id == 0 || chapter_data.cur_read_chapter_id == null) {
return 1;
}
}
static autoParagraph(text, emspWidth) {
const emspStyle = `style="margin-left: ${emspWidth}px;"`;
const emsp_html = ``;
const character = `
${emsp_html}`;
return character + text.replace(/\n\s*/g, character);
}
};
let tools = _tools;
tools.platform = config_config.config.Platform.H5;
exports.tools = tools;