Skip to content

Commit

Permalink
Add stdout debug feature (#42)
Browse files Browse the repository at this point in the history
* Update DarockBiliApp.swift

* Update SearchView.swift
  • Loading branch information
WindowsMEMZ committed Oct 12, 2024
1 parent 5acbd55 commit aa91050
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 14 additions & 6 deletions DarockBili Watch App/DarockBiliApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import SDWebImageSVGCoder
import SDWebImageWebPCoder

//!!!: Debug Setting, Set false Before Release
var debug = false
var debug = true

var debugControlStdout = "stdo\n"

var pShowTipText = ""
var pShowTipSymbol = ""
Expand Down Expand Up @@ -174,14 +176,20 @@ struct DarockBili_Watch_AppApp: App {
.buttonStyle(.plain)
.offset(x: 15, y: 5)
if isShowingDebugControls {
HStack {
VStack {
VStack {
HStack {
Text("Memory Usage: \(memoryUsage) MB")

Spacer()
}
.allowsHitTesting(false)
ScrollView {
Text(debugControlStdout)
}
.font(.system(size: 10))
Spacer()
.frame(height: 180)
.border(Color.blue, width: 2)
}
.font(.system(size: 10))

.onAppear {
Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { timer in
systemResourceRefreshTimer = timer
Expand Down
2 changes: 2 additions & 0 deletions DarockBili Watch App/InMain/SearchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ struct SearchView: View {
debugResponse = ""
DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/frontend/finger/spi") { respJson, isSuccess in
if isSuccess {
debugControlStdout += "SEARCH/FINGER/SPI SUCCEEDED: \n\(respJson.debugDescription)"
let headers: HTTPHeaders = [
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"accept-encoding": "gzip, deflate, br",
Expand All @@ -151,6 +152,7 @@ struct SearchView: View {
DarockKit.Network.shared.requestJSON("https://api.bilibili.com/x/web-interface/wbi/search/all/v2?\(signed)", headers: headers) { respJson, isSuccess in
if isSuccess {
debugPrint(respJson)
debugControlStdout += "SEARCH/ALL/V2 SUCCEEDED: \n\(respJson.debugDescription)"
let userDatas = respJson["data"]["result"][8]["data"]
for user in userDatas {
isUserDetailPresented.append(false)
Expand Down

0 comments on commit aa91050

Please sign in to comment.