diff --git a/DarockBili.xcodeproj/project.pbxproj b/DarockBili.xcodeproj/project.pbxproj index 39876e261..309a4c930 100644 --- a/DarockBili.xcodeproj/project.pbxproj +++ b/DarockBili.xcodeproj/project.pbxproj @@ -1371,7 +1371,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBili.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 547; + CURRENT_PROJECT_VERSION = 554; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -1416,7 +1416,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBili.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 547; + CURRENT_PROJECT_VERSION = 554; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -1458,7 +1458,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 547; + CURRENT_PROJECT_VERSION = 554; DEVELOPMENT_ASSET_PATHS = "\"DarockBili Watch App/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -1490,7 +1490,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 547; + CURRENT_PROJECT_VERSION = 554; DEVELOPMENT_ASSET_PATHS = "\"DarockBili Watch App/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -1643,7 +1643,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 547; + CURRENT_PROJECT_VERSION = 554; DEVELOPMENT_ASSET_PATHS = "\"DarockBili Watch App/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -1675,7 +1675,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 547; + CURRENT_PROJECT_VERSION = 554; DEVELOPMENT_ASSET_PATHS = "\"DarockBili Watch App/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -1707,7 +1707,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 547; + CURRENT_PROJECT_VERSION = 554; DEVELOPMENT_TEAM = B57D8PP775; INFOPLIST_KEY_CFBundleDisplayName = DarockBili; MARKETING_VERSION = 1.0.0; @@ -1723,7 +1723,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 547; + CURRENT_PROJECT_VERSION = 554; DEVELOPMENT_TEAM = B57D8PP775; INFOPLIST_KEY_CFBundleDisplayName = DarockBili; MARKETING_VERSION = 1.0.0; diff --git a/Localizable.xcstrings b/Localizable.xcstrings index 5ae0ba673..f2adac79d 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -190,21 +190,7 @@ } }, "%lld" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "%lld" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "%lld" - } - } - } + "extractionState" : "stale" }, "%lld / %lld" : { "localizations" : { @@ -253,6 +239,9 @@ } } } + }, + "+86" : { + }, "114" : { "localizations" : { @@ -978,278 +967,6 @@ } } }, - "DarockID.account" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Account" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "帐户" - } - } - } - }, - "DarockID.code.unmatch" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Verification Code does not match" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "验证码不匹配" - } - } - } - }, - "DarockID.email" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Email" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "邮箱" - } - } - } - }, - "DarockID.feedback-without-logging-in" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Report without logging in..." - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "在不登录的情况下反馈…" - } - } - } - }, - "DarockID.incorrect" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Passsword or Account Incorrect" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "帐户或密码不正确" - } - } - } - }, - "DarockID.login" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Login" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "登录" - } - } - } - }, - "DarockID.login.title" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Login with Darock ID" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "登录Darock通行证" - } - } - } - }, - "DarockID.password" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Password" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "密码" - } - } - } - }, - "DarockID.password.confirm" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Confirm Password" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "确认密码" - } - } - } - }, - "DarockID.password.unmatch" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Password does not match" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "密码不匹配" - } - } - } - }, - "DarockID.register" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Register" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "注册" - } - } - } - }, - "DarockID.register.success" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Successfully Registered" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "注册成功" - } - } - } - }, - "DarockID.register.title" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Register Darock ID" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "注册 Darock 通行证" - } - } - } - }, - "DarockID.unable-to-connect" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Cannot connect to Darock server" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "无法连接至Darock服务器" - } - } - } - }, - "DarockID.verification-code" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Verification Code" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "验证码" - } - } - } - }, - "DarockID.verification-code.send" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Send Verification Code" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "发送验证码" - } - } - } - }, "Dignite" : { "localizations" : { "en" : { @@ -1282,23 +999,6 @@ } } }, - "Download.closing-in-3sec" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "This page will close in 3s" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "页面将于3秒后自动关闭" - } - } - } - }, "Download.finished.%lld" : { "localizations" : { "en" : { @@ -1827,23 +1527,6 @@ } } }, - "Feedback.nothing" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "No Feedback" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "没有反馈" - } - } - } - }, "fp" : { "localizations" : { "en" : { @@ -2164,94 +1847,70 @@ } } }, - "login.captchasucc" : { + "Login" : { "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Captcha Completed" - } - }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "人机验证已完成" + "value" : "登录" } } } }, - "login.code" : { + "Login.scan" : { "localizations" : { "en" : { "stringUnit" : { "state" : "translated", - "value" : "Verification Code" + "value" : "Scan to Login" } }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "验证码" + "value" : "扫描以登录" } } } }, - "login.codesent" : { + "Login.scanned" : { "localizations" : { "en" : { "stringUnit" : { "state" : "translated", - "value" : "Verification Code Sent" + "value" : "Scanned" } }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "验证码已发送" + "value" : "已扫描" } } } }, - "login.first" : { + "Login.step1.phone-number" : { "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "First: Phone Info" - } - }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "第一步: 手机号信息" + "value" : "电话号码" } } } }, - "login.getcode" : { + "Login.step1.title" : { "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Get Code" - } - }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "获取验证码" + "value" : "手机号" } } } }, - "login.goonver" : { + "Login.step2.CAPTCHA" : { "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Start Captcha" - } - }, "zh-Hans" : { "stringUnit" : { "state" : "translated", @@ -2260,118 +1919,72 @@ } } }, - "login.login" : { + "Login.step2.captcha-first" : { "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Login" - } - }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "登录" + "value" : "先进行人机验证" } } } }, - "login.phonearea" : { + "Login.step2.code" : { "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Phone Area Code" - } - }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "国际冠码" + "value" : "验证码" } } } }, - "login.phonemunber" : { - "extractionState" : "stale", + "Login.step2.code.empty" : { "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Phone Number" - } - }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "手机号" + "value" : "手机号不得为空" } } } }, - "login.phonenumber" : { - - }, - "Login.scan" : { + "Login.step2.code.get" : { "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Scan to Login" - } - }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "扫描以登录" + "value" : "获取验证码" } } } }, - "Login.scanned" : { + "Login.step2.code.sent" : { "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Scanned" - } - }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "已扫描" + "value" : "已发送验证码" } } } }, - "login.second" : { + "Login.step2.title" : { "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Second: Captcha" - } - }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "第二步: 人机验证" + "value" : "验证" } } } }, - "login.third" : { + "Login.step3.title" : { "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Third: Verification Code" - } - }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "第三步: 验证码" + "value" : "登录" } } } @@ -2536,23 +2149,6 @@ } } }, - "Moments.live" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "started broadcasting" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "直播了" - } - } - } - }, "Moments.requires-login" : { "localizations" : { "en" : { @@ -2569,23 +2165,6 @@ } } }, - "Moments.upload-video" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : " · Uploaded Video" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : " · 投稿了视频" - } - } - } - }, "name" : { "localizations" : { "en" : { @@ -2794,40 +2373,6 @@ } } }, - "Player.third-party" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Third-party Player" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "自定义播放器" - } - } - } - }, - "Player.third-party.description" : { - "extractionState" : "stale", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Third-party Player offers more features, but it may shorten battery life" - } - }, - "zh-Hans" : { - "stringUnit" : { - "state" : "translated", - "value" : "自定义播放器拥有更多功能,但续航可能会有所缩短" - } - } - } - }, "Screen-time.daily-average" : { "localizations" : { "en" : { diff --git a/MeowBili/Others/LoginView.swift b/MeowBili/Others/LoginView.swift index 7ca90ae2d..5f1fa037c 100644 --- a/MeowBili/Others/LoginView.swift +++ b/MeowBili/Others/LoginView.swift @@ -54,143 +54,133 @@ struct LoginView: View { @State var userList2: [Any] = [] @State var userList3: [Any] = [] @State var userList4: [Any] = [] + @State var currentStep = 1 var body: some View { TabView { -// ScrollView { -// if qrImage != nil { -// ZStack { -// VStack { -// Image(uiImage: UIImage(cgImage: qrImage!)) -// .resizable() -// .frame(width: 140, height: 140) -// .blur(radius: isScanned ? 8 : 0) -// Text("Login.scan") -// .bold() -// } -// if isScanned { -// Text("Login.scanned") -// .font(.title2) -// //.foregroundColor(.white) -// } -// } -// } else { -// ProgressView() -// } -// } -// .tag(0) -// .onAppear { -// userList1 = UserDefaults.standard.array(forKey: "userList1") ?? [] -// userList2 = UserDefaults.standard.array(forKey: "userList2") ?? [] -// userList3 = UserDefaults.standard.array(forKey: "userList3") ?? [] -// userList4 = UserDefaults.standard.array(forKey: "userList4") ?? [] -// let headers: HTTPHeaders = [ -// "User-Agent": "Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" -// ] -// DarockKit.Network.shared.requestJSON("https://passport.bilibili.com/x/passport-login/web/qrcode/generate", headers: headers) { respJson, isSuccess in -// if isSuccess { -// let qrUrl = respJson["data"]["url"].string!.replacingOccurrences(of: "\\u0026", with: "&") -// debugPrint(qrUrl) -// if let image = EFQRCode.generate(for: qrUrl) { -// qrImage = image -// } -// qrKey = respJson["data"]["qrcode_key"].string! -// Timer.scheduledTimer(withTimeInterval: 2.0, repeats: true) { timer in -// qrTimer = timer -// DarockKit.Network.shared.requestJSON("https://passport.bilibili.com/x/passport-login/web/qrcode/poll?qrcode_key=\(qrKey)", headers: headers) { respJson, isSuccess in -// if respJson["data"]["code"].int == 86090 { -// isScanned = true -// } else if respJson["data"]["code"].int == 0 { -// timer.invalidate() -// debugPrint(respJson) -// let respUrl = respJson["data"]["url"].string! -// dedeUserID = String(respUrl.split(separator: "DedeUserID=")[1].split(separator: "&")[0]) -// dedeUserID__ckMd5 = String(respUrl.split(separator: "DedeUserID__ckMd5=")[1].split(separator: "&")[0]) -// sessdata = String(respUrl.split(separator: "SESSDATA=")[1].split(separator: "&")[0]) -// biliJct = String(respUrl.split(separator: "bili_jct=")[1].split(separator: "&")[0]) -// userList1.append(dedeUserID) -// userList2.append(dedeUserID__ckMd5) -// userList3.append(sessdata) -// userList4.append(biliJct) -// UserDefaults.standard.set(userList1, forKey: "userList1") -// UserDefaults.standard.set(userList2, forKey: "userList2") -// UserDefaults.standard.set(userList3, forKey: "userList3") -// UserDefaults.standard.set(userList4, forKey: "userList4") -// dismiss() -// } -// -// } -// } -// } -// } -// } -// .onDisappear { -// if qrTimer != nil { -// qrTimer!.invalidate() -// } -// } - //--SMS Login-- - List { - Section { - TextField("login.phonearea", text: $phoneCode) - .autocorrectionDisabled() - .textInputAutocapitalization(.never) - TextField("login.phonenumber", text: $accountInput) - .autocorrectionDisabled() - .textInputAutocapitalization(.never) - } header: { - Text("login.first") - } - Section { - Button(action: { - UIApplication.shared.open(URL(string: "https://darock.top/geetest?gt=\(gt)&challenge=\(challenge)")!) - }, label: { - Text(validate == "" ? "login.goonver" : "login.captchasucc") - .bold() - }) - .disabled(validate != "") - } header: { - Text("login.second") - } - Section { - Button(action: { - let headers: HTTPHeaders = [ - "Host": "passport.bilibili.com", - "Origin": "https://www.bilibili.com", - "Referer": "https://www.bilibili.com/", - "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15", - "Cookie": "browser_resolution=1580-497; FEED_LIVE_VERSION=V8; buvid4=818BA302-8EAC-0630-67AB-BB978A5797AF60982-023042618-ho21%2BqF6LZokzAShrGptM4EHZm2TE4%2FTXmfZyPpzfCnLuUmUckb8wg%3D%3D; buvid_fp=5a716236853dd1e737d439882c685594; header_theme_version=CLOSE; home_feed_column=5; _uuid=15B5A2103-BBC2-9109A-7458-6410C3CF101028B94909infoc; b_lsid=CCF71993_18991563B31; b_ut=7; i-wanna-go-back=-1; innersign=0; b_nut=1690360493; buvid3=6481EDF5-10C43-9593-251E-89210B4A1C10A193894infoc" - ] - AF.request("https://passport.bilibili.com/x/passport-login/web/sms/send", method: .post, parameters: BiliSmsCodePost(cid: Int(phoneCode)!, tel: Int(accountInput)!, token: loginToken, challenge: challenge, validate: validate, seccode: seccode), headers: headers).response { response in - debugPrint(response) - let json = try! JSON(data: response.data!) - if let token = json["data"]["captcha_key"].string { - smsLoginToken = token - } else { - AlertKitAPI.present(title: "发送验证码失败", subtitle: "请从第二步开始重试", icon: .error, style: .iOS17AppleMusic, haptic: .error) - let headers: HTTPHeaders = [ - "User-Agent": "Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" - ] - DarockKit.Network.shared.requestJSON("https://passport.bilibili.com/x/passport-login/captcha?source=main_web", headers: headers) { respJson, isSuccess in - if isSuccess { - challenge = respJson["data"]["geetest"]["challenge"].string! - gt = respJson["data"]["geetest"]["gt"].string! - loginToken = respJson["data"]["token"].string! + ScrollView { + VStack { + GroupBox { + VStack(alignment: .leading) { + Label("Login.step1.title", systemImage: "1.circle") + .bold() + // .foregroundStyle(currentStep == 1 ? Color.accentColor : Color.primary) + HStack { + /* Picker("+\(phoneCode)", selection: $phoneCode) { + ForEach(callNations.indices) { codeIndex in + Text(callNations[codeIndex]).tag(callCodes[codeIndex]) + } + } */ + Text("+86") + TextField("Login.step1.phone-number", text: $accountInput) + .keyboardType(.phonePad) + .onChange(of: accountInput, perform: { value in + if !passwdInput.isEmpty { + currentStep = 3 + } else if !accountInput.isEmpty { + currentStep = 2 + } else { + currentStep = 1 + } + }) + } + } + } + GroupBox { + VStack(alignment: .leading) { + Label("Login.step2.title", systemImage: "2.circle") + .bold() + // .foregroundStyle(currentStep == 2 ? Color.accentColor : Color.primary) + HStack { + TextField(validate.isEmpty ? "Login.step2.captcha-first" : "Login.step2.code", text: $passwdInput) + .disabled(validate.isEmpty) + .keyboardType(.numberPad) + .onChange(of: passwdInput, perform: { value in + if !passwdInput.isEmpty { + currentStep = 3 + } else if !accountInput.isEmpty { + currentStep = 2 + } else { + currentStep = 1 + } + print(currentStep) + }) + Button(action: { + if validate.isEmpty { + UIApplication.shared.open(URL(string: "https://darock.top/geetest?gt=\(gt)&challenge=\(challenge)")!) + } else { + let headers: HTTPHeaders = [ + "Host": "passport.bilibili.com", + "Origin": "https://www.bilibili.com", + "Referer": "https://www.bilibili.com/", + "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15", + "Cookie": "browser_resolution=1580-497; FEED_LIVE_VERSION=V8; buvid4=818BA302-8EAC-0630-67AB-BB978A5797AF60982-023042618-ho21%2BqF6LZokzAShrGptM4EHZm2TE4%2FTXmfZyPpzfCnLuUmUckb8wg%3D%3D; buvid_fp=5a716236853dd1e737d439882c685594; header_theme_version=CLOSE; home_feed_column=5; _uuid=15B5A2103-BBC2-9109A-7458-6410C3CF101028B94909infoc; b_lsid=CCF71993_18991563B31; b_ut=7; i-wanna-go-back=-1; innersign=0; b_nut=1690360493; buvid3=6481EDF5-10C43-9593-251E-89210B4A1C10A193894infoc" + ] + AF.request("https://passport.bilibili.com/x/passport-login/web/sms/send", method: .post, parameters: BiliSmsCodePost(cid: Int(phoneCode)!, tel: Int(accountInput)!, token: loginToken, challenge: challenge, validate: validate, seccode: seccode), headers: headers).response { response in + debugPrint(response) + let json = try! JSON(data: response.data!) + smsLoginToken = json["data"]["captcha_key"].string! + } } - } - validate = "" - seccode = "" + }, label: { + if validate.isEmpty { + Text("Login.step2.CAPTCHA") + .foregroundStyle(!validate.isEmpty && accountInput.isEmpty ? Color.secondary : Color.accentColor) + } else if smsLoginToken.isEmpty { + if accountInput.isEmpty { + Text("Login.step2.code.empty") + .foregroundStyle(.secondary) + } else { + Text("Login.step2.code.get") + .foregroundStyle(Color.accentColor) + } + } else { + Text("Login.step2.code.sent") + .foregroundStyle(.secondary) + } + }) + .disabled(!validate.isEmpty && accountInput.isEmpty) + } + } - }, label: { - Text(validate == "" ? "login.getcode" : "login.codesent") - }) - .disabled(accountInput == "" || validate == "" || smsLoginToken != "") - TextField("login.code", text: $passwdInput) - } header: { - Text("login.third") - } - Section { + } + .disabled(currentStep < 2) + .foregroundStyle(currentStep >= 2 ? Color.primary : Color.secondary) + /* Section { + Button(action: { + UIApplication.shared.open(URL(string: "https://darock.top/geetest?gt=\(gt)&challenge=\(challenge)")!) + }, label: { + Text(validate == "" ? "login.goonver" : "login.captchasucc") + .bold() + }) + .disabled(validate != "") + } header: { + Text("login.second") + } + Section { + Button(action: { + let headers: HTTPHeaders = [ + "Host": "passport.bilibili.com", + "Origin": "https://www.bilibili.com", + "Referer": "https://www.bilibili.com/", + "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15", + "Cookie": "browser_resolution=1580-497; FEED_LIVE_VERSION=V8; buvid4=818BA302-8EAC-0630-67AB-BB978A5797AF60982-023042618-ho21%2BqF6LZokzAShrGptM4EHZm2TE4%2FTXmfZyPpzfCnLuUmUckb8wg%3D%3D; buvid_fp=5a716236853dd1e737d439882c685594; header_theme_version=CLOSE; home_feed_column=5; _uuid=15B5A2103-BBC2-9109A-7458-6410C3CF101028B94909infoc; b_lsid=CCF71993_18991563B31; b_ut=7; i-wanna-go-back=-1; innersign=0; b_nut=1690360493; buvid3=6481EDF5-10C43-9593-251E-89210B4A1C10A193894infoc" + ] + AF.request("https://passport.bilibili.com/x/passport-login/web/sms/send", method: .post, parameters: BiliSmsCodePost(cid: Int(phoneCode)!, tel: Int(accountInput)!, token: loginToken, challenge: challenge, validate: validate, seccode: seccode), headers: headers).response { response in + debugPrint(response) + let json = try! JSON(data: response.data!) + smsLoginToken = json["data"]["captcha_key"].string! + } + }, label: { + Text(validate == "" ? "login.getcode" : "login.codesent") + }) + .disabled(accountInput == "" || validate == "" || smsLoginToken != "") + //SecureField no need! by Linecom-Lik + TextField("login.code", text: $passwdInput) + } header: { + Text("login.third") + } */ Button(action: { AF.request("https://passport.bilibili.com/x/passport-login/web/login/sms", method: .post, parameters: BiliLoginPost(cid: Int(phoneCode)!, tel: Int(accountInput)!, code: Int(passwdInput)!, captcha_key: smsLoginToken)).response { response in let data = response.data @@ -219,11 +209,22 @@ struct LoginView: View { } } }, label: { - Text("login.login") + GroupBox { + HStack { + Label("Login.step3.title", systemImage: "3.circle") + .bold() + //.foregroundStyle(currentStep == 3 ? Color.accentColor : Color.primary) + Spacer() + Image(systemName: "arrow.up.right.square") + } + } }) - .disabled(accountInput == "" || passwdInput == "") + .disabled(currentStep < 3) + .foregroundStyle(currentStep >= 3 ? Color.primary : Color.secondary) } } + .navigationTitle("Login") + .padding() .tag(1) .onOpenURL { url in let surl = url.absoluteString.urlDecoded() @@ -274,3 +275,389 @@ struct LoginView_Previews: PreviewProvider { LoginView() } } + +public let callNations = [ + "Afghanistan", + "Albania", + "Algeria", + "Andorra", + "Angola", + "Antigua and Barbuda", + "Argentina", + "Armenia", + "Australia", + "Austria", + "Azerbaijan", + "Bahamas", + "Bahrain", + "Bangladesh", + "Barbados", + "Belarus", + "Belgium", + "Belize", + "Benin", + "Bhutan", + "Bolivia", + "Bosnia and Herzegovina", + "Botswana", + "Brazil", + "Brunei", + "Bulgaria", + "Burkina Faso", + "Burundi", + "Cabo Verde (Cape Verde)", + "Cambodia", + "Cameroon", + "Canada", + "Central African Republic", + "Chad", + "Chile", + "China mainland", + "Colombia", + "Comoros", + "Congo, Democratic Republic of the", + "Congo, Republic of the", + "Costa Rica", + "Croatia", + "Cuba", + "Cyprus", + "Czech Republic", + "Denmark", + "Djibouti", + "Dominica", + "Dominican Republic", + "East Timor (Timor-Leste)", + "Ecuador", + "Egypt", + "El Salvador", + "Equatorial Guinea", + "Eritrea", + "Estonia", + "Eswatini (Swaziland)", + "Ethiopia", + "Fiji", + "Finland", + "France", + "Gabon", + "Gambia", + "Georgia", + "Germany", + "Ghana", + "Greece", + "Grenada", + "Guatemala", + "Guinea", + "Guinea-Bissau", + "Guyana", + "Haiti", + "Honduras", + "Hungary", + "Iceland", + "India", + "Indonesia", + "Iran", + "Iraq", + "Ireland", + "Israel", + "Italy", + "Jamaica", + "Japan", + "Jordan", + "Kazakhstan", + "Kenya", + "Kiribati", + "Korea, North (North Korea)", + "Korea, South (South Korea)", + "Kosovo", + "Kuwait", + "Kyrgyzstan", + "Laos", + "Latvia", + "Lebanon", + "Lesotho", + "Liberia", + "Libya", + "Liechtenstein", + "Lithuania", + "Luxembourg", + "Madagascar", + "Malawi", + "Malaysia", + "Maldives", + "Mali", + "Malta", + "Marshall Islands", + "Mauritania", + "Mauritius", + "Mexico", + "Micronesia", + "Moldova", + "Monaco", + "Mongolia", + "Montenegro", + "Morocco", + "Mozambique", + "Myanmar (Burma)", + "Namibia", + "Nauru", + "Nepal", + "Netherlands", + "New Zealand", + "Nicaragua", + "Niger", + "Nigeria", + "North Macedonia (formerly Macedonia)", + "Norway", + "Oman", + "Pakistan", + "Palau", + "Palestine State", + "Panama", + "Papua New Guinea", + "Paraguay", + "Peru", + "Philippines", + "Poland", + "Portugal", + "Qatar", + "Romania", + "Russia", + "Rwanda", + "Saint Kitts and Nevis", + "Saint Lucia", + "Saint Vincent and the Grenadines", + "Samoa", + "San Marino", + "Sao Tome and Principe", + "Saudi Arabia", + "Senegal", + "Serbia", + "Seychelles", + "Sierra Leone", + "Singapore", + "Slovakia", + "Slovenia", + "Solomon Islands", + "Somalia", + "South Africa", + "South Sudan", + "Spain", + "Sri Lanka", + "Sudan", + "Suriname", + "Sweden", + "Switzerland", + "Syria", + "Taiwan", + "Tajikistan", + "Tanzania", + "Thailand", + "Togo", + "Tonga", + "Trinidad and Tobago", + "Tunisia", + "Turkey", + "Turkmenistan", + "Tuvalu", + "Uganda", + "Ukraine", + "United Arab Emirates", + "United Kingdom", + "United States of America", + "Uruguay", + "Uzbekistan", + "Vanuatu", + "Vatican City" +]; + +public let callCodes = [ + "93", + "355", + "213", + "376", + "244", + "1-268", + "54", + "374", + "61", + "43", + "994", + "1-242", + "973", + "880", + "1-246", + "375", + "32", + "501", + "229", + "975", + "591", + "387", + "267", + "55", + "673", + "359", + "226", + "257", + "238", + "855", + "237", + "1", + "236", + "235", + "56", + "86", + "57", + "269", + "243", + "242", + "506", + "385", + "53", + "357", + "420", + "45", + "253", + "1", + "670", + "593", + "20", + "503", + "240", + "291", + "372", + "268", + "251", + "679", + "358", + "33", + "241", + "220", + "995", + "49", + "233", + "30", + "1", + "502", + "224", + "245", + "592", + "509", + "504", + "36", + "354", + "91", + "62", + "98", + "964", + "353", + "972", + "39", + "81", + "962", + "7", + "254", + "686", + "850", + "82", + "383", + "965", + "996", + "856", + "371", + "961", + "266", + "231", + "218", + "423", + "370", + "352", + "261", + "265", + "60", + "960", + "223", + "356", + "692", + "222", + "230", + "52", + "691", + "373", + "377", + "976", + "382", + "212", + "258", + "95", + "264", + "674", + "977", + "31", + "64", + "505", + "227", + "234", + "389", + "47", + "968", + "92", + "680", + "970", + "507", + "675", + "595", + "51", + "63", + "48", + "351", + "974", + "40", + "7", + "250", + "378", + "239", + "966", + "221", + "381", + "248", + "232", + "65", + "421", + "386", + "677", + "252", + "27", + "211", + "34", + "94", + "249", + "597", + "46", + "41", + "963", + "886", + "992", + "255", + "66", + "228", + "676", + "1-868", + "216", + "90", + "993", + "688", + "256", + "380", + "971", + "44", + "598", + "998", + "678", + "379", + "58", + "84", + "967", + "260", + "263" +];