Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
poc-fe
Project
Project
Details
Activity
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
poc
poc-fe
Commits
7ba16dcf
Commit
7ba16dcf
authored
Oct 25, 2024
by
tyyin lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore(首页): 新建会话优化
parent
906a7c01
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
118 additions
and
52 deletions
+118
-52
app.vue
src/app.vue
+3
-0
message-tip-modal.vue
src/components/message-tip-modal/message-tip-modal.vue
+69
-0
zh-cn.yaml
src/locales/langs/zh-cn.yaml
+1
-0
zh-hk.yaml
src/locales/langs/zh-hk.yaml
+1
-0
footer-operation.vue
src/views/home/components/footer-operation.vue
+15
-2
history-menu-sidebar.vue
src/views/home/components/history-menu-sidebar.vue
+22
-46
home.vue
src/views/home/home.vue
+3
-3
global.d.ts
types/global.d.ts
+3
-1
locales.d.ts
types/locales.d.ts
+1
-0
No files found.
src/app.vue
View file @
7ba16dcf
...
@@ -6,6 +6,7 @@ import { themeOverrides } from '@/config/theme-config'
...
@@ -6,6 +6,7 @@ import { themeOverrides } from '@/config/theme-config'
import
{
useResizeObserver
}
from
'@vueuse/core'
import
{
useResizeObserver
}
from
'@vueuse/core'
import
{
useDesignSettingStore
}
from
'@/store/modules/design-setting'
import
{
useDesignSettingStore
}
from
'@/store/modules/design-setting'
import
{
useUserStore
}
from
'./store/modules/user'
import
{
useUserStore
}
from
'./store/modules/user'
import
MessageTipModal
from
'@/components/message-tip-modal/message-tip-modal.vue'
const
designSettingStore
=
useDesignSettingStore
()
const
designSettingStore
=
useDesignSettingStore
()
const
userStore
=
useUserStore
()
const
userStore
=
useUserStore
()
...
@@ -48,6 +49,8 @@ useResizeObserver(rootContainer, (entries) => {
...
@@ -48,6 +49,8 @@ useResizeObserver(rootContainer, (entries) => {
<
template
>
<
template
>
<div
ref=
"rootContainer"
class=
"h-full w-full"
>
<div
ref=
"rootContainer"
class=
"h-full w-full"
>
<MessageTipModal
/>
<NConfigProvider
<NConfigProvider
class=
"h-full w-full"
class=
"h-full w-full"
:locale=
"currentLocale"
:locale=
"currentLocale"
...
...
src/components/message-tip-modal/message-tip-modal.vue
0 → 100644
View file @
7ba16dcf
<
script
setup
lang=
"ts"
>
import
{
onMounted
,
reactive
,
ref
}
from
'vue'
import
{
useI18n
}
from
'vue-i18n'
const
{
t
}
=
useI18n
()
const
isShowModal
=
ref
(
false
)
const
modalOptions
=
reactive
({
title
:
t
(
'common_module.tip'
),
content
:
''
,
})
let
_modalStatusResolve
=
(
_value
?:
any
)
=>
{}
let
_modalStatusReject
=
(
_reason
?:
any
)
=>
{}
onMounted
(()
=>
{
window
.
$message
.
ctWarning
=
handleShowModal
})
function
handleCancel
()
{
isShowModal
.
value
=
false
_modalStatusReject
(
new
Error
(
'cancel show modal'
))
}
function
handleConfirm
()
{
isShowModal
.
value
=
false
_modalStatusResolve
(
true
)
}
function
handleShowModal
(
content
:
string
,
title
?:
string
)
{
content
&&
(
modalOptions
.
content
=
content
)
title
&&
(
modalOptions
.
title
=
title
)
isShowModal
.
value
=
true
return
new
Promise
<
boolean
|
Error
>
((
resolve
,
reject
)
=>
{
_modalStatusResolve
=
resolve
_modalStatusReject
=
reject
})
}
</
script
>
<
template
>
<n-modal
v-model:show=
"isShowModal"
>
<div
class=
"min-w-[420px] max-w-[600px] rounded-[10px] bg-[#fff] p-[30px]"
>
<div>
<h2>
<i
class=
"iconfont icon-tishi text-[18px] text-[#f25744]"
></i>
<span
class=
"font-600 ml-[5px] text-[18px]"
>
{{
modalOptions
.
title
||
t
(
'common_module.tip'
)
}}
</span>
</h2>
<div
class=
"mt-[20px] indent-4 text-[16px]"
>
{{
modalOptions
.
content
}}
</div>
</div>
<div
class=
"mt-[50px] text-end"
>
<n-button
color=
"#F5F5F5"
round
class=
"!px-[34px] !py-[10px] !text-[14px] !text-[#333]"
@
click=
"handleCancel"
>
{{
t
(
'common_module.cancel_btn_text'
)
}}
</n-button>
<n-button
color=
"#6F77FF"
round
class=
"!ml-[12px] !px-[34px] !py-[10px] !text-[14px]"
@
click=
"handleConfirm"
>
{{
t
(
'common_module.confirm_btn_text'
)
}}
</n-button>
</div>
</div>
</n-modal>
</
template
>
src/locales/langs/zh-cn.yaml
View file @
7ba16dcf
...
@@ -108,6 +108,7 @@ home_module:
...
@@ -108,6 +108,7 @@ home_module:
the_selected_list_cannot_be_empty
:
'
所选列表不能为空'
the_selected_list_cannot_be_empty
:
'
所选列表不能为空'
history_record_item_apply_tip
:
'
是否确定应用此会话记录?'
history_record_item_apply_tip
:
'
是否确定应用此会话记录?'
historical_record
:
'
历史记录'
historical_record
:
'
历史记录'
interrupt_dialogue_prompt
:
'
当前回复尚未完成,是否确定打断发起新会话?'
router_title_module
:
router_title_module
:
login
:
'
登录'
login
:
'
登录'
...
...
src/locales/langs/zh-hk.yaml
View file @
7ba16dcf
...
@@ -91,6 +91,7 @@ login_module:
...
@@ -91,6 +91,7 @@ login_module:
successful
:
'
獲取成功'
successful
:
'
獲取成功'
get_verification_code
:
'
獲取驗証碼'
get_verification_code
:
'
獲取驗証碼'
other_login_methods
:
'
其他登錄方式'
other_login_methods
:
'
其他登錄方式'
interrupt_dialogue_prompt
:
'
當前回復尚未完成,是否確定打斷發起新會話?'
home_module
:
home_module
:
agent_welcome_message
:
'
Hi,
歡迎使用SuperLink'
agent_welcome_message
:
'
Hi,
歡迎使用SuperLink'
...
...
src/views/home/components/footer-operation.vue
View file @
7ba16dcf
...
@@ -27,6 +27,8 @@ const isAgentResponding = defineModel<boolean>('isAgentResponding', { required:
...
@@ -27,6 +27,8 @@ const isAgentResponding = defineModel<boolean>('isAgentResponding', { required:
const
{
t
}
=
useI18n
()
const
{
t
}
=
useI18n
()
let
currentFetchEventSourceController
:
AbortController
|
null
=
null
const
isShowApplicationSelectMenu
=
ref
(
false
)
const
isShowApplicationSelectMenu
=
ref
(
false
)
const
agentApplicationSelectList
=
ref
<
AgentApplicationRecordItem
[]
>
([])
const
agentApplicationSelectList
=
ref
<
AgentApplicationRecordItem
[]
>
([])
...
@@ -61,7 +63,18 @@ function handleApplicationChange(agentApplicationItem: AgentApplicationRecordIte
...
@@ -61,7 +63,18 @@ function handleApplicationChange(agentApplicationItem: AgentApplicationRecordIte
}
}
function
handleCreateNewSession
()
{
function
handleCreateNewSession
()
{
if
(
isAgentResponding
.
value
)
{
window
.
$message
.
ctWarning
(
t
(
'home_module.interrupt_dialogue_prompt'
)).
then
(()
=>
{
currentFetchEventSourceController
&&
currentFetchEventSourceController
.
abort
()
isAgentResponding
.
value
=
false
emit
(
'createNewSession'
)
emit
(
'createNewSession'
)
emit
(
'historyRecordListUpdate'
)
})
}
else
{
emit
(
'createNewSession'
)
}
}
}
function
questionSubmit
()
{
function
questionSubmit
()
{
...
@@ -96,7 +109,7 @@ function questionSubmit() {
...
@@ -96,7 +109,7 @@ function questionSubmit() {
let
isFirstClip
=
true
let
isFirstClip
=
true
let
messageContent
=
''
let
messageContent
=
''
fetchEventStreamSource
(
currentFetchEventSourceController
=
fetchEventStreamSource
(
'/agentApplicationRest/callAgentApplication.json'
,
'/agentApplicationRest/callAgentApplication.json'
,
{
{
dialogsId
:
props
.
currentSessionId
,
//会话ID
dialogsId
:
props
.
currentSessionId
,
//会话ID
...
...
src/views/home/components/history-menu-sidebar.vue
View file @
7ba16dcf
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
fetchHistoryRecordDelete
,
fetchSessionHistoryRecordList
}
from
'@/apis/home-agent'
import
{
fetchHistoryRecordDelete
,
fetchSessionHistoryRecordList
}
from
'@/apis/home-agent'
import
{
computed
,
ref
,
nextTick
,
toValue
,
useTemplateRef
}
from
'vue'
import
{
computed
,
ref
,
nextTick
,
toValue
}
from
'vue'
import
MessageTipModal
from
'./message-tip-modal.vue'
import
{
useI18n
}
from
'vue-i18n'
import
{
useI18n
}
from
'vue-i18n'
interface
SessionHistoryRecordItem
{
interface
SessionHistoryRecordItem
{
...
@@ -16,18 +15,12 @@ const emit = defineEmits<{
...
@@ -16,18 +15,12 @@ const emit = defineEmits<{
const
isShowHistoryMenu
=
defineModel
<
boolean
>
({
default
:
true
})
const
isShowHistoryMenu
=
defineModel
<
boolean
>
({
default
:
true
})
const
{
t
}
=
useI18n
()
const
{
t
}
=
useI18n
()
const
messageTipModalRef
=
useTemplateRef
<
InstanceType
<
typeof
MessageTipModal
>>
(
'messageTipModalRef'
)
const
sessionHistoryRecordList
=
ref
<
SessionHistoryRecordItem
[]
>
([])
const
sessionHistoryRecordList
=
ref
<
SessionHistoryRecordItem
[]
>
([])
const
isHistoryListEdit
=
ref
(
false
)
const
isHistoryListEdit
=
ref
(
false
)
const
currentSelectHistoryRecordList
=
ref
<
SessionHistoryRecordItem
[
'dialogsId'
][]
>
([])
const
currentSelectHistoryRecordList
=
ref
<
SessionHistoryRecordItem
[
'dialogsId'
][]
>
([])
const
messageTipModalOptions
=
ref
<
{
title
:
string
;
content
:
string
}
>
({
title
:
t
(
'common_module.tip'
),
content
:
t
(
'home_module.history_record_item_delete_tip'
),
})
const
isSelectAllRecord
=
computed
(()
=>
{
const
isSelectAllRecord
=
computed
(()
=>
{
return
(
return
(
currentSelectHistoryRecordList
.
value
.
length
===
sessionHistoryRecordList
.
value
.
length
&&
currentSelectHistoryRecordList
.
value
.
length
===
sessionHistoryRecordList
.
value
.
length
&&
...
@@ -92,19 +85,16 @@ function handleRecordDelete() {
...
@@ -92,19 +85,16 @@ function handleRecordDelete() {
return
return
}
}
messageTipModalOptions
.
value
=
{
window
.
$message
.
ctWarning
(
t
(
'home_module.history_record_item_delete_tip'
),
t
(
'common_module.tip'
)).
then
(()
=>
{
title
:
t
(
'common_module.tip'
),
content
:
t
(
'home_module.history_record_item_delete_tip'
),
}
if
(
messageTipModalRef
.
value
)
{
messageTipModalRef
.
value
.
showModal
().
then
(()
=>
{
const
loadingCtl
=
window
.
$message
.
loading
(
`
${
t
(
'common_module.during_operation'
)}
...`
)
const
loadingCtl
=
window
.
$message
.
loading
(
`
${
t
(
'common_module.during_operation'
)}
...`
)
fetchHistoryRecordDelete
(
toValue
(
currentSelectHistoryRecordList
.
value
))
fetchHistoryRecordDelete
(
toValue
(
currentSelectHistoryRecordList
.
value
))
.
then
(()
=>
{
.
then
(()
=>
{
nextTick
(()
=>
{
nextTick
(()
=>
{
window
.
$message
.
success
(
t
(
'common_module.delete_success_message'
))
window
.
$message
.
success
(
t
(
'common_module.delete_success_message'
))
isHistoryListEdit
.
value
=
false
getSessionHistoryRecordList
()
getSessionHistoryRecordList
()
})
})
})
})
...
@@ -117,7 +107,6 @@ function handleRecordDelete() {
...
@@ -117,7 +107,6 @@ function handleRecordDelete() {
loadingCtl
.
destroy
()
loadingCtl
.
destroy
()
})
})
})
})
}
}
}
function
onHistoryRecordListUpdate
()
{
function
onHistoryRecordListUpdate
()
{
...
@@ -125,16 +114,9 @@ function onHistoryRecordListUpdate() {
...
@@ -125,16 +114,9 @@ function onHistoryRecordListUpdate() {
}
}
function
handleRecordItemApply
(
dialogsId
:
string
)
{
function
handleRecordItemApply
(
dialogsId
:
string
)
{
messageTipModalOptions
.
value
=
{
window
.
$message
.
ctWarning
(
t
(
'home_module.history_record_item_apply_tip'
),
t
(
'common_module.tip'
)).
then
(()
=>
{
title
:
t
(
'common_module.tip'
),
content
:
t
(
'home_module.history_record_item_apply_tip'
),
}
if
(
messageTipModalRef
.
value
)
{
messageTipModalRef
.
value
.
showModal
().
then
(()
=>
{
emit
(
'getMessageRecordList'
,
dialogsId
)
emit
(
'getMessageRecordList'
,
dialogsId
)
})
})
}
}
}
defineExpose
({
defineExpose
({
...
@@ -246,12 +228,6 @@ defineExpose({
...
@@ -246,12 +228,6 @@ defineExpose({
:class=
"{ '!rotate-0': !isShowHistoryMenu }"
:class=
"{ '!rotate-0': !isShowHistoryMenu }"
></span>
></span>
</button>
</button>
<MessageTipModal
ref=
"messageTipModalRef"
:title=
"messageTipModalOptions.title"
:content=
"messageTipModalOptions.content"
/>
</template>
</template>
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
...
...
src/views/home/home.vue
View file @
7ba16dcf
...
@@ -37,7 +37,7 @@ const questionContent = ref('')
...
@@ -37,7 +37,7 @@ const questionContent = ref('')
const
messageList
=
ref
(
new
Map
<
string
,
MessageItemInterface
>
())
const
messageList
=
ref
(
new
Map
<
string
,
MessageItemInterface
>
())
const
isAgentResponding
=
ref
(
false
)
const
isAgentResponding
=
ref
(
false
)
const
isShowMessageList
=
ref
(
false
)
const
isShowMessageList
=
ref
(
false
)
const
isAgentLoading
=
ref
(
true
)
const
isAgent
Init
Loading
=
ref
(
true
)
// messageList.value.set('1', {
// messageList.value.set('1', {
// role: 'user',
// role: 'user',
...
@@ -93,7 +93,7 @@ function createSessionId() {
...
@@ -93,7 +93,7 @@ function createSessionId() {
fetchCreateSessionId
<
string
>
().
then
((
res
)
=>
{
fetchCreateSessionId
<
string
>
().
then
((
res
)
=>
{
currentSessionId
.
value
=
res
.
data
currentSessionId
.
value
=
res
.
data
isAgentLoading
.
value
=
false
isAgent
Init
Loading
.
value
=
false
})
})
}
}
...
@@ -212,7 +212,7 @@ function onGetMessageRecordList(recordId: string) {
...
@@ -212,7 +212,7 @@ function onGetMessageRecordList(recordId: string) {
<Transition
name=
"mask"
mode=
"out-in"
>
<Transition
name=
"mask"
mode=
"out-in"
>
<div
<div
v-show=
"isAgentLoading"
v-show=
"isAgent
Init
Loading"
class=
"z-100 absolute inset-0 flex flex-col items-center justify-center bg-[rgba(0,0,0,0.4)]"
class=
"z-100 absolute inset-0 flex flex-col items-center justify-center bg-[rgba(0,0,0,0.4)]"
>
>
<n-spin
:size=
"38"
/>
<n-spin
:size=
"38"
/>
...
...
types/global.d.ts
View file @
7ba16dcf
...
@@ -2,7 +2,9 @@ declare interface Window {
...
@@ -2,7 +2,9 @@ declare interface Window {
ENV
:
'DEV'
|
'PROD'
ENV
:
'DEV'
|
'PROD'
$loadingBar
:
import
(
'naive-ui'
).
LoadingBarProviderInst
$loadingBar
:
import
(
'naive-ui'
).
LoadingBarProviderInst
$dialog
:
import
(
'naive-ui'
).
DialogProviderInst
$dialog
:
import
(
'naive-ui'
).
DialogProviderInst
$message
:
import
(
'naive-ui'
).
MessageProviderInst
$message
:
import
(
'naive-ui'
).
MessageProviderInst
&
{
ctWarning
:
(
message
:
string
,
title
?:
string
)
=>
Promise
<
boolean
|
Error
>
}
$notification
:
import
(
'naive-ui'
).
NotificationProviderInst
$notification
:
import
(
'naive-ui'
).
NotificationProviderInst
}
}
...
...
types/locales.d.ts
View file @
7ba16dcf
...
@@ -113,6 +113,7 @@ declare namespace I18n {
...
@@ -113,6 +113,7 @@ declare namespace I18n {
the_selected_list_cannot_be_empty
:
string
the_selected_list_cannot_be_empty
:
string
history_record_item_apply_tip
:
string
history_record_item_apply_tip
:
string
historical_record
:
string
historical_record
:
string
interrupt_dialogue_prompt
:
string
}
}
router_title_module
:
{
router_title_module
:
{
...
...
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