|
@@ -173,18 +173,20 @@
|
|
<script>
|
|
<script>
|
|
// 自定义模块,这里只需要开放soulTable即可
|
|
// 自定义模块,这里只需要开放soulTable即可
|
|
layui.config({
|
|
layui.config({
|
|
- base: '/layui/modules/', // 第三方模块所在目录
|
|
|
|
- version: 'v1.6.4' // 插件版本号
|
|
|
|
|
|
+ base: '/layui/modules/' // 第三方模块所在目录
|
|
|
|
+ , layimAssetsPath: '/layui/modules/layim/dist/layim-assets/'
|
|
|
|
+ , version: 'v1.6.4' // 插件版本号
|
|
}).extend({
|
|
}).extend({
|
|
soulTable: 'soulTable/soulTable',
|
|
soulTable: 'soulTable/soulTable',
|
|
tableChild: 'soulTable/tableChild',
|
|
tableChild: 'soulTable/tableChild',
|
|
tableMerge: 'soulTable/tableMerge',
|
|
tableMerge: 'soulTable/tableMerge',
|
|
tableFilter: 'soulTable/tableFilter',
|
|
tableFilter: 'soulTable/tableFilter',
|
|
excel: 'soulTable/excel',
|
|
excel: 'soulTable/excel',
|
|
|
|
+ layim: 'layim/dist/layim'
|
|
});
|
|
});
|
|
|
|
|
|
//JS
|
|
//JS
|
|
- layui.use(['element', 'layer', 'util', 'upload', 'form', 'table', 'soulTable', 'laytpl'], function () {
|
|
|
|
|
|
+ layui.use(['element', 'layer', 'util', 'upload', 'form', 'table', 'soulTable', 'laytpl', 'layim'], function () {
|
|
const element = layui.element
|
|
const element = layui.element
|
|
, layer = layui.layer
|
|
, layer = layui.layer
|
|
, util = layui.util
|
|
, util = layui.util
|
|
@@ -193,6 +195,7 @@
|
|
, table = layui.table
|
|
, table = layui.table
|
|
, soulTable = layui.soulTable
|
|
, soulTable = layui.soulTable
|
|
, laytpl = layui.laytpl
|
|
, laytpl = layui.laytpl
|
|
|
|
+ , layim = layui.layim
|
|
, $ = layui.$;
|
|
, $ = layui.$;
|
|
|
|
|
|
let clipboard;
|
|
let clipboard;
|
|
@@ -224,6 +227,7 @@
|
|
}
|
|
}
|
|
|
|
|
|
$(function () {
|
|
$(function () {
|
|
|
|
+ layim.setChatMin();
|
|
flashPages();
|
|
flashPages();
|
|
clipboard = new ClipboardJS('.js-clipboard');
|
|
clipboard = new ClipboardJS('.js-clipboard');
|
|
clipboard.on('success', function (e) {
|
|
clipboard.on('success', function (e) {
|
|
@@ -370,6 +374,58 @@
|
|
});
|
|
});
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ layim.config({
|
|
|
|
+ brief: true //是否简约模式(如果true则不显示主面板)
|
|
|
|
+ ,minRight: '350px'
|
|
|
|
+ }).chat({
|
|
|
|
+ name: 'ChatGPT'
|
|
|
|
+ ,type: 'friend'
|
|
|
|
+ ,avatar: 'static/chatgpt.png'
|
|
|
|
+ ,id: -2
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ layim.on('sendMessage', function(res){
|
|
|
|
+ console.log(res)
|
|
|
|
+ let data = {
|
|
|
|
+ "prompt": res.mine.content,
|
|
|
|
+ "max_tokens": 2048,
|
|
|
|
+ "model": "text-davinci-003"
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ $.ajax({
|
|
|
|
+ type: 'post',
|
|
|
|
+ url: 'https://api.openai.com/v1/completions',
|
|
|
|
+ headers: {
|
|
|
|
+ "Content-Type": "application/json",
|
|
|
|
+ "Authorization": "Bearer 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"
|
|
|
|
+ },
|
|
|
|
+ dataType: 'json',
|
|
|
|
+ data: JSON.stringify(data),
|
|
|
|
+ success: function (res) {
|
|
|
|
+ layim.getMessage({
|
|
|
|
+ username: "ChatGPT" //消息来源用户名
|
|
|
|
+ ,avatar: "http://tp1.sinaimg.cn/1571889140/180/40030060651/1" //消息来源用户头像
|
|
|
|
+ ,id: "-2" //消息的来源ID(如果是私聊,则是用户id,如果是群聊,则是群组id)
|
|
|
|
+ ,type: "friend" //聊天窗口来源类型,从发送消息传递的to里面获取
|
|
|
|
+ ,content: "嗨,你好!本消息系离线消息。" //消息内容
|
|
|
|
+ // ,mine: false //是否我发送的消息,如果为true,则会显示在右方
|
|
|
|
+ });
|
|
|
|
+ /*//如果是来自于系统的聊天面板的消息
|
|
|
|
+ layim.getMessage({
|
|
|
|
+ system: true //系统消息
|
|
|
|
+ ,id: -2 //聊天窗口ID
|
|
|
|
+ ,type: "friend" //聊天窗口类型
|
|
|
|
+ ,content: '对方已掉线'
|
|
|
|
+ });*/
|
|
|
|
+ },
|
|
|
|
+ error: function (errMsg) {
|
|
|
|
+ console.log(errMsg);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+
|
|
});
|
|
});
|
|
</script>
|
|
</script>
|
|
</body>
|
|
</body>
|