Skip to content

Commit

Permalink
Merge pull request #290 from Darock-Studio/fix/maincrash
Browse files Browse the repository at this point in the history
修复可能的开启时崩溃问题
  • Loading branch information
WindowsMEMZ authored Feb 28, 2024
2 parents a7c8487 + c300700 commit de0f8c5
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions MeowBili/InMain/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,22 @@ struct MainView: View {
.sheet(isPresented: $isNewUserPresenting, content: { LoginView() })
.onAppear {
if username == "" {
getBuvid(url: "https://api.bilibili.com/x/space/wbi/acc/info".urlEncoded()) { buvid3, buvid4, _uuid, _ in
let headers: HTTPHeaders = [
"cookie": "SESSDATA=\(sessdata); innersign=0; buvid3=\(buvid3); b_nut=1704873471; i-wanna-go-back=-1; b_ut=7; b_lsid=9910433CB_18CF260AB89; _uuid=\(_uuid); enable_web_push=DISABLE; header_theme_version=undefined; home_feed_column=4; browser_resolution=3440-1440; buvid4=\(buvid4);",
"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=\(dedeUserID)".base64Encoded()) { signed in
if let signed {
debugPrint(signed)
autoRetryRequestApi("https://api.bilibili.com/x/space/wbi/acc/info?\(signed)", headers: headers) { respJson, isSuccess in
if isSuccess {
debugPrint(respJson)
if !CheckBApiError(from: respJson) { return }
username = respJson["data"]["name"].string ?? ""
userSign = respJson["data"]["sign"].string ?? ""
userFaceUrl = respJson["data"]["face"].string ?? "E"
} else if isShowNetworkFixing {
isNetworkFixPresented = true
}
let headers: HTTPHeaders = [
"cookie": "SESSDATA=\(sessdata); innersign=0; buvid3=\(globalBuvid3); b_nut=1704873471; i-wanna-go-back=-1; b_ut=7; b_lsid=9910433CB_18CF260AB89; enable_web_push=DISABLE; header_theme_version=undefined; home_feed_column=4; browser_resolution=3440-1440; buvid4=\(globalBuvid4);",
"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=\(dedeUserID)".base64Encoded()) { signed in
if let signed {
debugPrint(signed)
DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/space/wbi/acc/info?\(signed)", headers: headers) { respJson, isSuccess in
if isSuccess {
debugPrint(respJson)
if !CheckBApiError(from: respJson) { return }
username = respJson["data"]["name"].string ?? ""
userSign = respJson["data"]["sign"].string ?? ""
userFaceUrl = respJson["data"]["face"].string ?? "E"
} else if isShowNetworkFixing {
isNetworkFixPresented = true
}
}
}
Expand Down

0 comments on commit de0f8c5

Please sign in to comment.