Skip to content

Commit

Permalink
Merge pull request #216 from Darock-Studio/ios/setting
Browse files Browse the repository at this point in the history
iOS 设置更新
  • Loading branch information
WindowsMEMZ authored Feb 12, 2024
2 parents 5bc1d22 + e804491 commit 74bb865
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
14 changes: 8 additions & 6 deletions MeowBili/Others/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct SettingsView: View {
.clipShape(RoundedRectangle(cornerRadius: 5))
Image(systemName: "network")
.font(.system(size: 16))
.foregroundColor(.white)
}
Text("Settings.internet")
}
Expand All @@ -64,6 +65,7 @@ struct SettingsView: View {
.clipShape(RoundedRectangle(cornerRadius: 5))
Image(systemName: "hourglass")
.font(.system(size: 16))
.foregroundColor(.white)
}
Text("Settings.screen-time")
}
Expand All @@ -76,6 +78,7 @@ struct SettingsView: View {
.clipShape(RoundedRectangle(cornerRadius: 5))
Image(systemName: "bed.double.fill")
.font(.system(size: 14))
.foregroundColor(.white)
}
Text("Settings.sleep")
}
Expand All @@ -88,6 +91,7 @@ struct SettingsView: View {
.clipShape(RoundedRectangle(cornerRadius: 5))
Image(systemName: "exclamationmark")
.font(.system(size: 16))
.foregroundColor(.white)
}
Text("Settings.feedback")
}
Expand All @@ -102,6 +106,7 @@ struct SettingsView: View {
.clipShape(RoundedRectangle(cornerRadius: 5))
Image(systemName: "info")
.font(.system(size: 16))
.foregroundColor(.white)
}
Text("Settings.about")
}
Expand All @@ -116,6 +121,7 @@ struct SettingsView: View {
.clipShape(RoundedRectangle(cornerRadius: 5))
Image(systemName: "hammer.fill")
.font(.system(size: 16))
.foregroundColor(.white)
}
Text("Settings.developer")
}
Expand Down Expand Up @@ -162,16 +168,12 @@ struct SettingsView: View {
}

struct PlayerSettingsView: View {
@AppStorage("RecordHistoryTime") var recordHistoryTime = "into"
@AppStorage("IsRecordHistory") var isRecordHistory = true
@AppStorage("VideoGetterSource") var videoGetterSource = "official"
var body: some View {
List {
Section {
Picker("Player.record-history", selection: $recordHistoryTime) {
Text("Player.record-history.when-entering-page").tag("into")
Text("Player.record-history.when-video-plays").tag("play")
Text("Player.record-history.never").tag("never")
}
Toggle("记录历史记录", isOn: $isRecordHistory)
}
Section(footer: Text("Player.analyzying-source.description")) {
Picker("Player.analyzying-source", selection: $videoGetterSource) {
Expand Down
6 changes: 0 additions & 6 deletions MeowBili/Video/VideoDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ struct VideoDetailView: View {
@AppStorage("DedeUserID__ckMd5") var dedeUserID__ckMd5 = ""
@AppStorage("SESSDATA") var sessdata = ""
@AppStorage("bili_jct") var biliJct = ""
@AppStorage("RecordHistoryTime") var recordHistoryTime = "into"
@AppStorage("VideoGetterSource") var videoGetterSource = "official"
@AppStorage("IsDanmakuEnabled") var isDanmakuEnabled = true
@State var isDecoded = false
Expand Down Expand Up @@ -505,11 +504,6 @@ struct VideoDetailView: View {
}
}
}
if recordHistoryTime == "into" {
AF.request("https://api.bilibili.com/x/click-interface/web/heartbeat", method: .post, parameters: ["bvid": videoDetails["BV"]!, "mid": dedeUserID, "type": 3, "dt": 2, "play_type": 2, "csrf": biliJct], headers: headers).response { response in
debugPrint(response)
}
}

if videoDetails["Title"]!.contains("<em class=\"keyword\">") {
videoDetails["Title"] = "\(String(videoDetails["Title"]!.hasPrefix("<em class=\"keyword\">") ? "" : (videoDetails["Title"]!.split(separator: "<em class=\"keyword\">")[0])))\(String(videoDetails["Title"]!.split(separator: "<em class=\"keyword\">")[videoDetails["Title"]!.hasPrefix("<em class=\"keyword\">") ? 0 : 1].split(separator: "</em>")[0]))\(String(videoDetails["Title"]!.hasSuffix("</em>") ? "" : videoDetails["Title"]!.split(separator: "</em>")[1]))"
Expand Down
24 changes: 12 additions & 12 deletions MeowBili/Video/VideoPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct VideoPlayerView: View {
@AppStorage("DedeUserID__ckMd5") var dedeUserID__ckMd5 = ""
@AppStorage("SESSDATA") var sessdata = ""
@AppStorage("bili_jct") var biliJct = ""
@AppStorage("RecordHistoryTime") var recordHistoryTime = "into"
@AppStorage("IsRecordHistory") var isRecordHistory = true
@State var currentTime: Double = 0.0
@State var playerTimer: Timer?
@State var danmakuTimer: Timer?
Expand All @@ -55,20 +55,20 @@ struct VideoPlayerView: View {
let headers: HTTPHeaders = [
"cookie": "SESSDATA=\(sessdata)"
]
if recordHistoryTime == "play" {
if isRecordHistory {
AF.request("https://api.bilibili.com/x/click-interface/web/heartbeat", method: .post, parameters: ["bvid": VideoDetailView.willPlayVideoBV, "mid": dedeUserID, "type": 3, "dt": 2, "play_type": 2, "csrf": biliJct], headers: headers).response { response in
debugPrint(response)
}
}

Timer.scheduledTimer(withTimeInterval: 15, repeats: true) { timer in
playerTimer = timer
debugPrint(player.currentTime())
let headers: HTTPHeaders = [
"cookie": "SESSDATA=\(sessdata)"
]
AF.request("https://api.bilibili.com/x/click-interface/web/heartbeat", method: .post, parameters: ["bvid": VideoDetailView.willPlayVideoBV, "mid": dedeUserID, "played_time": Int(player.currentTime().seconds), "type": 3, "dt": 2, "play_type": 0, "csrf": biliJct], headers: headers).response { response in
debugPrint(response)
Timer.scheduledTimer(withTimeInterval: 15, repeats: true) { timer in
playerTimer = timer
debugPrint(player.currentTime())
let headers: HTTPHeaders = [
"cookie": "SESSDATA=\(sessdata)"
]
AF.request("https://api.bilibili.com/x/click-interface/web/heartbeat", method: .post, parameters: ["bvid": VideoDetailView.willPlayVideoBV, "mid": dedeUserID, "played_time": Int(player.currentTime().seconds), "type": 3, "dt": 2, "play_type": 0, "csrf": biliJct], headers: headers).response { response in
debugPrint(response)
}
}
}

Expand Down

0 comments on commit 74bb865

Please sign in to comment.