明树Git Lab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
D
deepseek_wechat_chat
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zengfanpei
deepseek_wechat_chat
Commits
f421ec49
Commit
f421ec49
authored
Feb 26, 2025
by
yangyajing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加发送按钮
parent
5d7b9c51
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
124 additions
and
116 deletions
+124
-116
index.css
public/publicAccount/css/index.css
+14
-4
index.html
public/publicAccount/index.html
+1
-0
index.js
public/publicAccount/js/index.js
+109
-112
No files found.
public/publicAccount/css/index.css
View file @
f421ec49
...
...
@@ -50,17 +50,27 @@ body, html{
}
.container
.input-wrap
{
margin-top
:
0.625rem
;
display
:
flex
;
align-items
:
center
;
}
.container
.input-wrap
input
{
width
:
100%
;
flex
:
1
;
width
:
0
;
border
:
1px
solid
#aaa
;
height
:
1.87
5rem
;
line-height
:
1.87
5rem
;
border-radius
:
0.
2
5rem
;
height
:
2.
5rem
;
line-height
:
2.
5rem
;
border-radius
:
0.5rem
;
padding
:
0
0.75rem
;
box-sizing
:
border-box
;
outline
:
none
;
}
.container
.input-wrap
.send-button
{
padding
:
5px
15px
;
background-color
:
#1FC67E
;
color
:
#fff
;
border-radius
:
6px
;
margin-left
:
15px
;
}
.mask-container
{
position
:
fixed
;
width
:
100%
;
...
...
public/publicAccount/index.html
View file @
f421ec49
...
...
@@ -11,6 +11,7 @@
</div>
<div
class=
"input-wrap"
>
<input
type=
"text"
id=
"question-input"
placeholder=
"给deepseek发送消息"
>
<div
class=
"send-button"
>
发送
</div>
</div>
</div>
<div
class=
"mask-container"
>
...
...
public/publicAccount/js/index.js
View file @
f421ec49
...
...
@@ -78,128 +78,125 @@ $(function () {
})
}
// 提交问答
$
(
"#question-input"
).
keypress
(
function
(
event
)
{
if
(
event
.
key
===
"Enter"
||
event
.
keyCode
===
13
)
{
event
.
preventDefault
();
question
=
$
(
this
).
val
();
if
(
question
)
{
async
function
handleAsk
()
{
try
{
const
response
=
await
fetch
(
"https://dashscope.aliyuncs.com/api/v1/apps/6de1065c75074ee1a11238ab90c1aa34/completion"
,
{
body
:
JSON
.
stringify
({
input
:
{
prompt
:
question
,
stream
:
true
},
parameters
:
{},
debug
:
{}
}),
method
:
"post"
,
headers
:
{
"Authorization"
:
"Bearer sk-0ff2fc43671f4ed28dd7c80289da04e7"
,
"Content-Type"
:
"application/json"
,
"X-DashScope-SSE"
:
"enable"
$
(
".send-button"
).
on
(
"click"
,
function
()
{
question
=
$
(
"#question-input"
).
val
();
if
(
question
)
{
async
function
handleAsk
()
{
try
{
const
response
=
await
fetch
(
"https://dashscope.aliyuncs.com/api/v1/apps/6de1065c75074ee1a11238ab90c1aa34/completion"
,
{
body
:
JSON
.
stringify
({
input
:
{
prompt
:
question
,
stream
:
true
},
credentials
:
"omit"
,
mode
:
"cors"
});
if
(
response
.
status
==
200
)
{
const
reader
=
response
.
body
.
getReader
();
const
decoder
=
new
TextDecoder
();
$
(
"#question-input"
).
val
(
""
).
attr
(
"disabled"
,
false
);
while
(
true
)
{
const
{
value
,
done
}
=
await
reader
.
read
();
function
transformValue
(
val
)
{
const
string
=
decoder
.
decode
(
val
);
const
lines
=
string
.
split
(
'
\
n'
);
const
result
=
{};
lines
.
forEach
(
line
=>
{
const
[
k
,
v
]
=
line
.
split
(
':'
);
if
(
k
&&
v
)
{
if
(
k
===
'data'
)
{
result
[
k
]
=
JSON
.
parse
(
line
.
slice
(
line
.
indexOf
(
":"
)
+
1
));
}
else
{
result
[
k
]
=
v
;
}
parameters
:
{},
debug
:
{}
}),
method
:
"post"
,
headers
:
{
"Authorization"
:
"Bearer sk-0ff2fc43671f4ed28dd7c80289da04e7"
,
"Content-Type"
:
"application/json"
,
"X-DashScope-SSE"
:
"enable"
},
credentials
:
"omit"
,
mode
:
"cors"
});
if
(
response
.
status
==
200
)
{
const
reader
=
response
.
body
.
getReader
();
const
decoder
=
new
TextDecoder
();
$
(
"#question-input"
).
val
(
""
).
attr
(
"disabled"
,
false
);
while
(
true
)
{
const
{
value
,
done
}
=
await
reader
.
read
();
function
transformValue
(
val
)
{
const
string
=
decoder
.
decode
(
val
);
const
lines
=
string
.
split
(
'
\
n'
);
const
result
=
{};
lines
.
forEach
(
line
=>
{
const
[
k
,
v
]
=
line
.
split
(
':'
);
if
(
k
&&
v
)
{
if
(
k
===
'data'
)
{
result
[
k
]
=
JSON
.
parse
(
line
.
slice
(
line
.
indexOf
(
":"
)
+
1
));
}
else
{
result
[
k
]
=
v
;
}
});
return
result
;
}
const
result
=
transformValue
(
value
);
if
(
done
)
{
$
(
'.conversation-loading'
).
hide
();
saveConversation
();
break
;
}
answer
=
""
;
if
(
result
.
data
&&
result
.
data
.
output
&&
result
.
data
.
output
.
text
)
{
answer
=
result
.
data
.
output
.
text
;
}
$
(
".conversation-item"
).
eq
(
$
(
".conversation-item"
).
length
-
1
).
find
(
".answer-data"
).
html
(
answer
);
scrollBottom
();
}
});
return
result
;
}
const
result
=
transformValue
(
value
);
if
(
done
)
{
$
(
'.conversation-loading'
).
hide
();
saveConversation
();
break
;
}
answer
=
""
;
if
(
result
.
data
&&
result
.
data
.
output
&&
result
.
data
.
output
.
text
)
{
answer
=
result
.
data
.
output
.
text
;
}
}
else
{
$
(
".conversation-item"
).
eq
(
$
(
".conversation-item"
).
length
-
1
).
find
(
".answer-data"
).
html
(
"网络连接失败"
);
$
(
"#question-input"
).
val
(
""
).
attr
(
"disabled"
,
false
);
$
(
'.conversation-loading'
).
hide
();
$
(
".conversation-item"
).
eq
(
$
(
".conversation-item"
).
length
-
1
).
find
(
".answer-data"
).
html
(
answer
);
scrollBottom
();
}
}
catch
(
err
)
{
}
else
{
$
(
".conversation-item"
).
eq
(
$
(
".conversation-item"
).
length
-
1
).
find
(
".answer-data"
).
html
(
"网络连接失败"
);
$
(
"#question-input"
).
val
(
""
).
attr
(
"disabled"
,
false
);
$
(
'.conversation-loading'
).
hide
();
}
}
catch
(
err
)
{
$
(
".conversation-item"
).
eq
(
$
(
".conversation-item"
).
length
-
1
).
find
(
".answer-data"
).
html
(
"网络连接失败"
);
$
(
"#question-input"
).
val
(
""
).
attr
(
"disabled"
,
false
);
$
(
'.conversation-loading'
).
hide
();
}
// 创建对话框
let
div
=
document
.
createElement
(
"div"
);
div
.
className
=
"conversation-item"
;
div
.
innerHTML
=
`<div class="conversation-question">
<div class="question-data">
${
question
}
</div>
</div>
<div class="conversation-answer">
<div class="answer-data"></div>
</div>`
;
$
(
'.conversation-wrap'
)[
0
].
insertBefore
(
div
,
$
(
'.conversation-loading'
)[
0
]);
$
(
'.conversation-loading'
).
show
();
$
(
this
).
attr
(
"disabled"
,
true
);
handleAsk
();
// $.ajax({
// url: "https://dashscope.aliyuncs.com/api/v1/apps/6de1065c75074ee1a11238ab90c1aa34/completion",
// type: "post",
// timeout: 1800000,
// headers: {
// "Authorization": "Bearer sk-0ff2fc43671f4ed28dd7c80289da04e7",
// "Content-Type": "application/json",
// "X-DashScope-SSE": "enable"
// },
// contentType: "application/json",
// data: JSON.stringify({
// input: {
// prompt: question,
// stream: true
// },
// 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-wrap')[0].insertBefore(div, $('.conversation-loading')[0]);
// $(this).val("");
// $('.conversation-loading').hide();
// scrollBottom();
// // saveConversation();
// }
// })
}
// 创建对话框
let
div
=
document
.
createElement
(
"div"
);
div
.
className
=
"conversation-item"
;
div
.
innerHTML
=
`<div class="conversation-question">
<div class="question-data">
${
question
}
</div>
</div>
<div class="conversation-answer">
<div class="answer-data"></div>
</div>`
;
$
(
'.conversation-wrap'
)[
0
].
insertBefore
(
div
,
$
(
'.conversation-loading'
)[
0
]);
$
(
'.conversation-loading'
).
show
();
$
(
"#question-input"
).
attr
(
"disabled"
,
true
);
handleAsk
();
// $.ajax({
// url: "https://dashscope.aliyuncs.com/api/v1/apps/6de1065c75074ee1a11238ab90c1aa34/completion",
// type: "post",
// timeout: 1800000,
// headers: {
// "Authorization": "Bearer sk-0ff2fc43671f4ed28dd7c80289da04e7",
// "Content-Type": "application/json",
// "X-DashScope-SSE": "enable"
// },
// contentType: "application/json",
// data: JSON.stringify({
// input: {
// prompt: question,
// stream: true
// },
// 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-wrap')[0].insertBefore(div, $('.conversation-loading')[0]);
// $(this).val("");
// $('.conversation-loading').hide();
// scrollBottom();
// // saveConversation();
// }
// })
}
});
// 保存当前问答
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment