From 65664fdfd5f09447a71433f071cadb8abdbe112e Mon Sep 17 00:00:00 2001 From: Mark Chan <45706356+WindowsMEMZ@users.noreply.github.com> Date: Sat, 13 Jan 2024 23:18:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7=E7=AD=89?= =?UTF-8?q?=E7=BA=A7=E6=98=BE=E7=A4=BA=20(#71)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Updated user VIP & Level show * Removed phone login * Fix build issue * Fix UI Spacer --- DarockBili Watch App/Others/LoginView.swift | 186 +++++++++--------- .../PersonalCenter/UserDetailView.swift | 22 ++- 2 files changed, 108 insertions(+), 100 deletions(-) diff --git a/DarockBili Watch App/Others/LoginView.swift b/DarockBili Watch App/Others/LoginView.swift index 72d015086..38d814cef 100644 --- a/DarockBili Watch App/Others/LoginView.swift +++ b/DarockBili Watch App/Others/LoginView.swift @@ -112,103 +112,95 @@ struct LoginView: View { } //--SMS Login-- - List { - TextField("国际冠字码", text: $phoneCode) - .autocorrectionDisabled() - .textInputAutocapitalization(.never) - TextField("手机号", text: $accountInput) - .autocorrectionDisabled() - .textInputAutocapitalization(.never) - Button(action: { - let session = ASWebAuthenticationSession(url: URL(string: "https://darock.top/geetest?gt=\(gt)&challenge=\(challenge)")!, callbackURLScheme: "captcha") { callbackURL, _ in - if callbackURL != nil { - if callbackURL!.absoluteString.contains("callback") { - let str = callbackURL!.absoluteString.urlDecoded() - validate = String(str.split(separator: "?")[1].split(separator: "&")[0]) - seccode = String(str.split(separator: "&")[1]) - } - } - } - session.prefersEphemeralWebBrowserSession = true - session.start() - }, label: { - Text(validate == "" ? "进行人机验证" : "人机验证已完成") - .bold() - }) - .disabled(validate != "") - 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("获取验证码") - }) - .disabled(accountInput == "" || validate == "" || smsLoginToken != "") - SecureField("验证码", text: $passwdInput) - Section { - Button(action: { - if phoneCode == "375" && accountInput == "ASCDemo17245" && passwdInput == "Demo267&ac=*" { - dedeUserID = "3493279255497074" - dedeUserID__ckMd5 = "3dc9e007861d3264" - sessdata = "ee3fe1cd,1706077691,cce33*72iwtRb9aI-sowIE4Wjh_HSt2vFGveKTFChcptZbrn-nNBrz8oDVZVeB-gLx7z5bQXrYq8gQAASgA" - biliJct = "611b2f688b1145802c0e36b722a35234" - dismiss() - } else { - 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 - if data != nil { - let json = try! JSON(data: data!) - debugPrint(json) - if json["code"].int == 0 { - if json["data"]["status"].int == 0 { - debugPrint(response.response!.headers) - let setCookie = response.response!.headers["Set-Cookie"]! - dedeUserID = String(setCookie.split(separator: "DedeUserID=")[1].split(separator: ";")[0]) - dedeUserID__ckMd5 = String(setCookie.split(separator: "DedeUserID__ckMd5=")[1].split(separator: ";")[0]) - if setCookie.hasPrefix("SESSDATA") { - sessdata = String(setCookie.split(separator: "SESSDATA=")[0].split(separator: ";")[0]) - } else { - sessdata = String(setCookie.split(separator: "SESSDATA=")[1].split(separator: ";")[0]) - } - biliJct = String(setCookie.split(separator: "bili_jct=")[1].split(separator: ";")[0]) - dismiss() - } else if json["data"]["status"].int == 1006 { - - } else if json["data"]["status"].int == 1007 { - - } - } - } - } - } - }, label: { - Text("登录") - }) - .disabled(accountInput == "" || passwdInput == "") - } - } - .tag(1) - .onAppear { - 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! - } - } - } + //List { + // TextField("国际冠字码", text: $phoneCode) + // .autocorrectionDisabled() + // .textInputAutocapitalization(.never) + // TextField("手机号", text: $accountInput) + // .autocorrectionDisabled() + // .textInputAutocapitalization(.never) + // Button(action: { + // let session = ASWebAuthenticationSession(url: URL(string: "https://darock.top/geetest?gt=\(gt)&challenge=\(challenge)")!, callbackURLScheme: "captcha") { callbackURL, _ in + // if callbackURL != nil { + // if callbackURL!.absoluteString.contains("callback") { + // let str = callbackURL!.absoluteString.urlDecoded() + // validate = String(str.split(separator: "?")[1].split(separator: "&")[0]) + // seccode = String(str.split(separator: "&")[1]) + // } + // } + // } + // session.prefersEphemeralWebBrowserSession = true + // session.start() + // }, label: { + // Text(validate == "" ? "进行人机验证" : "人机验证已完成") + // .bold() + // }) + // .disabled(validate != "") + // 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("获取验证码") + // }) + // .disabled(accountInput == "" || validate == "" || smsLoginToken != "") + // SecureField("验证码", text: $passwdInput) + // Section { + // 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 + // if data != nil { + // let json = try! JSON(data: data!) + // debugPrint(json) + // if json["code"].int == 0 { + // if json["data"]["status"].int == 0 { + // debugPrint(response.response!.headers) + // let setCookie = response.response!.headers["Set-Cookie"]! + // dedeUserID = String(setCookie.split(separator: "DedeUserID=")[1].split(separator: ";")[0]) + // dedeUserID__ckMd5 = String(setCookie.split(separator: "DedeUserID__ckMd5=")[1].split(separator: ";")[0]) + // if setCookie.hasPrefix("SESSDATA") { + // sessdata = String(setCookie.split(separator: "SESSDATA=")[0].split(separator: ";")[0]) + // } else { + // sessdata = String(setCookie.split(separator: "SESSDATA=")[1].split(separator: ";")[0]) + // } + // biliJct = String(setCookie.split(separator: "bili_jct=")[1].split(separator: ";")[0]) + // dismiss() + // } else if json["data"]["status"].int == 1006 { + // + // } else if json["data"]["status"].int == 1007 { + // + // } + // } + // } + // } + // }, label: { + // Text("登录") + // }) + // .disabled(accountInput == "" || passwdInput == "") + // } + //} + //.tag(1) + //.onAppear { + // 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! + // } + // } + //} } } diff --git a/DarockBili Watch App/PersonalCenter/UserDetailView.swift b/DarockBili Watch App/PersonalCenter/UserDetailView.swift index 273b83dd6..03453221d 100644 --- a/DarockBili Watch App/PersonalCenter/UserDetailView.swift +++ b/DarockBili Watch App/PersonalCenter/UserDetailView.swift @@ -39,6 +39,7 @@ struct UserDetailView: View { @State var userSign = "" @State var followCount = -1 @State var fansCount = -1 + @State var vipLabel = "" @State var videos = [[String: String]]() @State var viewSelector: UserDetailViewPubsType = .video @State var articles = [[String: String]]() @@ -102,7 +103,7 @@ struct UserDetailView: View { .navigationTitle(username) .tag(1) } - SecondPageBase(officialType: $officialType, officialTitle: $officialTitle, userSign: $userSign) + SecondPageBase(officialType: $officialType, officialTitle: $officialTitle, userSign: $userSign, userLevel: $userLevel, vipLabel: $vipLabel) .tag(2) } .tabViewStyle(.verticalPage) @@ -113,7 +114,7 @@ struct UserDetailView: View { .offset(y: -10) .navigationTitle(username) .tag(1) - SecondPageBase(officialType: $officialType, officialTitle: $officialTitle, userSign: $userSign) + SecondPageBase(officialType: $officialType, officialTitle: $officialTitle, userSign: $userSign, userLevel: $userLevel, vipLabel: $vipLabel) .tag(2) } } @@ -144,7 +145,7 @@ struct UserDetailView: View { } .onAppear { let headers: HTTPHeaders = [ - "cookie": "SESSDATA=\(sessdata);", + "cookie": "SESSDATA=\(sessdata); buvid3=\(globalBuvid3);", "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" ] biliWbiSign(paramEncoded: "mid=\(uid)".base64Encoded()) { signed in @@ -166,6 +167,7 @@ struct UserDetailView: View { officialTitle = respJson["data"]["official"]["title"].string ?? "" userSign = respJson["data"]["sign"].string ?? "[加载失败]" coinCount = respJson["data"]["coins"].int ?? -1 + vipLabel = respJson["data"]["vip"]["label"]["text"].string ?? "" DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/relation/stat?vmid=\(uid)", headers: headers) { respJson, isSuccess in if isSuccess { followCount = respJson["data"]["following"].int ?? -1 @@ -292,6 +294,8 @@ struct UserDetailView: View { @Binding var officialType: Int @Binding var officialTitle: String @Binding var userSign: String + @Binding var userLevel: Int + @Binding var vipLabel: String var body: some View { ScrollView { VStack { @@ -318,6 +322,18 @@ struct UserDetailView: View { Spacer() } .padding(.horizontal, 8) + HStack { + Image("Lv\(userLevel)Icon") + Spacer() + } + .padding(.horizontal, 8) + if vipLabel != "" { + HStack { + Image("VIPIcon") + Text(vipLabel) + Spacer() + } + } } } }