Skip to content

Commit

Permalink
Merge pull request #241 from Darock-Studio/fix/issues
Browse files Browse the repository at this point in the history
fix(iOS-Comments, Dynamic, VideoDetails): Fixed comments always show …
  • Loading branch information
WindowsMEMZ authored Feb 18, 2024
2 parents 4d249ce + b347849 commit b4bfa29
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 28 deletions.
16 changes: 8 additions & 8 deletions DarockBili.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBili.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 634;
CURRENT_PROJECT_VERSION = 643;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1453,7 +1453,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBili.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 634;
CURRENT_PROJECT_VERSION = 643;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1496,7 +1496,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 634;
CURRENT_PROJECT_VERSION = 643;
DEVELOPMENT_ASSET_PATHS = "DarockBili\\ Watch\\ App/Preview\\ Content";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1531,7 +1531,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 634;
CURRENT_PROJECT_VERSION = 643;
DEVELOPMENT_ASSET_PATHS = "DarockBili\\ Watch\\ App/Preview\\ Content";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1687,7 +1687,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 634;
CURRENT_PROJECT_VERSION = 643;
DEVELOPMENT_ASSET_PATHS = "\"DarockBili Watch App/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1720,7 +1720,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 634;
CURRENT_PROJECT_VERSION = 643;
DEVELOPMENT_ASSET_PATHS = "\"DarockBili Watch App/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1753,7 +1753,7 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 634;
CURRENT_PROJECT_VERSION = 643;
DEVELOPMENT_TEAM = B57D8PP775;
INFOPLIST_KEY_CFBundleDisplayName = DarockBili;
MARKETING_VERSION = 1.0.0;
Expand All @@ -1769,7 +1769,7 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 634;
CURRENT_PROJECT_VERSION = 643;
DEVELOPMENT_TEAM = B57D8PP775;
INFOPLIST_KEY_CFBundleDisplayName = DarockBili;
MARKETING_VERSION = 1.0.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
notificationPayloadFile = "PushNotificationPayload.apns">
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
Expand All @@ -83,6 +82,13 @@
ReferencedContainer = "container:DarockBili.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
<AdditionalOption
key = "NSZombieEnabled"
value = "YES"
isEnabled = "YES">
</AdditionalOption>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
7 changes: 7 additions & 0 deletions DarockBili.xcodeproj/xcshareddata/xcschemes/MeowBili.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@
ReferencedContainer = "container:DarockBili.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
<AdditionalOption
key = "NSZombieEnabled"
value = "YES"
isEnabled = "YES">
</AdditionalOption>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
9 changes: 9 additions & 0 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -4514,6 +4514,9 @@
},
"二维码名片" : {

},
"什么都木有" : {

},
"令枫" : {
"localizations" : {
Expand All @@ -4533,6 +4536,9 @@
},
"全屏" : {

},
"内容" : {

},
"动态" : {

Expand Down Expand Up @@ -4627,6 +4633,9 @@
},
"推荐" : {

},
"文本加载失败" : {

},
"显示底部弹幕" : {

Expand Down
29 changes: 20 additions & 9 deletions MeowBili/GlobalView/CommentsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct CommentsView: View {
@State var presentRepliesGoto = ""
@State var presentRepliesRootData = [String: String]()
@State var isCommentRepliesPresented = false
@State var isNoMore = false
var body: some View {
ScrollView {
LazyVStack {
Expand Down Expand Up @@ -179,16 +180,22 @@ struct CommentsView: View {
commentOffsets[i] = 0
}
}
Button(action: {
nowPage += 1
ContinueLoadComment()
}, label: {
Text("Home.more")
.bold()
})
.buttonStyle(.borderedProminent)
if !isNoMore {
Button(action: {
nowPage += 1
ContinueLoadComment()
}, label: {
Text("Home.more")
.bold()
})
.buttonStyle(.borderedProminent)
}
} else {
ProgressView()
if isNoMore {
Text("什么都木有")
} else {
ProgressView()
}
}
}
.padding(.horizontal)
Expand Down Expand Up @@ -218,6 +225,10 @@ struct CommentsView: View {
debugPrint(respJson)
if !CheckBApiError(from: respJson) { return }
let replies = respJson["data"]["replies"]
if replies.count == 0 {
isNoMore = true
return
}
var calNum = 0
for reply in replies {
isSenderDetailsPresented.append(false)
Expand Down
28 changes: 28 additions & 0 deletions MeowBili/InMain/SearchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ import SDWebImageSwiftUI
import AuthenticationServices

struct SearchMainView: View {
@AppStorage("DedeUserID") var dedeUserID = ""
@AppStorage("DedeUserID__ckMd5") var dedeUserID__ckMd5 = ""
@AppStorage("SESSDATA") var sessdata = ""
@AppStorage("bili_jct") var biliJct = ""
@State var searchText = ""
@State var isSearchPresented = false
@State var searchHistory = [String]()
@State var suggestions = [String]()
var body: some View {
NavigationStack {
List {
Expand All @@ -46,6 +51,24 @@ struct SearchMainView: View {
.onDisappear {
searchText = ""
}
.onChange(of: searchText) { value in
if value != "" {
let headers: HTTPHeaders = [
"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"
]
DarockKit.Network.shared.requestJSON("https://s.search.bilibili.com/main/suggest", headers: headers) { respJson, isSuccess in
if isSuccess {
suggestions.removeAll()
for result in respJson["result"]["tag"] {
if let v = result.1["value"].string {
suggestions.append(v)
}
}
}
}
}
}
}
if debug {
Button(action: {
Expand Down Expand Up @@ -79,6 +102,11 @@ struct SearchMainView: View {
searchHistory.removeAll()
searchHistory = UserDefaults.standard.stringArray(forKey: "SearchHistory") ?? [String]()
}
.searchSuggestions {
if suggestions.count != 0 {

}
}
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions MeowBili/MeowBiliApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,13 @@ struct DarockBili_Watch_AppApp: App {

class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
let audioSession = AVAudioSession.sharedInstance()
do {
try audioSession.setCategory(.playback)
try audioSession.setActive(true, options: [])
} catch {
print("Setting category to AVAudioSessionCategoryPlayback failed.")
}
// let audioSession = AVAudioSession.sharedInstance()
// do {
// try audioSession.setCategory(.playback)
// try audioSession.setActive(true, options: [])
// } catch {
// print("Setting category to AVAudioSessionCategoryPlayback failed.")
// }

return true
}
Expand Down
4 changes: 2 additions & 2 deletions MeowBili/PersonalCenter/UserDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ struct UserDetailView: View {
"cookie": "SESSDATA=\(sessdata); buvid_fp=e651c1a382430ea93631e09474e0b395; buvid3=\(UuidInfoc.gen()); buvid4=buvid4-failed-1",
//"origin": "https://space.bilibili.com",
//"referer": "https://space.bilibili.com/\(uid)/video",
//"User-Agent": "Mozilla/5.0" // Bypass? drdar://gh/SocialSisterYi/bilibili-API-collect/issues/868/1859065874
//"User-Agent": "Mozilla/5.0" // Bypass? rdar://gh/SocialSisterYi/bilibili-API-collect/issues/868#1859065874
"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",
]
// FIXME: Official Wbi crypto logic for this request seems different from other APIs, some IP can get but some can't. It's hard to fix ~_~
Expand Down Expand Up @@ -525,7 +525,7 @@ struct UserDetailView: View {
let headers: HTTPHeaders = [
"accept-language": "en,zh-CN;q=0.9,zh;q=0.8",
"cookie": "SESSDATA=\(sessdata);buvid3=\(globalBuvid3); buvid4=\(globalBuvid4);",
"User-Agent": "Mozilla/5.0" // Bypass? drdar://gh/SocialSisterYi/bilibili-API-collect/issues/868/1859065874
"User-Agent": "Mozilla/5.0" // Bypass? rdar://gh/SocialSisterYi/bilibili-API-collect/issues/868#1859065874
]
biliWbiSign(paramEncoded: "mid=\(uid)&ps=30&pn=\(articleNowPage)&sort=publish_time&platform=web".base64Encoded()) { signed in
if let signed {
Expand Down
7 changes: 7 additions & 0 deletions MeowBili/UserDynamic/DynamicDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,22 @@ struct DynamicDetailView: View {
}
}
}
.padding()
}
.navigationTitle("动态详情")
.navigationBarTitleDisplayMode(.inline)
.tag(1)
.tabItem {
Label("内容", systemImage: "shippingbox.fill")
}
if dynamicDetails["Type"]! as! BiliDynamicType == .text || dynamicDetails["Type"]! as! BiliDynamicType == .forward || dynamicDetails["Type"]! as! BiliDynamicType == .draw {
CommentsView(oid: dynamicDetails["DynamicID"]! as! String, type: (dynamicDetails["Type"]! as! BiliDynamicType) == .draw ? 11 : 17)
.navigationTitle("动态评论")
.navigationBarTitleDisplayMode(.inline)
.tag(2)
.tabItem {
Label("评论", systemImage: "bubble.left.and.text.bubble.right.fill")
}
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions MeowBili/UserDynamic/ImageViewerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ struct ImageViewerView: View {
.scaledToFit()
.frame(alignment: .center)
.modifier(zoomable())
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button(action: {
let img = UIImage(data: try! Data(contentsOf: URL(string: url)!))!
UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil)
AlertKitAPI.present(title: "已保存", subtitle: "图片已保存到相册", icon: .done, style: .iOS17AppleMusic, haptic: .success)
}, label: {
Image(systemName: "square.and.arrow.down")
})
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions MeowBili/UserDynamic/UserDynamicMainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ struct UserDynamicMainView: View {
ProgressView()
}
})
.buttonStyle(.borderedProminent)
} else {
ProgressView()
}
Expand Down
2 changes: 2 additions & 0 deletions MeowBili/Video/VideoDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ struct VideoDetailView: View {
.navigationBarTitleDisplayMode(.inline)
.scrollDismissesKeyboard(.immediately)
.onAppear {
if isDecoded { return } // After user enter a new video then exit, this onAppear method will be re-call

let headers: HTTPHeaders = [
"cookie": "SESSDATA=\(sessdata)",
"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"
Expand Down

0 comments on commit b4bfa29

Please sign in to comment.