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