重置密码
This commit is contained in:
parent
b12695d5bd
commit
d74f58ad0e
@ -8,39 +8,10 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
import Observation
|
import Observation
|
||||||
|
|
||||||
enum AuthScreen {
|
|
||||||
case login
|
|
||||||
case resetPassword
|
|
||||||
case register
|
|
||||||
}
|
|
||||||
|
|
||||||
struct LoginRootView: View {
|
|
||||||
@Environment(AppContext.self) var appContext: AppContext
|
|
||||||
@State private var authScreen = AuthScreen.login
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
Group {
|
|
||||||
switch self.authScreen {
|
|
||||||
case .login:
|
|
||||||
LoginView(authScreen: $authScreen)
|
|
||||||
case .resetPassword:
|
|
||||||
ResetPasswordRootView()
|
|
||||||
case .register:
|
|
||||||
EmptyView()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.onChange(of: self.authScreen) {
|
|
||||||
print("app auth screen changed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 登陆页面
|
// 登陆页面
|
||||||
struct LoginView: View {
|
struct LoginView: View {
|
||||||
@Environment(UserContext.self) var userContext: UserContext
|
@Environment(UserContext.self) var userContext: UserContext
|
||||||
@State private var authMethod: AuthMethod = .account
|
@State private var authMethod: AuthMethod = .account
|
||||||
@Binding var authScreen: AuthScreen
|
|
||||||
|
|
||||||
enum AuthMethod {
|
enum AuthMethod {
|
||||||
case token
|
case token
|
||||||
@ -90,7 +61,7 @@ struct LoginView: View {
|
|||||||
case .token:
|
case .token:
|
||||||
LoginTokenView()
|
LoginTokenView()
|
||||||
case .account:
|
case .account:
|
||||||
LoginAccountView(authScreen: $authScreen)
|
LoginAccountView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +72,6 @@ struct LoginView: View {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct LoginTokenView: View {
|
struct LoginTokenView: View {
|
||||||
@Environment(UserContext.self) var userContext: UserContext
|
@Environment(UserContext.self) var userContext: UserContext
|
||||||
@State private var token: String = ""
|
@State private var token: String = ""
|
||||||
@ -174,9 +144,10 @@ struct LoginTokenView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct LoginAccountView: View {
|
struct LoginAccountView: View {
|
||||||
|
@Environment(\.openWindow) private var openWindow
|
||||||
|
|
||||||
@Environment(UserContext.self) var userContext: UserContext
|
@Environment(UserContext.self) var userContext: UserContext
|
||||||
@Environment(AppContext.self) var appContext: AppContext
|
@Environment(AppContext.self) var appContext: AppContext
|
||||||
@Binding var authScreen: AuthScreen
|
|
||||||
|
|
||||||
@State private var username: String = ""
|
@State private var username: String = ""
|
||||||
@State private var password: String = ""
|
@State private var password: String = ""
|
||||||
@ -224,7 +195,7 @@ struct LoginAccountView: View {
|
|||||||
, alignment: .topLeading)
|
, alignment: .topLeading)
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
self.authScreen = .resetPassword
|
openWindow(id: "resetPassword")
|
||||||
} label: {
|
} label: {
|
||||||
Text("忘记密码?")
|
Text("忘记密码?")
|
||||||
.underline(true, color: .blue)
|
.underline(true, color: .blue)
|
||||||
|
|||||||
@ -15,7 +15,7 @@ struct RootView: View {
|
|||||||
if userContext.isLogined {
|
if userContext.isLogined {
|
||||||
NetworkView()
|
NetworkView()
|
||||||
} else {
|
} else {
|
||||||
LoginRootView()
|
LoginView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -90,6 +90,12 @@ struct punchnetApp: App {
|
|||||||
}
|
}
|
||||||
.defaultSize(width: 800, height: 500)
|
.defaultSize(width: 800, height: 500)
|
||||||
|
|
||||||
|
Window("重置密码", id: "resetPassword") {
|
||||||
|
ResetPasswordRootView()
|
||||||
|
.environment(self.userContext)
|
||||||
|
}
|
||||||
|
.defaultSize(width: 800, height: 500)
|
||||||
|
|
||||||
MenuBarExtra("punchnet", image: "logo_32") {
|
MenuBarExtra("punchnet", image: "logo_32") {
|
||||||
VStack {
|
VStack {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user