明树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
8b55f684
Commit
8b55f684
authored
Feb 26, 2025
by
yangyajing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加发送disabled,修改授权弹框样式
parent
3fca6402
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
64 deletions
+54
-64
index.css
public/publicAccount/css/index.css
+14
-5
index.html
public/publicAccount/index.html
+3
-2
index.js
public/publicAccount/js/index.js
+37
-57
No files found.
public/publicAccount/css/index.css
View file @
8b55f684
...
...
@@ -20,6 +20,11 @@ body, html{
border-radius
:
0.31rem
;
overflow-y
:
auto
;
}
.container
.conversation-wrap
.reload-button
{
text-align
:
center
;
cursor
:
pointer
;
display
:
none
;
}
.container
.conversation-wrap
.conversation-question
{
text-align
:
right
;
}
...
...
@@ -72,6 +77,10 @@ body, html{
margin-left
:
15px
;
cursor
:
pointer
;
}
.container
.input-wrap
.send-button.disabled
{
background-color
:
#aaa
;
cursor
:
not-allowed
;
}
.mask-container
{
position
:
fixed
;
width
:
100%
;
...
...
@@ -102,15 +111,15 @@ body, html{
.mask-container
.mask-content
{
font-size
:
0.875rem
;
color
:
#333
;
margin
:
0.75rem
0
;
margin
:
0.75rem
0
1.5rem
;
}
.mask-container
.mask-button
{
display
:
inline-block
;
padding
:
0
1rem
;
height
:
2rem
;
line-height
:
2rem
;
width
:
80%
;
height
:
2
.5
rem
;
line-height
:
2
.5
rem
;
text-align
:
center
;
background-color
:
rgb
(
239
,
10
,
10
)
;
background-color
:
#1FC67E
;
color
:
#fff
;
border-radius
:
0.5rem
;
cursor
:
pointer
;
...
...
public/publicAccount/index.html
View file @
8b55f684
...
...
@@ -7,6 +7,7 @@
<body>
<div
class=
"container"
>
<div
class=
"conversation-wrap"
>
<div
class=
"reload-button"
>
点击重新加载
</div>
<div
class=
"conversation-loading"
>
加载中……
</div>
</div>
<div
class=
"input-wrap"
>
...
...
@@ -16,9 +17,9 @@
</div>
<div
class=
"mask-container"
>
<div
class=
"mask-wrap"
>
<div
class=
"mask-title"
>
用户信息
授权
</div>
<div
class=
"mask-title"
>
登录
授权
</div>
<div
class=
"mask-content"
>
为了更好地提供服务,请授权用户信息
</div>
<div
class=
"mask-button"
>
授权
登录
</div>
<div
class=
"mask-button"
>
授权
</div>
</div>
</div>
</body>
...
...
public/publicAccount/js/index.js
View file @
8b55f684
...
...
@@ -5,24 +5,28 @@ $(function () {
let
page
=
1
;
let
pageSize
=
10
;
let
havePage
=
true
;
let
canSend
=
true
;
// 判断是否已授权
function
checkCode
()
{
let
searchCode
=
new
URLSearchParams
(
location
.
search
).
get
(
"code"
);
if
(
searchCode
)
{
localStorage
.
setItem
(
"tokenCode"
,
searchCode
);
tokenCode
=
searchCode
;
getUserInfo
();
}
else
{
$
(
".mask-container"
).
show
();
openId
=
localStorage
.
getItem
(
"openId"
);
if
(
!
openId
)
{
let
searchCode
=
new
URLSearchParams
(
location
.
search
).
get
(
"code"
);
if
(
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"
;
location
.
replace
=
"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"
;
})
// 获取问答记录
function
getList
()
{
$
(
'.conversation-loading'
).
show
();
$
.
ajax
({
url
:
"http://deepseek.bridata.com/api/question/getQuesList"
,
type
:
"post"
,
...
...
@@ -34,6 +38,7 @@ $(function () {
}),
dataType
:
"json"
,
success
:
(
res
)
=>
{
$
(
'.conversation-loading'
).
hide
();
if
(
res
.
code
===
0
)
{
let
conversationList
=
res
.
data
.
list
;
let
html
=
""
...
...
@@ -49,9 +54,12 @@ $(function () {
$
(
'.conversation-wrap'
).
html
(
html
+
$
(
'.conversation-wrap'
).
html
());
scrollBottom
();
havePage
=
conversationList
.
length
===
pageSize
;
}
else
{
$
(
".reload-button"
).
show
();
}
},
error
:
function
()
{
$
(
'.conversation-loading'
).
hide
();
alert
(
"网络连接失败"
);
}
})
...
...
@@ -69,6 +77,7 @@ $(function () {
success
:
(
res
)
=>
{
if
(
res
.
code
===
0
)
{
openId
=
res
.
data
.
openid
;
localStorage
.
setItem
(
"openId"
,
openId
);
getList
();
}
},
...
...
@@ -77,10 +86,17 @@ $(function () {
}
})
}
// 重新获取记录
$
(
".reload-button"
).
on
(
"click"
,
function
()
{
$
(
this
).
hide
();
getList
();
})
// 提交问答
$
(
".send-button"
).
on
(
"click"
,
function
()
{
question
=
$
(
"#question-input"
).
val
();
if
(
question
)
{
if
(
question
&&
canSend
)
{
canSend
=
false
;
$
(
this
).
addClass
(
"disabled"
);
async
function
handleAsk
()
{
try
{
const
response
=
await
fetch
(
"https://dashscope.aliyuncs.com/api/v1/apps/6de1065c75074ee1a11238ab90c1aa34/completion"
,
{
...
...
@@ -104,7 +120,6 @@ $(function () {
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
)
{
...
...
@@ -125,7 +140,9 @@ $(function () {
}
const
result
=
transformValue
(
value
);
if
(
done
)
{
$
(
'.conversation-loading'
).
hide
();
canSend
=
true
;
$
(
"#question-input"
).
attr
(
"disabled"
,
false
);
$
(
".send-button"
).
removeClass
(
"disabled"
);
saveConversation
();
break
;
}
...
...
@@ -138,13 +155,15 @@ $(function () {
}
}
else
{
$
(
".conversation-item"
).
eq
(
$
(
".conversation-item"
).
length
-
1
).
find
(
".answer-data"
).
html
(
"网络连接失败"
);
$
(
"#question-input"
).
val
(
""
).
attr
(
"disabled"
,
false
);
$
(
'.conversation-loading'
).
hide
();
$
(
"#question-input"
).
attr
(
"disabled"
,
false
);
$
(
".send-button"
).
removeClass
(
"disabled"
);
canSend
=
true
;
}
}
catch
(
err
)
{
canSend
=
true
;
$
(
".send-button"
).
removeClass
(
"disabled"
);
$
(
".conversation-item"
).
eq
(
$
(
".conversation-item"
).
length
-
1
).
find
(
".answer-data"
).
html
(
"网络连接失败"
);
$
(
"#question-input"
).
val
(
""
).
attr
(
"disabled"
,
false
);
$
(
'.conversation-loading'
).
hide
();
$
(
"#question-input"
).
attr
(
"disabled"
,
false
);
}
}
// 创建对话框
...
...
@@ -154,50 +173,11 @@ $(function () {
<div class="question-data">
${
question
}
</div>
</div>
<div class="conversation-answer">
<div class="answer-data"></div>
<div class="answer-data">
加载中……
</div>
</div>`
;
$
(
'.conversation-loading'
).
before
(
div
);
// $('.conversation-wrap')[0].insertBefore(div, $('.conversation-loading')[0]);
$
(
'.conversation-loading'
).
show
();
$
(
"#question-input"
).
attr
(
"disabled"
,
true
);
$
(
'.conversation-loading'
).
before
(
div
);
$
(
"#question-input"
).
val
(
""
).
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