"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _store = _interopRequireDefault(require("../../../store")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } var msgData = { mine: null, imgurl: null, aiRole_img: "airole.png", role_img: "role.png", getRole: function getRole(type, msg) { this.imgurl = this.getImgUrl(type); this.mine = this.getMine(type); var roleMsg = this.getTest(msg); var obj = { msg: this.getMsg(this.imgurl, roleMsg) }; return obj; }, getLoader: function getLoader() { this.mine = true; var url = config.imgUrl + this.aiRole_img; var showload = "
"; return this.getMsg(url, [{ type: "loader", val: showload }]); }, getAffairsData: function getAffairsData(res) { this.mine = true; var url = config.imgUrl + this.aiRole_img; return this.getMsg(url, [{ type: "affairs", val: res }]); }, getJsonToMdData: function getJsonToMdData(res, link) { this.mine = true; var url = config.imgUrl + this.aiRole_img; return this.getMsg(url, [{ type: "markdown", link: link, val: res }]); }, getMdData: function getMdData(type, res) { this.mine = true; var url = config.imgUrl + this.aiRole_img; return this.getMsg(url, [{ type: "markdown", val: res }]); }, getJsonToHtml: function getJsonToHtml(res) { this.mine = true; var url = config.imgUrl + this.aiRole_img; return this.getMsg(url, [{ type: "JsonHtml", val: res }]); }, getHTMLData: function getHTMLData(res) { this.mine = true; var url = config.imgUrl + this.aiRole_img; return this.getMsg(url, [{ type: "html", val: res }]); }, getRagData: function getRagData(res, more, msg) { return [{ type: "rag", acction: res.a, question: res.q, more: more, msg: msg, source: res.sourceName }]; }, getImgUrl: function getImgUrl(type) { var url = config.imgUrl; if (type == "ai") { url = url + this.aiRole_img; } else if (type == "role") { url = url + this.role_img; } return url; }, getMine: function getMine(type) { if (type == "ai") { return true; } else if (type == "role") { return false; } }, getTest: function getTest(res) { return [{ type: "text", val: res }]; }, setShowMsg: function setShowMsg(res) { var obj = { text: this.getAiToRoleMsg(res) }; this.mine = false; var imgurl = this.getImgUrl("ai"); var msg = this.getMsg(imgurl, obj); return msg; }, getAiToRoleMsg: function getAiToRoleMsg(res) { var msg = res.text; var img = res.img; var tab = res.tab; var val = ""; if (msg) { var val = "
"; for (var i in msg) { val += msg[i] + ";"; } val += "
"; } if (img) { var val_img = ""; for (var i in img) { var img_url = config.imgUrl + img[i]; if (val_img) { val_img += ","; } val_img += ""; } val += val_img; } if (tab) { var thead = tab[0]; var tbody = tab[1]; var header = ""; for (var i in thead) { header += "" + thead[i] + ""; } var bodyer = ""; for (var i in tbody) { var val_td = tbody[i]; var valtd = ""; for (var j in val_td) { valtd += "" + val_td[j] + ""; } valtd += ""; bodyer += valtd; } bodyer += ""; header += ""; var val_tab = "
" + header + bodyer + "
"; val += val_tab; } return val; }, setmsgtab: function setmsgtab(tab) { var url = config.imgUrl + this.aiRole_img; var thead = tab[0]; var tbody = tab[1]; var header = ""; for (var i in thead) { header += "" + thead[i] + ""; } var bodyer = ""; for (var i in tbody) { var val_td = tbody[i]; var valtd = ""; for (var j in val_td) { valtd += "" + val_td[j] + ""; } valtd += ""; bodyer += valtd; } bodyer += ""; header += ""; var val_tab = "" + header + bodyer + "
"; var obj = { date: this.getDate(), text: { text: val_tab }, mine: false, name: "", img: url }; return obj; }, setmsgImg: function setmsgImg(img) { var val_img = ""; for (var i in img) { var img_url = config.imgUrl + img[i]; // if (val_img) { // val_img += "," // } val_img += ""; } var url = config.imgUrl + this.aiRole_img; var obj = { date: this.getDate(), text: { text: val_img }, mine: false, name: "", img: url }; return obj; }, setmsgText: function setmsgText(res) { var std = ""; for (var i in res) { if (std) { std += ";"; } std += res[i]; } var flag = 0; var length = std.length; var str = ""; window.timer = setInterval(function () { str += std[flag]; _store["default"].state.setMsgData = { text: str }; flag++; if (flag > length) { clearInterval(timer); _store["default"].state.setMsgData = { text: "加载完成" }; } }, 150); }, getMsg: function getMsg(imgurl, msg) { return { date: this.getDate(), list: msg, mine: false, name: this.mine ? "[信息中心]" : "[您]", img: imgurl }; }, getDate: function getDate() { var now = new Date(); var year = now.getFullYear(); //获取完整的年份(4位,1970-????) var month = now.getMonth() + 1 < 10 ? "0" + (now.getMonth() + 1) : now.getMonth() + 1; //获取当前月份(0-11,0代表1月) var day = now.getDate() < 10 ? "0" + now.getDate() : now.getDate(); //获取当前日(1-31) var hour = now.getHours() < 10 ? "0" + now.getHours() : now.getHours(); //获取当前小时数(0-23) var minute = now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes(); //获取当前分钟数(0-59) var second = now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds(); //获取当前秒数(0-59) return year + "/" + month + "/" + day + " " + hour + ":" + minute + ":" + second; }, getDate1: function getDate1() { var now = new Date(); var year = now.getFullYear(); //获取完整的年份(4位,1970-????) var month = now.getMonth() + 1 < 10 ? "0" + (now.getMonth() + 1) : now.getMonth() + 1; //获取当前月份(0-11,0代表1月) var day = now.getDate() < 10 ? "0" + now.getDate() : now.getDate(); //获取当前日(1-31) var hour = now.getHours() < 10 ? "0" + now.getHours() : now.getHours(); //获取当前小时数(0-23) var minute = now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes(); //获取当前分钟数(0-59) var second = now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds(); //获取当前秒数(0-59) return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second; } }; var _default = msgData; exports["default"] = _default;