Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stdout debug feature #42

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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