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
5fd88a95
Commit
5fd88a95
authored
Feb 23, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// 退出登录
parent
936d9e9e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
3 deletions
+57
-3
YHLoginManager.swift
...axy/Classes/Modules/Login(登录)/Server/YHLoginManager.swift
+15
-0
YHLoginViewModel.swift
...alaxy/Classes/Modules/Login(登录)/VM/YHLoginViewModel.swift
+1
-2
YHMySettingViewController.swift
...lasses/Modules/Mine(我的)/C/YHMySettingViewController.swift
+27
-1
YHMyViewController.swift
...alaxy/Classes/Modules/Mine(我的)/C/YHMyViewController.swift
+8
-0
YHUserInfoHeaderView.swift
...axy/Classes/Modules/Mine(我的)/V/YHUserInfoHeaderView.swift
+6
-0
No files found.
galaxy/galaxy/Classes/Modules/Login(登录)/Server/YHLoginManager.swift
View file @
5fd88a95
...
@@ -23,6 +23,21 @@ class YHLoginManager: NSObject {
...
@@ -23,6 +23,21 @@ class YHLoginManager: NSObject {
return
false
return
false
}
}
// 保存用户数据到本地
func
saveLocalUserInfo
()
{
if
let
userModel
=
userModel
{
UserDefaults
.
standard
.
set
(
userModel
.
toDictionary
(),
forKey
:
YhConstant
.
KLoginedInfoKey
)
UserDefaults
.
standard
.
synchronize
()
}
}
// 清空用户数据
func
clearUserInfo
()
{
userModel
=
nil
UserDefaults
.
standard
.
set
(
nil
,
forKey
:
YhConstant
.
KLoginedInfoKey
)
UserDefaults
.
standard
.
synchronize
()
}
func
loadLocalUserInfoData
()
{
func
loadLocalUserInfoData
()
{
let
dic
=
UserDefaults
.
standard
.
value
(
forKey
:
YhConstant
.
KLoginedInfoKey
)
let
dic
=
UserDefaults
.
standard
.
value
(
forKey
:
YhConstant
.
KLoginedInfoKey
)
...
...
galaxy/galaxy/Classes/Modules/Login(登录)/VM/YHLoginViewModel.swift
View file @
5fd88a95
...
@@ -75,8 +75,7 @@ extension YHLoginViewModel {
...
@@ -75,8 +75,7 @@ extension YHLoginViewModel {
YHLoginManager
.
shared
.
userModel
=
resultModel
YHLoginManager
.
shared
.
userModel
=
resultModel
//数据保存到本地
//数据保存到本地
UserDefaults
.
standard
.
set
(
resultModel
.
toDictionary
(),
forKey
:
YhConstant
.
KLoginedInfoKey
)
YHLoginManager
.
shared
.
saveLocalUserInfo
()
UserDefaults
.
standard
.
synchronize
()
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
didLoginSuccessNotifiction
,
object
:
nil
)
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
didLoginSuccessNotifiction
,
object
:
nil
)
...
...
galaxy/galaxy/Classes/Modules/Mine(我的)/C/YHMySettingViewController.swift
View file @
5fd88a95
...
@@ -25,6 +25,17 @@ class YHMySettingViewController: YHBaseViewController, ConstraintRelatableTarget
...
@@ -25,6 +25,17 @@ class YHMySettingViewController: YHBaseViewController, ConstraintRelatableTarget
return
tableView
return
tableView
}()
}()
lazy
var
logoutBtn
:
UIButton
=
{
let
btn
=
UIButton
()
btn
.
setTitle
(
"退出登录"
.
local
,
for
:
.
normal
)
btn
.
titleLabel
?
.
font
=
UIFont
.
PFSC_M
(
ofSize
:
16
)
btn
.
setTitleColor
(
UIColor
(
hexString
:
"#313131"
),
for
:
.
normal
)
btn
.
backgroundColor
=
.
contentBkgColor
btn
.
layer
.
cornerRadius
=
6.0
btn
.
addTarget
(
self
,
action
:
#selector(
logout
)
,
for
:
.
touchUpInside
)
return
btn
}()
lazy
var
items
:
[
PersonalModuleItem
]
=
{
lazy
var
items
:
[
PersonalModuleItem
]
=
{
return
[
PersonalModuleItem
(
title
:
"调整颜色"
.
local
.
local
),
return
[
PersonalModuleItem
(
title
:
"调整颜色"
.
local
.
local
),
PersonalModuleItem
(
title
:
"深色模式"
.
local
),
PersonalModuleItem
(
title
:
"深色模式"
.
local
),
...
@@ -43,11 +54,26 @@ class YHMySettingViewController: YHBaseViewController, ConstraintRelatableTarget
...
@@ -43,11 +54,26 @@ class YHMySettingViewController: YHBaseViewController, ConstraintRelatableTarget
self
.
gk_navTitle
=
"设置"
.
local
self
.
gk_navTitle
=
"设置"
.
local
self
.
view
.
backgroundColor
=
.
white
self
.
view
.
backgroundColor
=
.
white
view
.
addSubview
(
tableView
)
view
.
addSubview
(
tableView
)
view
.
addSubview
(
logoutBtn
)
tableView
.
snp
.
makeConstraints
{
make
in
tableView
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalToSuperview
()
.
offset
(
k_Height_NavigationtBarAndStatuBar
)
make
.
top
.
equalToSuperview
()
.
offset
(
k_Height_NavigationtBarAndStatuBar
)
make
.
left
.
right
.
bottom
.
equalToSuperview
()
make
.
left
.
right
.
equalToSuperview
()
make
.
bottom
.
equalTo
(
logoutBtn
.
snp
.
top
)
.
offset
(
-
30
)
}
logoutBtn
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalToSuperview
()
.
offset
(
20
)
make
.
right
.
equalToSuperview
()
.
offset
(
-
20
)
make
.
height
.
equalTo
(
48.0
)
make
.
bottom
.
equalToSuperview
()
.
offset
(
-
30
)
}
}
}
}
@objc
func
logout
()
{
YHLoginManager
.
shared
.
clearUserInfo
()
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
didLoginoutSuccessNotifiction
,
object
:
nil
)
}
}
}
extension
YHMySettingViewController
:
UITableViewDelegate
,
UITableViewDataSource
{
extension
YHMySettingViewController
:
UITableViewDelegate
,
UITableViewDataSource
{
...
...
galaxy/galaxy/Classes/Modules/Mine(我的)/C/YHMyViewController.swift
View file @
5fd88a95
...
@@ -80,6 +80,9 @@ class YHMyViewController: YHBaseViewController, ConstraintRelatableTarget {
...
@@ -80,6 +80,9 @@ class YHMyViewController: YHBaseViewController, ConstraintRelatableTarget {
}
}
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
loginSuccess
)
,
name
:
YhConstant
.
YhNotification
.
didLoginSuccessNotifiction
,
object
:
nil
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
loginSuccess
)
,
name
:
YhConstant
.
YhNotification
.
didLoginSuccessNotifiction
,
object
:
nil
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
logoutSuccess
)
,
name
:
YhConstant
.
YhNotification
.
didLoginoutSuccessNotifiction
,
object
:
nil
)
}
}
}
}
...
@@ -147,5 +150,10 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource {
...
@@ -147,5 +150,10 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource {
extension
YHMyViewController
{
extension
YHMyViewController
{
@objc
func
loginSuccess
()
{
@objc
func
loginSuccess
()
{
printLog
(
"登录成功,进行相应的 UI刷新操作"
)
printLog
(
"登录成功,进行相应的 UI刷新操作"
)
headerView
.
nickName
=
"Hi, 银河用户"
}
@objc
func
logoutSuccess
()
{
headerView
.
nickName
=
"登录/注册"
}
}
}
}
galaxy/galaxy/Classes/Modules/Mine(我的)/V/YHUserInfoHeaderView.swift
View file @
5fd88a95
...
@@ -15,6 +15,12 @@ class YHUserInfoHeaderView: UIView {
...
@@ -15,6 +15,12 @@ class YHUserInfoHeaderView: UIView {
var
settingBlock
:(()
->
Void
)?
var
settingBlock
:(()
->
Void
)?
var
evaluateBlock
:(()
->
Void
)?
var
evaluateBlock
:(()
->
Void
)?
var
nickName
:
String
?
{
didSet
{
userNameLabel
.
text
=
nickName
}
}
private
lazy
var
avarImgView
:
UIImageView
=
{
private
lazy
var
avarImgView
:
UIImageView
=
{
...
...
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