wordpress网站侧栏加一个AI提示的代码

wordpress网站侧栏加一个AI提示的代码

wp侧栏小工具加一个推广AI的模块,类似对话打字效果,下面是代码: <div class="widget widget-chatgpt"> <div class="chatgpt-msg"> <div class="item"><span>小明</span><div class="msg"><span id="typed-me-span">...

wp侧栏小工具加一个推广AI的模块,类似对话打字效果,下面是代码:

<div class="widget widget-chatgpt">
<div class="chatgpt-msg">
<div class="item"><span>小明</span><div class="msg"><span id="typed-me-span">帮我写个关于***的开题报告</span></div></div>
<div class="item"><span>AI助手</span><div id="typed-text" class="msg"><span id="typed-text-span">好的,正在构思中,请稍等...</span></div></div>
</div>
<a href="<?php echo _MBT('child_openai_link');?>" target="_blank" class="btn">我要AI创作</a>
<script>
const div = document.getElementById('typed-me-span');
const text = div.innerHTML;
div.innerHTML = '';

for(let i = 0; i < text.length; i++) {
setTimeout(function(){
div.innerHTML += text.charAt(i);
}, i * 100);
}

setTimeout(function(){
jQuery("#typed-text-span").css("opacity","1");
const div2 = document.getElementById('typed-text-span');
const text = div2.innerHTML;
div2.innerHTML = '';

for(let i = 0; i < text.length; i++) {
setTimeout(function(){
div2.innerHTML += text.charAt(i);
}, i * 100);
}
},'2000');

</script>
</div>

css代码

.widget-chatgpt .btn{width:100%; background: linear-gradient( 270deg, #ff5f33 0%, #fe987c 100%); box-shadow: 0px 6px 10px 0px rgb(254 152 124 / 40%);display:block;color:#fff;padding:10px 0}
.widget-chatgpt .chatgpt-msg .item{margin-bottom:20px;overflow:hidden;text-align:right}
.widget-chatgpt .chatgpt-msg .item > span{display:block;color:#999;margin-bottom:3px;font-size:14px;}
.widget-chatgpt .chatgpt-msg .item .msg{background:#f5f5f5;padding:6px 14px;border-radius:8px 0 8px 8px;max-width:80%;font-size:14px;word-break: break-word;-webkit-user-select: text;-moz-user-select: text;user-select: text;display: inline-block;text-align: left; white-space: nowrap; overflow: hidden;width:210px;}
.widget-chatgpt .chatgpt-msg .item .msg #typed-me-span{animation: typing 4s steps(40, end);}
.widget-chatgpt .chatgpt-msg .item .msg #typed-text-span{animation: typing 10s steps(100, end);opacity:0}
.widget-chatgpt .chatgpt-msg .item:nth-child(2n){text-align:left}
.widget-chatgpt .chatgpt-msg .item:nth-child(2n) .msg{border-radius:0 8px 8px 8px}

 

原文链接:https://www.dqzy.cn/2025/03/30/109.html,转载请注明出处。 1、本站所有源码资源(包括源代码、软件、学习资料等)仅供研究学习以及参考等合法使用,请勿用于商业用途以及违法使用。如本站不慎侵犯您的版权请联系我们,我们将及时处理,并撤下相关内容! 2、访问本站的用户必须明白,本站对所提供下载的软件和程序代码不拥有任何权利,其版权归该软件和程序代码的合法拥有者所有,请用户在下载使用前必须详细阅读并遵守软件作者的“使用许可协议”,本站仅仅是一个学习交流的平台。 3、如下载的压缩包需要解压密码,若无特殊说明,那么文件的解压密码则为:www.dqzy.cn。 4、点启资源网是一个免费且专业分享网站源码、图片素材、特效代码、教程文章、站长工具的平台。我们努力给站长提供好的资源!
0

评论0

请先
显示验证码
没有账号?注册  忘记密码?