Skip to content

Commit

Permalink
Merge pull request #342 from Darock-Studio/fix/favorite
Browse files Browse the repository at this point in the history
优化性能,为watchOS添加短信登录
  • Loading branch information
WindowsMEMZ committed Apr 6, 2024
2 parents 5a264a0 + 2328145 commit c7777ae
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 352 deletions.
36 changes: 18 additions & 18 deletions DarockBili.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_TEAM = B57D8PP775;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = SafariExtension/Info.plist;
Expand Down Expand Up @@ -1651,7 +1651,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_TEAM = B57D8PP775;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = SafariExtension/Info.plist;
Expand Down Expand Up @@ -1748,7 +1748,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBiliAlternative.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B38QUJMY47;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1793,7 +1793,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconWatch;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview\\ Content\"";
DEVELOPMENT_TEAM = B38QUJMY47;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1833,7 +1833,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Vision App.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1869,7 +1869,7 @@
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Mac App.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -1898,7 +1898,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_TEAM = B57D8PP775;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
Expand All @@ -1922,7 +1922,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_TEAM = B38QUJMY47;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = SafariExtension/Info.plist;
Expand Down Expand Up @@ -1989,7 +1989,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Vision App.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -2024,7 +2024,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Vision App.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -2061,7 +2061,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBili.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -2108,7 +2108,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBili.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -2153,7 +2153,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconWatch;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview\\ Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -2189,7 +2189,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconWatch;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview\\ Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -2229,7 +2229,7 @@
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Mac App.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -2262,7 +2262,7 @@
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Mac App.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -2291,7 +2291,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_TEAM = B57D8PP775;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
Expand All @@ -2314,7 +2314,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 972;
CURRENT_PROJECT_VERSION = 983;
DEVELOPMENT_TEAM = B57D8PP775;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
Expand Down
10 changes: 10 additions & 0 deletions MeowBili/Extension/CodeExt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -717,3 +717,13 @@ prefix operator &&
prefix func && <T>(input: inout T) -> UnsafeMutablePointer<T> {
withUnsafeMutablePointer(to: &input) { $0 }
}

public func debugPrint(_ items: Any..., separator: String = " ", terminator: String = "\n") {
Swift.debugPrint(items, separator: separator, terminator: terminator)
if debug {
debugControlStdout += items.debugDescription + terminator
if debugControlStdout.count > 5000 {
debugControlStdout.removeFirst(500)
}
}
}
70 changes: 20 additions & 50 deletions MeowBili/GlobalView/CommentsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,57 +267,27 @@ struct CommentsView: View {
]
DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/v2/reply?type=\(type)&oid=\(id)&sort=1&ps=20&pn=\(nowPage)", headers: headers) { respJson, isSuccess in
if isSuccess {
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)
commentOffsets.append(20)
let repliesInComment = reply.1["replies"]
commentReplies.append([])
for sigReply in repliesInComment {
commentReplies[calNum].append(["Text": sigReply.1["content"]["message"].string ?? "[加载失败]", "Sender": sigReply.1["member"]["uname"].string ?? "[加载失败]", "SenderPic": sigReply.1["member"]["avatar"].string ?? "E", "SenderID": sigReply.1["member"]["mid"].string ?? "E", "IP": sigReply.1["reply_control"]["location"].string ?? "", "UserAction": String(sigReply.1["action"].int ?? 0), "Rpid": String(sigReply.1["rpid"].int ?? -1), "Like": String(sigReply.1["like"].int ?? -1)])
DispatchQueue(label: "com.darock.DarockBili.Comment-Load", qos: .background).async {
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)
commentOffsets.append(20)
let repliesInComment = reply.1["replies"]
commentReplies.append([])
for sigReply in repliesInComment {
commentReplies[calNum].append(["Text": sigReply.1["content"]["message"].string ?? "[加载失败]", "Sender": sigReply.1["member"]["uname"].string ?? "[加载失败]", "SenderPic": sigReply.1["member"]["avatar"].string ?? "E", "SenderID": sigReply.1["member"]["mid"].string ?? "E", "IP": sigReply.1["reply_control"]["location"].string ?? "", "UserAction": String(sigReply.1["action"].int ?? 0), "Rpid": String(sigReply.1["rpid"].int ?? -1), "Like": String(sigReply.1["like"].int ?? -1)])
}
let text = reply.1["content"]["message"].string ?? "[加载失败]"
comments.append(["Text": text, "Sender": reply.1["member"]["uname"].string ?? "[加载失败]", "SenderPic": reply.1["member"]["avatar"].string ?? "E", "SenderID": reply.1["member"]["mid"].string ?? "E", "IP": reply.1["reply_control"]["location"].string ?? "", "UserAction": String(reply.1["action"].int ?? 0), "Rpid": reply.1["rpid_str"].string ?? "-1", "Like": String(reply.1["like"].int ?? -1)])
calNum += 1
}
let text = reply.1["content"]["message"].string ?? "[加载失败]"
comments.append(["Text": text, "Sender": reply.1["member"]["uname"].string ?? "[加载失败]", "SenderPic": reply.1["member"]["avatar"].string ?? "E", "SenderID": reply.1["member"]["mid"].string ?? "E", "IP": reply.1["reply_control"]["location"].string ?? "", "UserAction": String(reply.1["action"].int ?? 0), "Rpid": reply.1["rpid_str"].string ?? "-1", "Like": String(reply.1["like"].int ?? -1)])
// sepTexts.append([])
// isEmoted.append(false)
// // 文本中包含表情
// if text.range(of: "\\[(.*?)\\]", options: .regularExpression) != nil {
// let regex = try! NSRegularExpression(pattern: "\\[(.*?)\\]")
// debugPrint("Contains")
// // 分割文本,同时去除表情
// let tmpSpdText = regex.stringByReplacingMatches(in: text, range: NSRange(text.startIndex..<text.endIndex, in: text), withTemplate: "|").split(separator: "|").map {
// String($0)
// }
// debugPrint(tmpSpdText)
// for text in tmpSpdText {
// sepTexts[calNum].append(String(text))
// }
// // 正则获取表情
// let emojis = regex.matches(in: text, range: NSRange(text.startIndex..., in: text)).map {
// String(text[Range($0.range, in: text)!])
// }
// let jEmotes = reply.1["content"]["emote"]
// debugPrint(jEmotes)
// // 获取表情对应URL
// emojiUrls.append([])
// for emoji in emojis {
// if let sigEUrl = jEmotes[emoji].string {
// emojiUrls[calNum].append(sigEUrl)
// }
// }
// isEmoted[calNum] = true
// debugPrint(emojiUrls)
// } else {
//
// }
calNum += 1
}
} else {
Logger().error("There is an error when request comments from Bilibili server")
Expand Down
8 changes: 8 additions & 0 deletions MeowBili/MeowBiliApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,14 @@ struct DarockBili_Watch_AppApp: App {
Spacer()
}
.allowsHitTesting(false)
ScrollView {
LazyVStack {
Text(debugControlStdout)
.font(.system(size: 5, design: .monospaced))
}
}
.border(Color.gray, width: 1)
.frame(width: 150, height: 90)
}
.font(.system(size: 10))

Expand Down

0 comments on commit c7777ae

Please sign in to comment.