Thinkphp6---workman开发聊天

news/2025/2/27 12:13:35/文章来源:https://www.cnblogs.com/e0yu/p/18740184

最近DeepSeek很火,就结合workman开发一个聊天对话功能:

一、安装 think-worker和 think-view

composer require topthink/think-worker
composer require topthink/think-view

版本更新比较快,通过这个安装的 think-worker 是4.0的,但是需要 thinkphp是8.0的

可以安装3.0的:

composer require topthink/think-worker 3.0

安装后会增加两个配置文件:

修改端口:

// 扩展自身需要的配置
'protocol'       => 'websocket', // 协议 支持 tcp udp unix http websocket text
'host'           => '127.0.0.1', // 监听地址
'port'           => 8000, // 监听端口
'socket'         => 'http://127.0.0.1:8000', // 完整监听地址
'context'        => [], // socket 上下文选项
'worker_class'   => 'app\http\Worker', // 自定义Workerman服务类名 支持数组定义多个服务

二、新建工程目录

控制器:

<?php
namespace app\http\controller;
use think\App;
use think\facade\View;
/*** Step controller*/

class ChatController {/*** list*/public function index(){return View::fetch();} }

视图:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title></title>
<link rel="stylesheet" type="text/css" href="/static/httpchat/font_Icon/iconfont.css"><script src="/static/admin/jquery/jquery-3.6.0.min.js"></script>
<style>.userlist li{background: rgb(0 0 0 / 5%);text-align: left;padding: 5px;height: 49px;/*line-height: 30px;*/font-size: 16px;border-bottom: 1px solid rgb(0 0 0 / 5%);}.userlist li img {width: 40px;height: 40px;padding-right: 5px;}.message-num{right: 2px;}.ChatInfoName{height: 50px;border-bottom: 1px solid #D9D9D9;line-height: 50px;font-size: 16px;padding: 0 10px;}.chatBox-content{height: 498px !important;width: 100%;}.chatBox-content-demo{width: 100%;height: 370px !important;overflow-y: scroll;}.div-textarea{width: 490px !important;/*min-height: 20px;*/height: 100px;_height: 120px;padding: 3px;outline: 0;background: #fff;font-size: 14px;line-height: 20px;word-wrap: break-word;overflow-x: hidden;overflow-y: auto;user-modify: read-write-plaintext-only;    /*纯文本*/-webkit-user-modify: read-write-plaintext-only;-moz-user-modify: read-write-plaintext-only;}.div-textarea:focus{box-shadow: 0 0 15px rgba(82, 168, 236, 0.6);}.clearfloat:after{display:block;clear:both;content:"";visibility:hidden;height:0}.clearfloat{zoom:1;margin: 10px 10px;}.clearfloat .right{float: right;}.author-name{text-align: center;margin: 15px 0 5px 0;color: #888;}.clearfloat .chat-message{max-width: 252px;text-align: left;padding: 8px 12px;border-radius: 6px;word-wrap:break-word;display: inline-block;position: relative;}.clearfloat .left .chat-message{background: #D9D9D9;min-height: 36px;}.clearfloat .left .chat-message:before{position: absolute;content: "";top: 8px;left: -6px;border-top: 10px solid transparent;border-bottom: 10px solid transparent;border-right: 10px solid #D9D9D9;}.clearfloat .right{text-align: right;}.clearfloat .right .chat-message{background: #8c85e6;color: #fff;text-align: left;min-height: 36px;}.clearfloat .right .chat-message:before{position: absolute;content: "";top: 8px;right: -6px;border-top: 10px solid transparent;border-bottom: 10px solid transparent;border-left: 10px solid #8c85e6;}.clearfloat .chat-avatars{display: inline-block;width: 30px;height: 30px;border-radius: 50%;background: #eee;vertical-align: top;overflow: hidden;}.clearfloat .chat-avatars>img{width: 30px;height: 30px;}.clearfloat .left .chat-avatars{margin-right: 10px;}.clearfloat .right .chat-avatars{margin-left: 10px;}.chatBox-send{width: 100%;padding: 10px 5px;background: #eee;border-top: 1px #D0D0D0 solid;position: absolute;bottom: 0;left: 0;}.chatBox-send>div{float: left;}.chatBox-send>div:nth-of-type(2){font-size: 0;}.chatBox-send>div button{padding: 1px 5px;margin-left: 3px;}.chatBox-send>div label{padding: 1px 5px;margin-left: 3px;}#chat-biaoqing{position: relative;}.hidden{display: none;}.biaoqing-photo{width: 200px;height: 160px;background: #ffffff;position: absolute;top: -160px;right: 40px;text-align: left;border-radius: 5px;border: solid 1px #c5c5c5;display: none;}.biaoqing-photo::before{content: '';position: absolute;border-top: solid 7px #c5c5c5;border-left: solid 9px transparent;border-right: solid 9px transparent;bottom: -7px;right: 36px;}.biaoqing-photo::after{content: '';position: absolute;border-top: solid 7px #fff;border-left: solid 10px transparent;border-right: solid 10px transparent;bottom: -5px;right: 35px;}.biaoqing-photo>ul{margin: 0;width: 200px;height: 160px;padding: 3px 2px;list-style: none;}.biaoqing-photo>ul>li{float: left;height: 30px;margin-left: 2px;}.emoji-picker-image{display: inline-block;width: 30px;height: 30px;background: url(/static/httpchat/img/bqxtb01.png) no-repeat;background-size: 200px auto;cursor: pointer;}.biaoqing-photo>ul>li span.emoji-picker-image:hover{border: solid 1px #f5f5f5;}.chat-message img{width: 220px;height:auto;}.chat-name{width: 230px;}/*按钮样式*/.btn-default-styles {outline: none;resize: none;border: none;display: inline-block;padding: 5px 10px;margin-bottom: 0;font-size: 14px;font-weight: 400;line-height: 1.42857143;text-align: center;white-space: nowrap;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;background-image: none;background: #bbb;color: #fff;border-radius: 4px;}.btn-default-styles:focus {outline: none;}.btn-default-styles:hover {background: #c5c5c5;animation: anniu 1s infinite;}.btn-default-styles:active {box-shadow: 0 2px 3px rgba(0, 0, 0, .2) inset;}/* 设置滚动条的样式 */::-webkit-scrollbar {width:5px;}/* 滚动槽 */::-webkit-scrollbar-track {border-radius:10px;}/* 滚动条滑块 */::-webkit-scrollbar-thumb {border-radius:10px;background:#8C85E6;-webkit-box-shadow:#8C85E6;}::-webkit-scrollbar-thumb:window-inactive {background: rgba(175, 190, 255, 0.4);}@media all and (max-width: 768px) {.chatBox{position: fixed;top: 0;left: 0;width: 100%;height: 100%;}}@media all and (max-width: 370px){.chat-name{width: 185px;}.chat-people>div:nth-of-type(2){width: 120px;}.clearfloat .chat-message{max-width: 240px;}}
</style>
</head>
<body>
<div class="layui-fluid" style="padding: 0">
<div class="layui-row" style="overflow: hidden;"><div class="layui-col-md3 layui-col-lg3 layui-col-xs3 div-user" style="border-right: 1px solid #b4b2b2;height: 549px;overflow-y: scroll;"><ul class="userlist" id="chatuser"><li lay-id="1"><img src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg" alt=""><span class="chat-name">管理员</span><span class="message-num">20</span></li></ul></div><div class="layui-col-md9 layui-col-lg9 layui-col-xs9 "><div id="chatcontent"><div class="ChatInfoName">这里是用户昵称</div><div><div class="chatBox-content"><div class="chatBox-content-demo" id="chatBox-content-demo"></div></div><div class="chatBox-send"><div class="div-textarea" contenteditable="true"></div><div><button id="chat-biaoqing" class="btn-default-styles"><i class="iconfont icon-biaoqing"></i></button><label id="chat-tuxiang" title="发送图片" for="inputImage" class="btn-default-styles"><input type="file" onchange="selectImg(this)" accept="image/jpg,image/jpeg,image/png"name="file" id="inputImage" class="hidden"><i class="iconfont icon-tuxiang"></i></label><button id="chat-fasong" class="btn-default-styles"><i class="iconfont icon-fasong"></i></button></div><div class="biaoqing-photo"><ul><li><span class="emoji-picker-image" style="background-position: -9px -18px;"></span></li><li><span class="emoji-picker-image" style="background-position: -40px -18px;"></span></li><li><span class="emoji-picker-image" style="background-position: -71px -18px;"></span></li><li><span class="emoji-picker-image" style="background-position: -102px -18px;"></span></li><li><span class="emoji-picker-image" style="background-position: -133px -18px;"></span></li><li><span class="emoji-picker-image" style="background-position: -164px -18px;"></span></li><li><span class="emoji-picker-image" style="background-position: -9px -52px;"></span></li><li><span class="emoji-picker-image" style="background-position: -40px -52px;"></span></li><li><span class="emoji-picker-image" style="background-position: -71px -52px;"></span></li><li><span class="emoji-picker-image" style="background-position: -102px -52px;"></span></li><li><span class="emoji-picker-image" style="background-position: -133px -52px;"></span></li><li><span class="emoji-picker-image" style="background-position: -164px -52px;"></span></li><li><span class="emoji-picker-image" style="background-position: -9px -86px;"></span></li><li><span class="emoji-picker-image" style="background-position: -40px -86px;"></span></li><li><span class="emoji-picker-image" style="background-position: -71px -86px;"></span></li><li><span class="emoji-picker-image" style="background-position: -102px -86px;"></span></li><li><span class="emoji-picker-image" style="background-position: -133px -86px;"></span></li><li><span class="emoji-picker-image" style="background-position: -164px -86px;"></span></li><li><span class="emoji-picker-image" style="background-position: -9px -120px;"></span></li><li><span class="emoji-picker-image" style="background-position: -40px -120px;"></span></li><li><span class="emoji-picker-image" style="background-position: -71px -120px;"></span></li><li><span class="emoji-picker-image" style="background-position: -102px -120px;"></span></li><li><span class="emoji-picker-image" style="background-position: -133px -120px;"></span></li><li><span class="emoji-picker-image" style="background-position: -164px -120px;"></span></li><li><span class="emoji-picker-image" style="background-position: -9px -154px;"></span></li><li><span class="emoji-picker-image" style="background-position: -40px -154px;"></span></li><li><span class="emoji-picker-image" style="background-position: -71px -154px;"></span></li><li><span class="emoji-picker-image" style="background-position: -102px -154px;"></span></li><li><span class="emoji-picker-image" style="background-position: -133px -154px;"></span></li><li><span class="emoji-picker-image" style="background-position: -164px -154px;"></span></li></ul></div></div></div></div></div>
</div>
</div><!--<div class="layui-fluid">-->
<!--    ……-->
<!--</div>--></body>
</html>
<script>var myavatars = '';
var myDate =new Date();
var year=myDate.getFullYear(); //获取当前年份
var mon=myDate.getMonth()+1; //获取当前月份
var da=myDate.getDate(); //获取当前日
var day=myDate.getDay(); //获取当前星期几
var h=myDate.getHours(); //获取小时
var m=myDate.getMinutes(); //获取分钟
var s=myDate.getSeconds(); //获取秒
var ms=myDate.getMilliseconds();    //获取当前毫秒数(0-999)
var ld=myDate.toLocaleDateString();    //获取当前日期
var msgdate=year+'-'+mon+'-'+da+' '+h+':'+m+':'+s;var from_id = "{$from_id}";
var to_id = "{$to_id}";//进聊天页面
$("#chatuser li").each(function () {$(this).click(function () {$("#chatuser li").css('background','rgb(0 0 0 / 5%)')$(this).css('background','#ffffff')var n = $(this).index();to_id = $(this).attr('lay-id')// $(".chatBox-head-one").toggle();// $(".chatBox-head-two").toggle();// $(".chatBox-list").fadeToggle();// $(".chatBox-kuang").fadeToggle();//传名字
        $(".ChatInfoName").text($(this).children(".chat-name").eq(0).html());//赋值头像
        myavatars = $(this).children('img').eq(0).attr("src");// //传头像//聊天框默认最底部
        $(document).ready(function () {$("#chatBox-content-demo").scrollTop($("#chatBox-content-demo")[0].scrollHeight);});// // 打开websocket// webSocket.onopen = function (event) {
        onOpen();// };
    })
});
// var userlist = [10009,10010,10011,10012,10013,10014,10015,10016,10017];
/**0:未连接1:连接成功,可通讯2:正在关闭3:连接已关闭或无法打开*///创建一个webSocket 实例
var webSocket = new WebSocket("ws://192.168.0.113:2345");
webSocket.onerror = function (event) {onError(event);
};
// 打开websocket
webSocket.onopen = function (event) {onOpen(event);
};
//监听消息
webSocket.onmessage = function (event) {onMessage(event);
};
webSocket.onclose = function (event) {onClose(event);
}
//关闭监听websocket
function onError(event) {// document.getElementById("msg").innerHTML = "<p>关闭</p>";
    console.log("错误: " + event.data);
}
function onOpen(event) {// console.log("打开: "+sockState());var bild = '{"type":"bind","uid":"' + from_id + '"}';webSocket.send(bild);setInterval(function () {webSocket.send('heartbeat');    //发送内容不限,只是为了证明客户端还没关闭还在线
    }, 20000)                    //50秒发一次
}
function onMessage(event) {// console.log(event.data)var massage = eval("(" + event.data + ")");//这里表示一对一聊天if (massage.type == 'text' && massage.mode == 'single') {//当前正在聊天的人  如果当前的发送对象id等于该消息来源的id,则为一个人  ,if (this.to_id == massage.from_id) {// console.log("服务端消息:"+massage.content);// $("#chatBox-content-demo").append("<div>我是" + massage.from_id + ":" + massage.content + "</div>");
            $("#chatBox-content-demo").append("<div class=\"clearfloat\">\n" +"                                <div class=\"author-name\">\n" +"                                    <small class=\"chat-date\">"+ massage.datetime +"</small>\n" +"                                </div>\n" +"                                <div class=\"left\">\n" +"                                    <div class=\"chat-avatars\"><img src=\"" + myavatars + "\" alt=\"头像\"/></div>\n" +"                                    <div class=\"chat-message\">" + massage.content + "</div>\n" +"                                </div>\n" +"                            </div>");return;} else {//不是当前聊天的人、将消息提醒发送到对应的列表,并将消息发送到对应页面//在数据库请求该人的基本信息,
        }}//这里表示群聊if (massage.type == 'text' && massage.mode == 'group') {console.log(massage);}}
function onClose(event) {// document.getElementById("msg").innerHTML = "<p>他通讯已关闭</p>";
    console.log("关闭: " + sockState());webSocket.close();
}
function sockState() {var status = ['未连接', '连接成功,可通讯', '正在关闭', '连接已关闭或无法打开'];return status[webSocket.readyState];
}function close(event) {webSocket.close();
}
document.onkeydown = keyDownSearch;
function keyDownSearch(e) {// 兼容FF和IE和Operavar theEvent = e || window.event;var code = theEvent.keyCode || theEvent.which || theEvent.charCode;if (code == 13) {//具体处理函数
        chat_fasong()return false;}return true;
}//未读信息数量为空时
var totalNum = $(".chat-message-num").html();
if (totalNum == "") {$(".chat-message-num").css("padding", 0);
}
$(".message-num").each(function () {var wdNum = $(this).html();if (wdNum == "") {$(this).css("padding", 0);}
});//      发送信息
$("#chat-fasong").click(function () {chat_fasong()
});
function chat_fasong() {var textContent = $(".div-textarea").html().replace(/[\n\r]/g, '<br>')if (textContent != "") {//发送到服务器var msg1 = '{"type":"text","mode":"single","from_id":"' + from_id + '","to_id":"' + to_id + '","content":"' + textContent + '","datetime":"' + msgdate + '"}';webSocket.send(msg1);$(".chatBox-content-demo").append("<div class=\"clearfloat\">" +"<div class=\"author-name\"><small class=\"chat-date\">" + msgdate + "</small> </div> " +"<div class=\"right\"> <div class=\"chat-message\"> " + textContent + " </div> " +"<div class=\"chat-avatars\"><img src=\"/static/httpchat/img/icon01.png\" alt=\"头像\" /></div> </div> </div>");/*"/static/httpchat/img/icon01.png"*///发送后清空输入框
        $(".div-textarea").html("");//聊天框默认最底部
        $(document).ready(function () {$("#chatBox-content-demo").scrollTop($("#chatBox-content-demo")[0].scrollHeight);});}
}//      发送表情
$("#chat-biaoqing").click(function () {$(".biaoqing-photo").toggle();
});
$(document).click(function () {$(".biaoqing-photo").css("display", "none");
});
$("#chat-biaoqing").click(function (event) {event.stopPropagation();//阻止事件
});$(".emoji-picker-image").each(function () {$(this).click(function () {var bq = $(this).parent().html();//发送到服务器var msg2 = '{"type":"text","mode":"single","from_id":"' + from_id + '","to_id":"' + to_id + '","content":"' + bq + '","datetime":"' + msgdate + '"}';webSocket.send(msg2);$(".chatBox-content-demo").append("<div class=\"clearfloat\">" +"<div class=\"author-name\"><small class=\"chat-date\">"+ msgdate +"</small> </div> " +"<div class=\"right\"> <div class=\"chat-message\"> " + bq + " </div> " +"<div class=\"chat-avatars\"><img src=\"/static/httpchat/img/icon01.png\" alt=\"头像\" /></div> </div> </div>");//发送后关闭表情框
        $(".biaoqing-photo").toggle();//聊天框默认最底部
        $(document).ready(function () {$("#chatBox-content-demo").scrollTop($("#chatBox-content-demo")[0].scrollHeight);});})
});//      发送图片
function selectImg(pic) {if (!pic.files || !pic.files[0]) {return;}var reader = new FileReader();reader.onload = function (evt) {var images = evt.target.result;var to_img = "<img src=" + images + ">";//发送到服务器var msg3 = '{"type":"text","mode":"single","from_id":"' + from_id + '","to_id":"' + to_id + '","content":"' + to_img + '","datetime":"' + msgdate + '"}';webSocket.send(msg3);$(".chatBox-content-demo").append("<div class=\"clearfloat\">" +"<div class=\"author-name\"><small class=\"chat-date\">"+ msgdate +"</small> </div> " +"<div class=\"right\"> <div class=\"chat-message\"><img src=" + images + "></div> " +"<div class=\"chat-avatars\"><img src=\"/static/httpchat/img/icon01.png\" alt=\"头像\" /></div> </div> </div>");//聊天框默认最底部
        $(document).ready(function () {$("#chatBox-content-demo").scrollTop($("#chatBox-content-demo")[0].scrollHeight);});fu};reader.readAsDataURL(pic.files[0]);}</script>

Worker.php

<?phpnamespace app\controller;use think\worker\Server;class Worker extends Server
{protected $socket = 'websocket://127.0.0.1:8000';public $con;public function onConnect($connection){$connection->send('链接成功!');}public function onMessage($connection,$data){$connection->send("\n".'服务器接收成功!'."\n");$this->con = $connection;$this->qianwen($data);}public function onClose($connection){}public function onError($connection,$code,$msg){echo 'error' . $code  . $msg;}public function onWorkerStart($worker){}public function qianwen($question='长恨歌'){header('Content-Type: text/event-stream');header('Cache-Control: no-cache');header('X-Accel-Buffering: no');header('Connection: keep-alive');set_time_limit(0);$openai_api_key = 'sk-6666666666666666666666666666';//子空间key$url = 'https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation';$headers = ['Authorization: Bearer ' . $openai_api_key,'Content-Type: application/json','X-DashScope-SSE: enable'];$params =  ['model' => 'farui-plus','input' => ['messages' => []],'parameters' => ['result_format'=>'message','incremental_output'=>true],];$params['input']['messages'][] = ['role' => 'user','content' => $question];$ch = curl_init($url);curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_TIMEOUT, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//有时候希望返回的内容作为变量储存,而不是直接输出。这个时候就必需设置curl的CURLOPT_RETURNTRANSFER选项为1或true。curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);//设置这个选项为一个非零值(象 “Location: “)的头,服务器会把它当做HTTP头的一部分发送(注意这是递归的,PHP将发送形如 “Location: “的头)。curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//curl_exec()获取的信息以文件流的形式返回,而不是直接输出curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);curl_setopt($ch, CURLOPT_WRITEFUNCTION, function ($ch, $data) {$res = substr(explode("\n",$data)[3],5);$res = json_decode($res,true);if($res['output']){$this->dayin($res['output']['choices'][0]['message']['content']);}else{echo $res['message'];}return strlen($data);});curl_exec($ch);curl_close($ch);}public function dayin($msg){$this->con->send($msg);}}

三、运行worker服务

php think worker:server

四、前端链接

五、参考文档

https://www.cnblogs.com/wjs2019/p/18289547

打完收工!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/890566.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Redis复习-网络模型

用户空间和内核空间 任何Linux发行版,其系统内核都是Linux。我们的应用都需要通过Linux内核与硬件交互。 为了避免用户应用导致冲突甚至内核崩溃,用户应用与内核是分离的: 1.进程的寻址空间会划分为两部分:内核空间、用户空间 2.用户空间只能执行受限的命令(Ring3),而且…

2026-02-27 把本地项目添加到新建的git仓库

一:检查本地项目中是否存在git仓库git status 没有,好!进入第二步👇(有?直接git add git commit -m xxx git push,聊天end) 二:初始化仓库git init 三:创建一个远程仓库地址(如有可略) 四:关联远程仓库git remote add origin 远程仓库 五:推送git push一般直接执…

No.21 CSS--弹性盒子模型(flex box)

一、定义弹性盒子是 CSS3 的一种新的布局模式。 CSS3 弹性盒是一种当页面需要适应不同的屏幕大小以及设备类型时确保元素拥有恰当的行为的布局方式。 引入弹性盒布局模型的目的是提供一种更加有效的方式来对一个容器中的子元素进行排列、对齐和分配空白空间。二、CSS3弹性盒内容…

从零开始的云上建筑师速成班:用ROS架构编辑器搭个服务器小屋

云上建筑师速成秘籍:用阿里云ROS架构编辑器像搭乐高一样玩转服务器!零代码拖拽资源+配置指南,从部署到拆家一条龙服务~前情提要:你的云上建筑师执照 想成为云架构师?不需要考清华MIT,只需要: ✅ 一个阿里云账号(注册地址已备好,请自取) ✅ 完成实名认证(就像进游乐园…

第02章 JDBC的新增修改删除

JDBC编程六步 JDBC编程的步骤是很固定的,通常包含以下六步:第一步:注册驱动作用一:将 JDBC 驱动程序从硬盘上的文件系统中加载到内存中。 作用二:使得 DriverManager 可以通过一个统一的接口来管理该驱动程序的所有连接操作。第二步:获取数据库连接获取java.sql.Connecti…

第01章 JDBC概述

什么是JDBC JDBC(Java DataBase Connectivity)就是Java数据库连接,说白了就是用Java语言来操作数据库。原来我们操作数据库是在控制台使用SQL语句来操作数据库,JDBC是用Java语言向数据库发送SQL语句。‍ JDBC原理 早期SUN公司的天才们想编写一套可以连接天下所有数据库的AP…

数组模拟单链表

题目代码 #include <iostream> #include <algorithm> #include <cstring> using namespace std; const int N = 100010; int head, idx, e[N], ne[N]; // 两个值,两个数组// head:第一个节点的下标(表示头结点的下标) // idx:已经存储了几个数(到了第几个数…

ES-8.17.2版本集群搭建

前提工作准备  Linux 3台 16GB运行内存 8核 50GB磁盘  JDK17 环境配置  elasticsearch-8.17.2-linux-x86_64.tar.gz 安装包2.集群规划  在 ES 集群中,不同节点可承担不同角色: **主节点(Master Node)**:负责集群管理、节点选举、索引元数据管理。建议至少配置 3 个…

第9章 shell编程

Linux系统结构 Linux操作系统是一种开放源代码的类UNIX操作系统,它的结构分为内核、Shell和应用程序三个层次。内核层内核是Linux系统的核心部分,它负责管理系统各种硬件设备、文件系统、内存管理和进程管理等核心任务。Linux内核设计了良好的模块化结构,可以动态地加载和卸…

第2章 磁盘与文件管理

磁盘管理 windows和Linux磁盘管理的区别 windows资源管理方式系统一般安装在C盘 C盘下的"Windows"目录是操作系统的核心 C盘下的"Program Files"目录下安装软件 C盘下的"用户"目录是所有的用户,包括超级管理员也在其中 windows操作系统分为C盘、…

第3章 系统命令

系统当前时间 date命令:切换用户 su 用户名sudo 命令:表示使用超级管理员身份执行该命令,如果你当前不是管理员,希望以管理员身份执行某个命令时,使用sudo,需要输入超级管理员的密码: ​​ echo命令 输出字符串 echo "Hello, world!"这将会输出 Hello, world!…

https://avoid.overfit.cn/post/bad10ed894bd43c086e3ef9de7478bea

特征选择作为机器学习工作流程中的关键环节,对模型性能具有决定性影响。Featurewiz是一个功能强大的特征选择库,具备以下核心能力:高度自动化的特征选择,仅需少量代码即可完成。 全面的特征工程功能,不仅能够选择特征,还能生成数百个衍生特征并自动筛选最优特征组合。 实…