明树Git Lab

Commit d627b9af authored by zfp1's avatar zfp1
parents ab66b593 a0b615a9
body, html{
width: 100%;
height: 100%;
padding: 0;
margin: 0;
font-size: 16px;
}
.container{
width: 100%;
height: 100%;
padding: 1rem;
background-color: #f0f8ff;
box-sizing: border-box;
display: flex;
flex-direction: column;
}
.container .conversation-wrap{
flex: 1;
height: 0;
border-radius: 0.31rem;
overflow-y: auto;
}
.container .conversation-wrap .conversation-question{
text-align: right;
}
.container .conversation-wrap .question-data{
display: inline-block;
background-color: #1FC67E;
color: #fff;
margin: 0.625rem 0;
border-radius: 0.625rem;
border-top-right-radius: 0;
padding: 0.5rem 0.625rem;
}
.container .conversation-wrap .answer-data{
display: inline-block;
background-color: #fff;
color: #333;
margin: 0.625rem 0;
border-radius: 0.625rem;
border-top-left-radius: 0;
padding: 0.5rem 0.625rem;
}
.container .conversation-loading{
margin: 0.31rem;
text-align: center;
font-size: 0.75rem;
color: #999;
display: none;
}
.container .input-wrap{
margin-top: 0.625rem;
}
.container .input-wrap input{
width: 100%;
border: 1px solid #aaa;
height: 1.875rem;
line-height: 1.875rem;
border-radius: 0.25rem;
padding: 0 0.75rem;
box-sizing: border-box;
outline: none;
}
.mask-container{
position: fixed;
width: 100%;
height: 100%;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 99999;
background-color: rgba(0, 0, 0, 0.3);
display: none;
}
.mask-container .mask-wrap{
width: 70%;
padding: 3.125rem 0;
text-align: center;
position: absolute;
top: 30%;
left: 15%;
background-color: #fff;
border-radius: 0.25rem;
}
.mask-container .mask-title{
font-size: 1.5rem;
font-weight: 600;
line-height: 2rem;
}
.mask-container .mask-content{
font-size: 0.875rem;
color: #333;
margin: 0.75rem 0;
}
.mask-container .mask-button{
display: inline-block;
padding: 0 1rem;
height: 2rem;
line-height: 2rem;
text-align: center;
background-color: rgb(239,10,10);
color: #fff;
border-radius: 0.5rem;
cursor: pointer;
}
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1740035071822" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5579" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><path d="M1015.754983 6.744114A39.428502 39.428502 0 0 0 986.315035 0.69841L70.522354 312.972149A134.056908 134.056908 0 0 0 5.596753 403.920561a140.891182 140.891182 0 0 0 45.99992 105.142673l191.359664 163.496856a19.714251 19.714251 0 0 0 0 2.891424L242.167767 1002.18237a23.131388 23.131388 0 0 0 14.719974 19.977108c2.628567 0 0 1.839997 2.628567 1.839996a83.851282 83.851282 0 0 0 31.542802-6.045703l121.439787-117.496937a45.737063 45.737063 0 0 0 0-45.474206 20.502821 20.502821 0 0 0-29.177091 0l-91.999839 84.376995V710.411452l326.730856 257.599549a95.154119 95.154119 0 0 0 154.034016-43.108496l238.936724-867.427051c1.839997-7.359987 10.514267-45.737063 4.73142-50.994197zM275.024852 636.023011l-198.719651-177.165404A53.88562 53.88562 0 0 1 91.550888 368.697765L938.737975 57.73831l-663.713123 578.284701z m446.85636 259.702402a54.148477 54.148477 0 0 1-52.571336 37.325649 131.428341 131.428341 0 0 1-41.005643-8.67427l-310.433741-255.496695L951.880809 105.841083l-229.473883 788.570047z" fill="#1F212B" p-id="5580"></path></svg>
\ No newline at end of file
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./css/index.css">
</head>
<html>
<body>
<div class="container">
<div class="conversation-wrap">
<div class="conversation-loading">加载中……</div>
</div>
<div class="input-wrap">
<input type="text" id="question-input" placeholder="给deepseek发送消息">
</div>
</div>
<div class="mask-container">
<div class="mask-wrap">
<div class="mask-title">用户信息授权</div>
<div class="mask-content">为了更好地提供服务,请授权用户信息</div>
<div class="mask-button">授权登录</div>
</div>
</div>
</body>
<script type="text/javascript" src="./js/jquery-1.11.3.js"></script>
<script type="text/javascript" src="./js/index.js"></script>
</html>
\ No newline at end of file
$(function () {
// 判断是否已授权
let openId = "";
let question = "";
let answer = "";
function checkCode () {
let searchCode = new URLSearchParams(location.search).get("code");
if (searchCode) {
localStorage.setItem("tokenCode", searchCode);
tokenCode = searchCode;
getUserInfo();
} else {
$(".mask-container").show();
}
}
checkCode();
$(".mask-container .mask-button").click(() => {
location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx0abd4eaaac30fd6b&redirect_uri=http%3A%2F%2Fdeepseek.bridata.com/publicAccount%2F&response_type=code&scope=snsapi_userinfo#wechat_redirect";
})
// 获取问答记录
let page = 1;
function getList () {
$.ajax({
url: "http://deepseek.bridata.com/api/question/getQuesList",
type: "post",
contentType: "application/json",
data: JSON.stringify({
page: page,
pageSize: 5,
openId: openId
}),
dataType: "json",
success: (res) => {
let conversationList = res.list;
let html = ""
conversationList.forEach(item => {
html = `<div class="conversation-item"><div class="conversation-item">
<div class="conversation-question">
<div class="question-data">${item.question}</div>
</div>
<div class="conversation-answer">
<div class="answer-data">${item.answer}</div>
</div></div>`;
});
$('.conversation-wrap').html(html + $('.conversation-wrap').html());
scrollBottom();
}
})
}
// 获取用户信息
function getUserInfo () {
$.ajax({
url: "http://deepseek.bridata.com/api/wechat/pa/getUserInfo",
type: "post",
contentType: "application/json",
data: JSON.stringify({
code: tokenCode
}),
dataType: "json",
success: (res) => {
if (res.code === 0) {
openId = res.data.openid;
getList();
}
}
})
}
// 提交问答
$("#question-input").keypress(function(event) {
if (event.key === "Enter" || event.keyCode === 13) {
event.preventDefault();
question = $(this).val();
if (question) {
$('.conversation-loading').show();
$(this).attr("disabled", true);
$.ajax({
url: "https://dashscope.aliyuncs.com/api/v1/apps/6de1065c75074ee1a11238ab90c1aa34/completion",
type: "post",
headers: {
"Authorization": "Bearer sk-0ff2fc43671f4ed28dd7c80289da04e7",
"Content-Type": "application/json"
},
contentType: "application/json",
data: JSON.stringify({
input: {
prompt: question
},
parameters: {},
debug: {}
}),
dataType: "json",
success: (res) => {
answer = res.output.text;
let div = document.createElement("div");
div.className = "conversation-item";
div.innerHTML = `<div class="conversation-item">
<div class="conversation-question">
<div class="question-data">${question}</div>
</div>
<div class="conversation-answer">
<div class="answer-data">${answer}</div>
</div>`;
$('.conversation-loading').insertBefore(div);
$(this).val("");
$('.conversation-loading').hide();
scrollBottom();
saveConversation();
}
})
}
}
});
// 保存当前问答
function saveConversation () {
$.ajax({
url: "http://deepseek.bridata.com/api/question/createQuestion",
type: "post",
contentType: "application/json",
data: JSON.stringify({
openId: openId,
question: question,
answer: answer
}),
dataType: "json",
success: (res) => {
question = "";
answer = "";
}
})
}
// 滚动到页面底部
function scrollBottom () {
let content = $(".conversation-wrap")[0];
content.scrollTo({ top: content.scrollHeight, behavior: "smooth" });
}
})
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment