suerprisePlus
2024-12-17 5dfcbd19cd041e1f8a5fb7ed9ab694bf4de00352
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
"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 = " <div class='parentBox'>  <div class='loadBox'> <div class='loaderContantBox'></div> </div>  </div>";
    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 = "<div class='msgText'>";
 
      for (var i in msg) {
        val += msg[i] + ";";
      }
 
      val += "</div>";
    }
 
    if (img) {
      var val_img = "";
 
      for (var i in img) {
        var img_url = config.imgUrl + img[i];
 
        if (val_img) {
          val_img += ",";
        }
 
        val_img += "<img data-src= " + img_url + "></img>";
      }
 
      val += val_img;
    }
 
    if (tab) {
      var thead = tab[0];
      var tbody = tab[1];
      var header = "<thead class ='tabHeader'><tr>";
 
      for (var i in thead) {
        header += "<th>" + thead[i] + "</th>";
      }
 
      var bodyer = "<tbody class ='tabBody'>";
 
      for (var i in tbody) {
        var val_td = tbody[i];
        var valtd = "<tr>";
 
        for (var j in val_td) {
          valtd += "<td>" + val_td[j] + "</td>";
        }
 
        valtd += "</tr>";
        bodyer += valtd;
      }
 
      bodyer += "</tbody>";
      header += "</tr></thead>";
      var val_tab = "<div><table class='tabTable'>" + header + bodyer + "</table></div>";
      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 = "<thead class ='tabHeader'><tr>";
 
    for (var i in thead) {
      header += "<th>" + thead[i] + "</th>";
    }
 
    var bodyer = "<tbody class ='tabBody'>";
 
    for (var i in tbody) {
      var val_td = tbody[i];
      var valtd = "<tr>";
 
      for (var j in val_td) {
        valtd += "<td>" + val_td[j] + "</td>";
      }
 
      valtd += "</tr>";
      bodyer += valtd;
    }
 
    bodyer += "</tbody>";
    header += "</tr></thead>";
    var val_tab = "<table class='tabTable'>" + header + bodyer + "</table>";
    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 += "<img data-src= " + img_url + "></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;