diff --git a/MeowBili/Others/SettingsView.swift b/MeowBili/Others/SettingsView.swift index f1280a7a0..1d89b6d4f 100644 --- a/MeowBili/Others/SettingsView.swift +++ b/MeowBili/Others/SettingsView.swift @@ -52,6 +52,7 @@ struct SettingsView: View { .clipShape(RoundedRectangle(cornerRadius: 5)) Image(systemName: "network") .font(.system(size: 16)) + .foregroundColor(.white) } Text("Settings.internet") } @@ -64,6 +65,7 @@ struct SettingsView: View { .clipShape(RoundedRectangle(cornerRadius: 5)) Image(systemName: "hourglass") .font(.system(size: 16)) + .foregroundColor(.white) } Text("Settings.screen-time") } @@ -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") } @@ -88,6 +91,7 @@ struct SettingsView: View { .clipShape(RoundedRectangle(cornerRadius: 5)) Image(systemName: "exclamationmark") .font(.system(size: 16)) + .foregroundColor(.white) } Text("Settings.feedback") } @@ -102,6 +106,7 @@ struct SettingsView: View { .clipShape(RoundedRectangle(cornerRadius: 5)) Image(systemName: "info") .font(.system(size: 16)) + .foregroundColor(.white) } Text("Settings.about") } @@ -116,6 +121,7 @@ struct SettingsView: View { .clipShape(RoundedRectangle(cornerRadius: 5)) Image(systemName: "hammer.fill") .font(.system(size: 16)) + .foregroundColor(.white) } Text("Settings.developer") } @@ -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) { diff --git a/MeowBili/Video/VideoDetailView.swift b/MeowBili/Video/VideoDetailView.swift index 0cf2f3345..d60be8907 100644 --- a/MeowBili/Video/VideoDetailView.swift +++ b/MeowBili/Video/VideoDetailView.swift @@ -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 @@ -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("") { videoDetails["Title"] = "\(String(videoDetails["Title"]!.hasPrefix("") ? "" : (videoDetails["Title"]!.split(separator: "")[0])))\(String(videoDetails["Title"]!.split(separator: "")[videoDetails["Title"]!.hasPrefix("") ? 0 : 1].split(separator: "")[0]))\(String(videoDetails["Title"]!.hasSuffix("") ? "" : videoDetails["Title"]!.split(separator: "")[1]))" diff --git a/MeowBili/Video/VideoPlayerView.swift b/MeowBili/Video/VideoPlayerView.swift index 0c801cff0..b55d3c06b 100644 --- a/MeowBili/Video/VideoPlayerView.swift +++ b/MeowBili/Video/VideoPlayerView.swift @@ -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? @@ -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) + } } }