Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
水玉婷
ai-wechat
Commits
98bd0230
Commit
98bd0230
authored
Apr 01, 2026
by
水玉婷
Browse files
feat:调整参数配置结构
parent
344dc350
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/views/History.vue
View file @
98bd0230
...
...
@@ -121,9 +121,7 @@
:params=
"chatParams"
:dialogSessionId=
"currentSessionId"
:detailData=
"currentSessionDetail"
:apiBaseUrl=
"apiBaseUrl"
:token=
"userToken"
:appCode=
"appCode"
:baseConfig=
"baseConfig"
customClass=
"chat-history"
:key=
"sessionKey"
/>
...
...
@@ -180,6 +178,14 @@ const userInfo = localStorage.getItem('wechat_user');
const
{
extMap
=
{}
}
=
JSON
.
parse
(
userInfo
||
'
{}
'
);
const
userToken
=
extMap
.
sessionId
;
const
appCode
=
import
.
meta
.
env
.
VITE_APP_CODE
||
'
ped.qywx
'
;
// 基础配置对象
const
baseConfig
=
{
apiBaseUrl
,
token
:
userToken
,
appCode
};
const
chatParams
=
{
appId
:
'
83b2664019a945d0a438abe6339758d8
'
,
stage
:
'
wechat-demo
'
,
...
...
@@ -676,8 +682,6 @@ onMounted(() => {
padding: 20px;
color: #999;
font-size: 14px;
background: #fafafa;
border-top: 1px solid #f0f0f0;
.pull-up-icon {
font-size: 20px;
...
...
@@ -704,7 +708,9 @@ onMounted(() => {
align-items: center;
padding: 8px 20px;
cursor: pointer;
transition: background-color 0.2s ease;
transition: all 0.2s ease;
will-change: background-color;
height:46px;
&:hover {
background: #D5D8D8;
...
...
@@ -746,12 +752,11 @@ onMounted(() => {
.delete-button {
background: none;
border: none;
padding: 4px;
padding:
0
4px;
border-radius: 4px;
cursor: pointer;
color: #323232;
opacity: 0;
transition: all 0.2s ease;
display: none;
&:hover {
color: #ff4d4f;
...
...
@@ -759,7 +764,7 @@ onMounted(() => {
}
&:hover .delete-button {
opacity: 1
;
display: block
;
}
}
...
...
src/views/Home.vue
View file @
98bd0230
...
...
@@ -2,10 +2,7 @@
<AiChat
:params=
"chatParams"
:dialogSessionId=
"dialogSessionId"
:detailData=
"detailData"
:apiBaseUrl=
"apiBaseUrl"
:token=
"userToken"
:appCode=
"appCode"
:baseConfig=
"baseConfig"
customClass=
"chat-demo"
/>
</
template
>
...
...
@@ -35,17 +32,19 @@
// 使用环境变量代替硬编码
const
appCode
=
import
.
meta
.
env
.
VITE_APP_CODE
||
'
ped.qywx
'
;
// 基础配置对象
const
baseConfig
=
{
apiBaseUrl
,
token
:
userToken
,
appCode
};
const
time
=
new
Date
().
getTime
();
const
chatParams
=
{
appId
:
appId
||
'
83b2664019a945d0a438abe6339758d8
'
,
// 企业微信应用ID
stage
:
'
wechat-demo
'
+
time
,
};
// const dialogSessionId = '20251127180914709-00043912';
const
dialogSessionId
=
''
;
const
detailData
=
ref
({
title
:
'
国械小智
'
,
});
const
dialogSessionId
=
ref
(
''
);
</
script
>
<
style
scoped
>
...
...
src/views/Login.vue
View file @
98bd0230
...
...
@@ -48,11 +48,11 @@ export default {
onMounted
(()
=>
{
// 检查是否已登录
//
const status = wechat.checkLoginStatus()
//
if (status.isLoggedIn) {
//
router.replace('/')
//
return
//
}
const
status
=
wechat
.
checkLoginStatus
()
if
(
status
.
isLoggedIn
)
{
router
.
replace
(
'
/
'
)
return
}
// 执行静默登录
handleLogin
()
...
...
src/views/components/AiChat.vue
View file @
98bd0230
...
...
@@ -6,7 +6,7 @@
<img
:src=
"props?.logoUrl || defaultAvatar"
alt=
"avatar"
class=
"avatar-image"
/>
</div>
<div
class=
"header-info"
>
<h2>
{{
props
?.
dialogSessionId
?
props
?.
detailData
?.
titl
e
||
'
继续对话
'
:
'
新建对话
'
}}
</h2>
<h2>
{{
props
?.
dialogSessionId
?
appData
?.
app_name
e
||
'
继续对话
'
:
'
新建对话
'
}}
</h2>
</div>
</div>
...
...
@@ -115,9 +115,7 @@
<div
class=
"chat-input"
>
<!-- 语音识别按钮 -->
<VoiceRecognitionText
ref=
"voiceRecognitionRef"
:disabled=
"loading"
:debug=
"true"
:token=
"props?.token"
:appCode=
"props?.appCode"
:apiBaseUrl=
"props?.apiBaseUrl"
:baseConfig=
"baseConfig"
@
text=
"handleVoiceText"
@
error=
"handleVoiceError"
class=
"voice-recognition-wrapper"
/>
...
...
@@ -148,14 +146,13 @@ import { createContentTemplateService, type Message } from './utils/contentTempl
interface
Props
{
// 对话会话ID
dialogSessionId
?:
string
// API基础URL
apiBaseUrl
?:
string
// 应用代码
appCode
?:
string
token
?:
string
// 基础配置对象
baseConfig
?:
{
apiBaseUrl
?:
string
token
?:
string
appCode
?:
string
}
logoUrl
?:
string
// 对话详情数据
detailData
?:
Record
<
string
,
any
>
onMessageSend
?:
(
message
:
string
|
Blob
)
=>
Promise
<
void
>
onGetChatRecord
?:
Function
customClass
?:
string
...
...
@@ -169,11 +166,12 @@ interface Props {
// 定义组件属性
const
props
=
withDefaults
(
defineProps
<
Props
>
(),
{
dialogSessionId
:
''
,
apiBaseUrl
:
''
,
appCode
:
''
,
token
:
''
,
baseConfig
:
()
=>
({
apiBaseUrl
:
''
,
token
:
''
,
appCode
:
''
}),
logoUrl
:
''
,
detailData
:
()
=>
({}),
onMessageSend
:
undefined
,
onGetChatRecord
:
undefined
,
customClass
:
''
,
...
...
@@ -457,15 +455,15 @@ const sendMessage = async (type: MessageType = 'text', params: MessageParams = {
dialogSessionId
:
dialogSessionId
.
value
,
appId
:
props
.
params
?.
appId
,
};
const
{
token
,
appCode
}
=
props
.
baseConfig
||
{};
const
response
=
await
fetch
(
`
${
import
.
meta
.
env
.
VITE_SSE_PATH
}
/sse/ask`
,
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
'
token
'
:
props
.
token
,
'
x-session-id
'
:
props
?.
token
,
'
x-app-code
'
:
props
.
appCode
||
''
},
'
token
'
:
token
||
''
,
'
x-session-id
'
:
token
||
''
,
'
x-app-code
'
:
appCode
||
''
}
as
HeadersInit
,
body
:
JSON
.
stringify
(
requestData
)
});
...
...
@@ -670,13 +668,14 @@ const getChatRecord = async (dialogSessionId: string) => {
messages
.
value
=
[...
recordList
];
}
}
else
{
const
response
=
await
fetch
(
`
${
props
.
apiBaseUrl
}
/aiService/ask/list/chat/
${
dialogSessionId
}
`
,
{
const
{
token
,
appCode
}
=
props
.
baseConfig
||
{};
const
response
=
await
fetch
(
`
${
props
.
baseConfig
?.
apiBaseUrl
||
''
}
/aiService/ask/list/chat/
${
dialogSessionId
}
`
,
{
method
:
'
GET
'
,
headers
:
{
'
token
'
:
props
.
token
,
'
x-session-id
'
:
props
.
token
,
'
x-app-code
'
:
props
.
appCode
||
''
}
'
token
'
:
token
||
''
,
'
x-session-id
'
:
token
||
''
,
'
x-app-code
'
:
appCode
||
''
}
as
HeadersInit
});
const
data
=
await
response
.
json
();
...
...
@@ -698,10 +697,10 @@ const getAppInfo = async () => {
const
response
=
await
fetch
(
`
${
import
.
meta
.
env
.
VITE_SSE_PATH
}
/apps/getAppInfoById/
${
props
.
params
?.
appId
}
`
,
{
method
:
'
GET
'
,
headers
:
{
'
token
'
:
props
.
token
,
'
x-session-id
'
:
props
.
token
,
'
x-app-code
'
:
props
.
appCode
||
''
}
'
token
'
:
props
.
baseConfig
?.
token
||
''
,
'
x-session-id
'
:
props
.
baseConfig
?.
token
||
''
,
'
x-app-code
'
:
props
.
baseConfig
?.
appCode
||
''
}
as
HeadersInit
});
const
data
=
await
response
.
json
();
if
(
data
.
code
===
0
)
{
...
...
src/views/components/VoiceRecognition.vue
View file @
98bd0230
...
...
@@ -58,18 +58,22 @@ interface Props {
disabled
?:
boolean
debug
?:
boolean
maxDuration
?:
number
,
// 添加最大时长参数
token
?:
string
,
appCode
?:
string
,
apiBaseUrl
?:
string
,
baseConfig
?:
{
token
?:
string
,
appCode
?:
string
,
apiBaseUrl
?:
string
,
}
}
const
props
=
withDefaults
(
defineProps
<
Props
>
(),
{
disabled
:
false
,
debug
:
false
,
maxDuration
:
30
,
// 默认最大时长为30秒
token
:
''
,
appCode
:
''
,
apiBaseUrl
:
''
,
baseConfig
:
()
=>
({
token
:
''
,
appCode
:
''
,
apiBaseUrl
:
''
,
}
)
}
)
// 组件事件
...
...
@@ -408,14 +412,14 @@ const uploadAudioFile = async (audioBlob: Blob): Promise<{filePath: string, dura
const
formData
=
new
FormData
();
formData
.
append
(
'
file
'
,
audioBlob
,
'
recording.wav
'
);
formData
.
append
(
'
fileFolder
'
,
'
AI_TEMP
'
);
const
response
=
await
fetch
(
`${props.apiBaseUrl
}
/platformService/upload/v2`
,
{
const
{
token
,
appCode
}
=
props
.
baseConfig
||
{
}
;
const
response
=
await
fetch
(
`${props.
baseConfig?.
apiBaseUrl
|| ''
}
/platformService/upload/v2`
,
{
method
:
'
POST
'
,
headers
:
{
'
x-app-code
'
:
props
.
appCode
,
'
token
'
:
props
.
token
,
'
x-session-id
'
:
props
.
token
,
}
,
'
x-app-code
'
:
appCode
||
''
,
'
token
'
:
token
||
''
,
'
x-session-id
'
:
token
||
''
,
}
as
HeadersInit
,
body
:
formData
}
);
...
...
src/views/components/VoiceRecognitionText.vue
View file @
98bd0230
...
...
@@ -58,18 +58,22 @@ interface Props {
disabled
?:
boolean
debug
?:
boolean
maxDuration
?:
number
,
// 添加最大时长参数
token
?:
string
,
appCode
?:
string
,
apiBaseUrl
?:
string
,
baseConfig
?:
{
token
?:
string
,
appCode
?:
string
,
apiBaseUrl
?:
string
,
}
}
const
props
=
withDefaults
(
defineProps
<
Props
>
(),
{
disabled
:
false
,
debug
:
false
,
maxDuration
:
30
,
// 默认最大时长为30秒
token
:
''
,
appCode
:
''
,
apiBaseUrl
:
''
,
baseConfig
:
()
=>
({
token
:
''
,
appCode
:
''
,
apiBaseUrl
:
''
,
}
)
}
)
// 组件事件
...
...
@@ -409,13 +413,14 @@ const uploadAudioFile = async (audioBlob: Blob): Promise<string> => {
const
formData
=
new
FormData
();
formData
.
append
(
'
file
'
,
audioBlob
,
'
recording.wav
'
);
formData
.
append
(
'
fileFolder
'
,
'
AI_TEMP
'
);
const
{
token
,
appCode
}
=
props
.
baseConfig
||
{
}
;
const
response
=
await
fetch
(
`/agentService/index/audio2txt`
,
{
method
:
'
POST
'
,
headers
:
{
'
x-app-code
'
:
props
.
appCode
,
'
token
'
:
props
.
token
,
'
x-session-id
'
:
props
.
token
,
}
,
'
x-app-code
'
:
appCode
||
''
,
'
token
'
:
token
||
''
,
'
x-session-id
'
:
token
||
''
,
}
as
HeadersInit
,
body
:
formData
}
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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