Ver Fonte

feat: 替换layui版本为2.6.13,layim为3.9.9

zhangyuantao há 1 ano atrás
pai
commit
e93fd5442f

+ 0 - 1
src/main/java/com/tao/config/WebMVCConfig.java

@@ -22,7 +22,6 @@ public class WebMVCConfig implements WebMvcConfigurer {
     public void addViewControllers(ViewControllerRegistry registry) {
         registry.addViewController("/").setViewName("index");
         registry.addViewController("/addElement").setViewName("add");
-        registry.addViewController("/chatGPT").setViewName("chatgpt");
         registry.addViewController("/test").setViewName("test");
     }
 

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
src/main/resources/static/layui/css/layui.css


+ 1 - 1
src/main/resources/static/layui/css/modules/code.css

@@ -1 +1 @@
-html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-view{display:block;position:relative;margin:10px 0;padding:0;border:1px solid #eee;border-left-width:6px;background-color:#fafafa;color:#333;font-family:Courier New;font-size:13px}.layui-code-title{position:relative;padding:0 10px;height:40px;line-height:40px;border-bottom:1px solid #eee;font-size:12px}.layui-code-title>.layui-code-about{position:absolute;right:10px;top:0;color:#b7b7b7}.layui-code-about>a{padding-left:10px}.layui-code-view>.layui-code-ol,.layui-code-view>.layui-code-ul{position:relative;overflow:auto}.layui-code-view>.layui-code-ol>li{position:relative;margin-left:45px;line-height:20px;padding:0 10px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view>.layui-code-ol>li:first-child,.layui-code-view>.layui-code-ul>li:first-child{padding-top:10px}.layui-code-view>.layui-code-ol>li:last-child,.layui-code-view>.layui-code-ul>li:last-child{padding-bottom:10px}.layui-code-view>.layui-code-ul>li{position:relative;line-height:20px;padding:0 10px;list-style-type:none;*list-style-type:none;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-dark{border:1px solid #0c0c0c;border-left-color:#3f3f3f;background-color:#0c0c0c;color:#c2be9e}.layui-code-dark>.layui-code-title{border-bottom:none}.layui-code-dark>.layui-code-ol>li,.layui-code-dark>.layui-code-ul>li{background-color:#3f3f3f;border-left:none}.layui-code-dark>.layui-code-ul>li{margin-left:6px}.layui-code-demo .layui-code{visibility:visible!important;margin:-15px;border-top:none;border-right:none;border-bottom:none}.layui-code-demo .layui-tab-content{padding:15px;border-top:none}
+html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-view{display:block;position:relative;margin:10px 0;padding:0;border:1px solid #eee;border-left-width:6px;background-color:#fafafa;color:#333;font-family:Courier New;font-size:12px}.layui-code-h3{position:relative;padding:0 10px;height:40px;line-height:40px;border-bottom:1px solid #eee;font-size:12px}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 10px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view .layui-code-ol li:first-child{padding-top:10px}.layui-code-view .layui-code-ol li:last-child{padding-bottom:10px}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0c0c0c;border-left-color:#3f3f3f;background-color:#0c0c0c;color:#c2be9e}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3f3f3f;border-left:none}.layui-code-demo .layui-code{visibility:visible!important;margin:-15px;border-top:none;border-right:none;border-bottom:none}.layui-code-demo .layui-tab-content{padding:15px;border-top:none}

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
src/main/resources/static/layui/css/modules/laydate/default/laydate.css


Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
src/main/resources/static/layui/layui.js


+ 0 - 0
src/main/resources/static/layui/css/soulTable.css → src/main/resources/static/layui/modules/css/soulTable.css


Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 1
src/main/resources/static/layui/modules/layim/dist/layim-assets/layim.css


Diff do ficheiro suprimidas por serem muito extensas
+ 17 - 59
src/main/resources/static/layui/modules/layim/dist/layim.js


+ 0 - 90
src/main/resources/templates/chatgpt.html

@@ -1,90 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="UTF-8">
-    <title>chatGPT</title>
-    <link rel="stylesheet" href="./layui/css/layui.css" media="all">
-    <script type="text/javascript" src="./layui/layui.js"></script>
-</head>
-<body>
-<div style="margin: 50px 0px 0px 50px">
-    <form class="layui-form layui-form-pane" action="">
-        <div class="layui-form-item">
-            <label class="layui-form-label" style="width: 16%">prompt</label>
-            <div class="layui-input-inline" style="width: 76%">
-                <input id="prompt" type="text" name="prompt" autocomplete="off" class="layui-input">
-            </div>
-        </div>
-        <div class="layui-form-item layui-hide">
-            <label class="layui-form-label" style="width: 16%">max_tokens</label>
-            <div class="layui-input-inline" style="width: 76%">
-                <input id="max_tokens" type="text" name="max_tokens" autocomplete="off" class="layui-input">
-            </div>
-        </div>
-        <div class="layui-form-item layui-hide">
-            <label class="layui-form-label" style="width: 16%">model</label>
-            <div class="layui-input-inline" style="width: 76%">
-                <input id="model" type="text" name="model" autocomplete="off" class="layui-input">
-            </div>
-        </div>
-        <div class="layui-form-item">
-            <div class="layui-input-inline">
-                <button class="layui-btn" lay-submit lay-filter="preAddElement">立即提交</button>
-                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
-            </div>
-        </div>
-    </form>
-</div>
-</body>
-<script>
-
-    // 自定义模块,这里只需要开放soulTable即可
-    layui.config({
-        base: '/layui/modules/'   // 第三方模块所在目录
-        , layimAssetsPath: '../layui/modules/layim/dist/layim-assets/'
-        , version: 'v1.6.4' // 插件版本号
-    }).extend({
-        layim: 'layim/dist/layim'
-    });
-
-    layui.use(['form', 'layer', 'layim'], function () {
-        const form = layui.form
-            , layim = layui.layim
-            , $ = layui.$;
-
-        //提交
-        form.on('submit(preAddElement)', function (data) {
-            data.field.max_tokens = 2048
-            data.field.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.field),
-                success: function (res) {
-                    console.log(res)
-                },
-                error: function (errMsg) {
-                    console.log(errMsg);
-                }
-            })
-            return false;
-        });
-
-        layim.config({
-            brief: true //是否简约模式(如果true则不显示主面板)
-        }).chat({
-            name: '一个新窗口'
-            ,type: 'friend'
-            ,avatar: 'http://tp1.sinaimg.cn/5619439268/180/40030060651/1'
-            ,id: -2
-        });
-
-    });
-
-</script>
-</html>

+ 28 - 25
src/main/resources/templates/index.html

@@ -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 太多请求啦,麻烦稍后再试~'
+                        });
+                    }
                 }
             })
 

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff