Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
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
mobile-group
galaxy-iOS
Commits
3ffa22f6
Commit
3ffa22f6
authored
Dec 09, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// AI
parent
07f52756
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
59 deletions
+96
-59
YHAIMainChatViewController.swift
...s/AI/AI-Dialogue(AI对话)/C/YHAIMainChatViewController.swift
+13
-4
YHAIRobotChatViewController.swift
.../AI/AI-Dialogue(AI对话)/C/YHAIRobotChatViewController.swift
+83
-55
No files found.
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/C/YHAIMainChatViewController.swift
View file @
3ffa22f6
...
@@ -220,6 +220,10 @@ class YHAIMainChatViewController: YHBaseViewController {
...
@@ -220,6 +220,10 @@ class YHAIMainChatViewController: YHBaseViewController {
}
}
}
}
}
}
func
isNeedStopResonse
()
->
Bool
{
return
self
.
bottomInputView
.
status
==
.
loading
}
}
}
extension
YHAIMainChatViewController
:
UITableViewDelegate
,
UITableViewDataSource
{
extension
YHAIMainChatViewController
:
UITableViewDelegate
,
UITableViewDataSource
{
...
@@ -243,11 +247,16 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
...
@@ -243,11 +247,16 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
cell
.
messageClick
=
{
cell
.
messageClick
=
{
[
weak
self
]
text
in
[
weak
self
]
text
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
self
.
stopAutoResponse
{
success
in
if
self
.
isNeedStopResonse
()
{
if
success
{
self
.
stopAutoResponse
{
success
in
self
.
sendMessage
(
text
)
if
success
{
self
.
sendMessage
(
text
)
}
}
}
}
}
}
else
{
self
.
sendMessage
(
text
)
}
}
return
cell
return
cell
}
else
if
msgType
==
.
thinking
{
}
else
if
msgType
==
.
thinking
{
...
...
galaxy/galaxy/Classes/Modules/AI/AI-Dialogue(AI对话)/C/YHAIRobotChatViewController.swift
View file @
3ffa22f6
...
@@ -78,6 +78,50 @@ class YHAIRobotChatViewController: YHBaseViewController {
...
@@ -78,6 +78,50 @@ class YHAIRobotChatViewController: YHBaseViewController {
return
msg
return
msg
}()
}()
lazy
var
bannerView
:
YHAIChatBannerView
=
{
let
view
=
YHAIChatBannerView
(
frame
:
CGRectMake
(
0
,
0
,
KScreenWidth
,
360
))
view
.
titleLabel
.
text
=
getHeaderTitle
()
view
.
descLabel
.
text
=
getHeaderDesc
()
view
.
bannerArr
=
self
.
getBannerForRobotType
(
robotType
)
view
.
messages
=
getFlowMessages
()
view
.
selectFlowMsgBlock
=
{
[
weak
self
]
text
in
guard
let
self
=
self
else
{
return
}
if
self
.
isNeedStopResonse
()
{
self
.
stopAutoResponse
{
success
in
if
success
{
self
.
sendMessage
(
text
)
}
}
}
else
{
self
.
sendMessage
(
text
)
}
}
view
.
selectBannerItemBlock
=
{
[
weak
self
]
model
in
guard
let
self
=
self
else
{
return
}
var
text
=
""
if
!
model
.
msg
.
isEmpty
{
text
=
model
.
msg
}
else
if
!
model
.
desc
.
isEmpty
{
text
=
model
.
desc
}
if
self
.
isNeedStopResonse
()
{
self
.
stopAutoResponse
{
success
in
if
success
{
self
.
sendMessage
(
text
)
}
}
}
else
{
self
.
sendMessage
(
text
)
}
}
return
view
}()
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
...
@@ -95,6 +139,12 @@ class YHAIRobotChatViewController: YHBaseViewController {
...
@@ -95,6 +139,12 @@ class YHAIRobotChatViewController: YHBaseViewController {
self
.
view
.
addSubview
(
self
.
bgImgView
)
self
.
view
.
addSubview
(
self
.
bgImgView
)
self
.
view
.
insertSubview
(
bgImgView
,
belowSubview
:
gk_navigationBar
)
self
.
view
.
insertSubview
(
bgImgView
,
belowSubview
:
gk_navigationBar
)
if
self
.
isNeedShowBannerHeader
{
self
.
tableView
.
tableHeaderView
=
self
.
bannerView
}
else
{
self
.
tableView
.
tableHeaderView
=
nil
}
cleanBtn
.
snp
.
makeConstraints
{
make
in
cleanBtn
.
snp
.
makeConstraints
{
make
in
make
.
width
.
height
.
equalTo
(
24
)
make
.
width
.
height
.
equalTo
(
24
)
make
.
centerY
.
equalToSuperview
()
make
.
centerY
.
equalToSuperview
()
...
@@ -123,26 +173,28 @@ class YHAIRobotChatViewController: YHBaseViewController {
...
@@ -123,26 +173,28 @@ class YHAIRobotChatViewController: YHBaseViewController {
}
}
@objc
override
func
backItemClick
(
_
sender
:
Any
)
{
@objc
override
func
backItemClick
(
_
sender
:
Any
)
{
self
.
stopAutoResponse
()
if
self
.
isNeedStopResonse
()
{
self
.
stopAutoResponse
{
success
in
}
}
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
}
}
func
scrollToBottom
()
{
func
scrollToBottom
()
{
self
.
tableView
.
reloadData
{
self
.
tableView
.
reloadData
{
if
self
.
messages
.
count
>
0
{
if
self
.
messages
.
count
>
0
{
let
indexPath
=
IndexPath
(
row
:
self
.
messages
.
count
-
1
,
section
:
0
)
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
0.5
,
execute
:
{
self
.
tableView
.
scrollToRow
(
at
:
indexPath
,
at
:
.
bottom
,
animated
:
true
)
let
indexPath
=
IndexPath
(
row
:
self
.
messages
.
count
-
1
,
section
:
0
)
self
.
tableView
.
scrollToRow
(
at
:
indexPath
,
at
:
.
bottom
,
animated
:
true
)
})
}
}
}
}
}
}
func
sendMessage
(
_
text
:
String
)
{
func
sendMessage
(
_
text
:
String
)
{
if
self
.
bottomInputView
.
status
==
.
loading
{
YHHUD
.
flash
(
message
:
"AI回复未结束"
)
return
}
self
.
chatConfig
.
removeThinkingMessageFromChatList
(
&
messages
)
self
.
chatConfig
.
removeThinkingMessageFromChatList
(
&
messages
)
let
question
=
YHAIChatMessage
.
createQuestionMessage
(
text
)
let
question
=
YHAIChatMessage
.
createQuestionMessage
(
text
)
messages
.
append
(
question
)
messages
.
append
(
question
)
...
@@ -283,6 +335,10 @@ class YHAIRobotChatViewController: YHBaseViewController {
...
@@ -283,6 +335,10 @@ class YHAIRobotChatViewController: YHBaseViewController {
return
""
return
""
}
}
func
isNeedStopResonse
()
->
Bool
{
return
self
.
bottomInputView
.
status
==
.
loading
}
}
}
extension
YHAIRobotChatViewController
:
UITableViewDelegate
,
UITableViewDataSource
{
extension
YHAIRobotChatViewController
:
UITableViewDelegate
,
UITableViewDataSource
{
...
@@ -306,10 +362,15 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
...
@@ -306,10 +362,15 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
cell
.
messageClick
=
{
cell
.
messageClick
=
{
[
weak
self
]
text
in
[
weak
self
]
text
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
self
.
stopAutoResponse
{
success
in
if
success
{
if
self
.
isNeedStopResonse
()
{
self
.
sendMessage
(
text
)
self
.
stopAutoResponse
{
success
in
if
success
{
self
.
sendMessage
(
text
)
}
}
}
}
else
{
self
.
sendMessage
(
text
)
}
}
}
}
return
cell
return
cell
...
@@ -395,46 +456,6 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
...
@@ -395,46 +456,6 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
return
UITableView
.
automaticDimension
return
UITableView
.
automaticDimension
}
}
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
UIView
?
{
if
!
isNeedShowBannerHeader
{
return
UIView
()
}
let
view
=
YHAIChatBannerView
()
view
.
titleLabel
.
text
=
getHeaderTitle
()
view
.
descLabel
.
text
=
getHeaderDesc
()
view
.
bannerArr
=
self
.
getBannerForRobotType
(
robotType
)
view
.
messages
=
getFlowMessages
()
view
.
selectFlowMsgBlock
=
{
[
weak
self
]
text
in
guard
let
self
=
self
else
{
return
}
self
.
stopAutoResponse
{
success
in
if
success
{
self
.
sendMessage
(
text
)
}
}
}
view
.
selectBannerItemBlock
=
{
[
weak
self
]
model
in
guard
let
self
=
self
else
{
return
}
var
text
=
""
if
!
model
.
msg
.
isEmpty
{
text
=
model
.
msg
}
else
if
!
model
.
desc
.
isEmpty
{
text
=
model
.
desc
}
self
.
stopAutoResponse
{
success
in
if
success
{
self
.
sendMessage
(
text
)
}
}
}
return
view
}
func
getBannerForRobotType
(
_
robotType
:
String
)
->
[
YHAIChatBannerItem
]
{
func
getBannerForRobotType
(
_
robotType
:
String
)
->
[
YHAIChatBannerItem
]
{
...
@@ -452,16 +473,23 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
...
@@ -452,16 +473,23 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
return
[]
return
[]
}
}
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
UIView
?
{
let
view
=
UIView
()
return
view
}
func
tableView
(
_
tableView
:
UITableView
,
viewForFooterInSection
section
:
Int
)
->
UIView
?
{
func
tableView
(
_
tableView
:
UITableView
,
viewForFooterInSection
section
:
Int
)
->
UIView
?
{
let
view
=
UIView
()
let
view
=
UIView
()
return
view
return
view
}
}
func
tableView
(
_
tableView
:
UITableView
,
heightForHeaderInSection
section
:
Int
)
->
CGFloat
{
func
tableView
(
_
tableView
:
UITableView
,
heightForHeaderInSection
section
:
Int
)
->
CGFloat
{
if
!
isNeedShowBannerHeader
{
return
1.0
return
1.0
}
}
return
360.0
func
tableView
(
_
tableView
:
UITableView
,
heightForFooterInSection
section
:
Int
)
->
CGFloat
{
return
1.0
}
}
}
}
...
...
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