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
c0c1eadb
Commit
c0c1eadb
authored
Oct 11, 2025
by
Alex朱枝文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试bug修复
parent
73f1ee3d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
26 deletions
+82
-26
YHCirclePublishViewController.swift
...ty(社区)/Circle(下属社区)/C/YHCirclePublishViewController.swift
+18
-4
YHResourceViewController.swift
...mmunity(社区)/Resource(资源)/C/YHResourceViewController.swift
+27
-6
YHResourceListModel.swift
...es/Community(社区)/Resource(资源)/M/YHResourceListModel.swift
+7
-0
YHCustomSearchView.swift
...les/Community(社区)/Resource(资源)/V/YHCustomSearchView.swift
+1
-0
YHResourceCategoryView.swift
...Community(社区)/Resource(资源)/V/YHResourceCategoryView.swift
+27
-15
YHResourceViewModel.swift
...s/Community(社区)/Resource(资源)/VM/YHResourceViewModel.swift
+2
-1
No files found.
galaxy/galaxy/Classes/Modules/Community(社区)/Circle(下属社区)/C/YHCirclePublishViewController.swift
View file @
c0c1eadb
...
...
@@ -499,12 +499,26 @@ extension YHCirclePublishViewController: UITextViewDelegate {
}
func
textView
(
_
textView
:
UITextView
,
shouldChangeTextIn
range
:
NSRange
,
replacementText
text
:
String
)
->
Bool
{
let
currentText
=
textView
.
text
??
""
guard
let
stringRange
=
Range
(
range
,
in
:
currentText
)
else
{
return
false
}
let
updatedText
=
currentText
.
replacingCharacters
(
in
:
stringRange
,
with
:
text
)
if
textView
==
self
.
textView
{
let
currentText
=
textView
.
text
??
""
guard
let
stringRange
=
Range
(
range
,
in
:
currentText
)
else
{
return
false
}
let
updatedText
=
currentText
.
replacingCharacters
(
in
:
stringRange
,
with
:
text
)
return
updatedText
.
count
<=
100
// 标题限制20个字符
if
updatedText
.
count
>
20
{
YHHUD
.
flash
(
message
:
"标题最多20个字符"
)
return
false
}
return
true
}
else
if
textView
==
self
.
detailTextView
{
// 详情限制1000个字符
if
updatedText
.
count
>
1000
{
YHHUD
.
flash
(
message
:
"内容最多1000个字符"
)
return
false
}
return
true
}
return
true
}
}
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/C/YHResourceViewController.swift
View file @
c0c1eadb
...
...
@@ -17,6 +17,8 @@ class YHResourceViewController: YHBaseViewController {
// 添加高度约束属性
private
var
categoryViewHeightConstraint
:
Constraint
?
private
var
searchWorkItem
:
DispatchWorkItem
?
lazy
var
viewModel
:
YHResourceViewModel
=
{
let
viewModel
=
YHResourceViewModel
()
return
viewModel
...
...
@@ -315,7 +317,9 @@ private extension YHResourceViewController {
viewModel
.
getResourceCategories
{
[
weak
self
]
categories
,
error
in
guard
let
self
=
self
else
{
return
}
if
let
categories
=
categories
{
if
var
categories
=
categories
{
let
all
=
YHResourceCategory
.
allCategory
categories
.
insert
(
all
,
at
:
0
)
self
.
allCategories
=
categories
self
.
categoryView
.
setCategories
(
categories
)
}
else
if
let
error
=
error
{
...
...
@@ -394,9 +398,15 @@ private extension YHResourceViewController {
industryButton
.
setTitleColor
(
UIColor
.
brandGrayColor7
,
for
:
.
normal
)
industryButton
.
titleLabel
?
.
font
=
UIFont
.
PFSC_R
(
ofSize
:
13
)
}
else
if
selectedCategories
.
count
==
1
{
industryButton
.
setTitle
(
selectedCategories
.
first
?
.
name
??
"全部行业"
,
for
:
.
normal
)
industryButton
.
setTitleColor
(
UIColor
.
brandGrayColor8
,
for
:
.
normal
)
industryButton
.
titleLabel
?
.
font
=
UIFont
.
PFSC_M
(
ofSize
:
13
)
if
selectedCategories
.
first
?
.
id
==
YHResourceCategory
.
allCategory
.
id
{
industryButton
.
setTitle
(
"全部行业"
,
for
:
.
normal
)
industryButton
.
setTitleColor
(
UIColor
.
brandGrayColor8
,
for
:
.
normal
)
industryButton
.
titleLabel
?
.
font
=
UIFont
.
PFSC_M
(
ofSize
:
13
)
}
else
{
industryButton
.
setTitle
(
selectedCategories
.
first
?
.
name
??
"全部行业"
,
for
:
.
normal
)
industryButton
.
setTitleColor
(
UIColor
.
brandGrayColor8
,
for
:
.
normal
)
industryButton
.
titleLabel
?
.
font
=
UIFont
.
PFSC_M
(
ofSize
:
13
)
}
}
else
{
industryButton
.
setTitle
(
"已选
\(
selectedCategories
.
count
)
个行业"
,
for
:
.
normal
)
industryButton
.
setTitleColor
(
UIColor
.
brandGrayColor8
,
for
:
.
normal
)
...
...
@@ -538,8 +548,19 @@ private extension YHResourceViewController {
extension
YHResourceViewController
:
YHCustomSearchViewDelegate
{
func
searchView
(
_
searchView
:
YHCustomSearchView
,
didSearchWithText
text
:
String
?)
{
viewModel
.
searchKeyword
=
text
getData
()
// 取消之前的延迟任务
searchWorkItem
?
.
cancel
()
// 创建新的延迟任务
let
workItem
=
DispatchWorkItem
{
[
weak
self
]
in
self
?
.
viewModel
.
searchKeyword
=
text
self
?
.
getData
()
}
searchWorkItem
=
workItem
// 1秒后执行
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
1.0
,
execute
:
workItem
)
}
func
searchViewDidBeginEditing
(
_
searchView
:
YHCustomSearchView
)
{
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/M/YHResourceListModel.swift
View file @
c0c1eadb
...
...
@@ -198,6 +198,13 @@ class YHResourceListModel: SmartCodable {
// MARK: - 资源分类模型
class
YHResourceCategory
:
SmartCodable
{
static
var
allCategory
:
YHResourceCategory
=
{
let
all
=
YHResourceCategory
()
all
.
name
=
"全部行业"
all
.
id
=
"-9999"
return
all
}()
required
init
()
{}
var
id
:
String
=
""
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/V/YHCustomSearchView.swift
View file @
c0c1eadb
...
...
@@ -43,6 +43,7 @@ class YHCustomSearchView: UIView {
textField
.
addTarget
(
self
,
action
:
#selector(
textFieldEditingDidBegin(_:)
)
,
for
:
.
editingDidBegin
)
textField
.
addTarget
(
self
,
action
:
#selector(
textFieldEditingDidEnd(_:)
)
,
for
:
.
editingDidEnd
)
textField
.
returnKeyType
=
.
search
textField
.
clearButtonMode
=
.
whileEditing
textField
.
attributedPlaceholder
=
NSAttributedString
.
init
(
string
:
"搜索企业名称、企业供需"
,
attributes
:
[
.
foregroundColor
:
UIColor
.
brandGrayColor6
,
.
font
:
UIFont
.
PFSC_R
(
ofSize
:
14
)])
return
textField
}()
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/V/YHResourceCategoryView.swift
View file @
c0c1eadb
...
...
@@ -186,15 +186,27 @@ extension YHResourceCategoryView: UICollectionViewDataSource, UICollectionViewDe
func
collectionView
(
_
collectionView
:
UICollectionView
,
didSelectItemAt
indexPath
:
IndexPath
)
{
let
category
=
categories
[
indexPath
.
item
]
// 切换选中状态(支持多选)
if
let
index
=
selectedCategories
.
firstIndex
(
where
:
{
$0
.
id
==
category
.
id
})
{
// 如果已选中,则取消选中
selectedCategories
.
remove
(
at
:
index
)
if
category
.
id
==
YHResourceCategory
.
allCategory
.
id
{
// 全部行业的处理逻辑
if
selectedCategories
.
contains
(
where
:
{
$0
.
id
==
YHResourceCategory
.
allCategory
.
id
})
{
selectedCategories
.
removeAll
()
}
else
{
selectedCategories
=
[
category
]
}
}
else
{
// 如果未选中,则添加到选中列表
selectedCategories
.
append
(
category
)
// 其他行业的处理逻辑
selectedCategories
.
removeAll
(
where
:
{
$0
.
id
==
YHResourceCategory
.
allCategory
.
id
})
// 原有的切换逻辑
// 切换选中状态(支持多选)
if
let
index
=
selectedCategories
.
firstIndex
(
where
:
{
$0
.
id
==
category
.
id
})
{
// 如果已选中,则取消选中
selectedCategories
.
remove
(
at
:
index
)
}
else
{
// 如果未选中,则添加到选中列表
selectedCategories
.
append
(
category
)
}
}
// 刷新UI
collectionView
.
reloadData
()
...
...
@@ -279,14 +291,14 @@ class YHResourceCategoryCell: UICollectionViewCell {
}
func
configure
(
with
category
:
YHResourceCategory
,
isSelected
:
Bool
)
{
// 设置图标(如果有)
if
!
category
.
icon
.
isEmpty
{
iconLabel
.
text
=
category
.
icon
iconLabel
.
isHidden
=
false
}
else
{
iconLabel
.
isHidden
=
true
}
//
// 设置图标(如果有)
//
if !category.icon.isEmpty {
//
iconLabel.text = category.icon
//
iconLabel.isHidden = false
//
} else {
//
iconLabel.isHidden = true
//
}
iconLabel
.
isHidden
=
true
titleLabel
.
text
=
category
.
name
if
isSelected
{
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/VM/YHResourceViewModel.swift
View file @
c0c1eadb
...
...
@@ -54,7 +54,8 @@ class YHResourceViewModel: NSObject {
"page_size"
:
pageSize
,
"type"
:
currentType
==
.
service
?
1
:
2
// 1-服务 2-需求
]
// 如果包含全部行业就移除
selectedCategories
.
removeAll
(
where
:
{
$0
.
id
==
YHResourceCategory
.
allCategory
.
id
})
// 添加分类筛选(多选)- 转为Int数组
if
!
selectedCategories
.
isEmpty
{
let
categoryIds
=
selectedCategories
.
compactMap
{
Int
(
$0
.
id
)
}
...
...
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