|
@@ -5,7 +5,7 @@
|
|
|
<meta name="viewport" content="width=device-width">
|
|
|
<title>ElementSync - AppUIAuto</title>
|
|
|
<link rel="stylesheet" href="./layui/css/layui.css" media="all">
|
|
|
- <link rel="stylesheet" href="./layui/css/soulTable.css" media="all"/>
|
|
|
+ <link rel="stylesheet" href="./layui/modules/css/soulTable.css" media="all"/>
|
|
|
<script type="text/javascript" src="./layui/layui.js"></script>
|
|
|
<script type="text/javascript" src="./layui/clipboard.js"></script>
|
|
|
</head>
|
|
@@ -147,7 +147,6 @@
|
|
|
<script type="text/html" id="toolbar">
|
|
|
<a class="layui-btn layui-btn-sm" lay-event="clearFilter">清除所有筛选条件</a>
|
|
|
<a class="layui-btn layui-btn-sm" lay-event="addElement">添加</a>
|
|
|
- <a class="layui-btn layui-btn-sm" lay-event="chatGPT">添加</a>
|
|
|
</script>
|
|
|
<script type="text/html" id="elementTypeTpl">
|
|
|
{{# if(d.elementType === 0){ }}
|
|
@@ -174,8 +173,7 @@
|
|
|
// 自定义模块,这里只需要开放soulTable即可
|
|
|
layui.config({
|
|
|
base: '/layui/modules/' // 第三方模块所在目录
|
|
|
- , layimAssetsPath: '/layui/modules/layim/dist/layim-assets/'
|
|
|
- , version: 'v1.6.4' // 插件版本号
|
|
|
+ , layimResPath: '/layui/modules/layim/dist/layim-assets/'
|
|
|
}).extend({
|
|
|
soulTable: 'soulTable/soulTable',
|
|
|
tableChild: 'soulTable/tableChild',
|
|
@@ -382,7 +380,7 @@
|
|
|
|
|
|
layim.config({
|
|
|
brief: true //是否简约模式(如果true则不显示主面板)
|
|
|
- , minRight: '350px'
|
|
|
+ , minRight: '370px'
|
|
|
}).chat({
|
|
|
name: 'ChatGPT'
|
|
|
, type: 'friend'
|
|
@@ -391,19 +389,17 @@
|
|
|
});
|
|
|
|
|
|
layim.on('sendMessage', function (res) {
|
|
|
- console.log(res)
|
|
|
+ let To = res.to;
|
|
|
+ if(To.type === 'friend'){
|
|
|
+ layim.setChatStatus('<span style="color:#ffa502;">(๑・`◡´・๑) 正在努力输入…</span>');
|
|
|
+ }
|
|
|
+
|
|
|
+ let Mine = res.mine;
|
|
|
let localChatGPT = layui.sessionData('chatgpt');
|
|
|
layui.sessionData('chatgpt', {
|
|
|
key: 'myprompt'
|
|
|
- , value: localChatGPT.myprompt + " Q1:" + res.mine.content
|
|
|
+ , value: localChatGPT.myprompt + " Q1:" + Mine.content
|
|
|
});
|
|
|
- let data = {
|
|
|
- "prompt": layui.sessionData('chatgpt').myprompt,
|
|
|
- "max_tokens": 2048,
|
|
|
- "model": "text-davinci-003"
|
|
|
- };
|
|
|
-
|
|
|
- let To = res.to
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'post',
|
|
@@ -413,30 +409,37 @@
|
|
|
"Authorization": "Bearer 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"
|
|
|
},
|
|
|
dataType: 'json',
|
|
|
- data: JSON.stringify(data),
|
|
|
+ data: JSON.stringify({
|
|
|
+ "prompt": layui.sessionData('chatgpt').myprompt,
|
|
|
+ "max_tokens": 2048,
|
|
|
+ "model": "text-davinci-003"
|
|
|
+ }),
|
|
|
success: function (res) {
|
|
|
- console.log(res.choices[0].text);
|
|
|
layui.sessionData('chatgpt', {
|
|
|
key: 'myprompt'
|
|
|
, value: layui.sessionData('chatgpt').myprompt + " A1:" + res.choices[0].text
|
|
|
});
|
|
|
+ layim.setChatStatus('<span style="color:#2ed573;">o( ̄▽ ̄)d 在线</span>');
|
|
|
layim.getMessage({
|
|
|
username: To.name //消息来源用户名
|
|
|
, avatar: To.avatar //消息来源用户头像
|
|
|
, id: To.id //消息的来源ID(如果是私聊,则是用户id,如果是群聊,则是群组id)
|
|
|
, type: To.type //聊天窗口来源类型,从发送消息传递的to里面获取
|
|
|
- , content: "我<br>是<br>谁" //消息内容
|
|
|
- , mine: false //是否我发送的消息,如果为true,则会显示在右方
|
|
|
+ , content: res.choices[0].text.trim().replace(/A1:/g, '').replace(/A1:/g, '') //消息内容
|
|
|
+ , mine: true //是否我发送的消息,如果为true,则会显示在右方
|
|
|
});
|
|
|
},
|
|
|
error: function (errMsg) {
|
|
|
- //如果是来自于系统的聊天面板的消息
|
|
|
- layim.getMessage({
|
|
|
- system: true //系统消息
|
|
|
- , id: -2 //聊天窗口ID
|
|
|
- , type: "friend" //聊天窗口类型
|
|
|
- , content: '对方已掉线'
|
|
|
- });
|
|
|
+ if (errMsg.status === 503 || errMsg.status === 429) {
|
|
|
+ layim.setChatStatus('<span style="color:#ff4757;">X﹏X 失联中</span>');
|
|
|
+ //如果是来自于系统的聊天面板的消息
|
|
|
+ layim.getMessage({
|
|
|
+ system: true //系统消息
|
|
|
+ , id: -2 //聊天窗口ID
|
|
|
+ , type: "friend" //聊天窗口类型
|
|
|
+ , content: 'w(゚Д゚)w 太多请求啦,麻烦稍后再试~'
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
|