Skip to content

Commit

Permalink
chore: Fixed issues(see issues page for details), added analyze(and p… (
Browse files Browse the repository at this point in the history
#247)

* chore: Fixed issues(see issues page for details), added analyze(and privacy settings for it)

* fix(Building): Fixed 'DarockBili Watch App' target missing library issue

* fix(Building): Fixed build issues

* fix(Building): Fixed build issues
  • Loading branch information
WindowsMEMZ authored Feb 19, 2024
1 parent 640d555 commit e9bf66c
Show file tree
Hide file tree
Showing 26 changed files with 788 additions and 305 deletions.
23 changes: 23 additions & 0 deletions DarockBili Watch App/Assets.xcassets/QRCard.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "QRCard 2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "QRCard.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "QRCard 1.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion DarockBili Watch App/Bangumi/BangumiPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import AVKit
import SwiftUI
import BPlayer
import Alamofire

struct BangumiPlayerView: View {
Expand Down
25 changes: 13 additions & 12 deletions DarockBili Watch App/DarockBiliApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import Darwin
import SwiftUI
import WatchKit
import Mixpanel
import DarockKit
import SwiftyJSON
import SDWebImage
Expand Down Expand Up @@ -328,18 +329,18 @@ public func tipWithText(_ text: String, symbol: String = "", time: Double = 3.0)

class AppDelegate: NSObject, WKApplicationDelegate {
func applicationDidFinishLaunching() {
// signal(SIGABRT, {error in
// signalErrorRecord(error, "SIGABRT")
// })
// signal(SIGTRAP, {error in
// signalErrorRecord(error, "SIGTRAP")
// })
// signal(SIGILL, {error in
// signalErrorRecord(error, "SIGILL")
// })
// signal(SIGKILL, {error in
// signalErrorRecord(error, "SIGKILL")
// })
Mixpanel.initialize(token: "37d4aaecc64cae16353c2fe7dbb0513c")
// ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Wow you see a token there, I'm not forget to hide it because you are no able to
// do anything important by this token >_-
if (UserDefaults.standard.object(forKey: "IsAllowMixpanel") as? Bool) ?? true {
Mixpanel.mainInstance().track(event: "Open App", properties: [
"System": "watchOS"
])
if let uid = UserDefaults.standard.string(forKey: "DedeUserId") {
Mixpanel.mainInstance().registerSuperPropertiesOnce(["DedeUserId": uid])
}
}

SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
Expand Down
35 changes: 0 additions & 35 deletions DarockBili Watch App/Extension/CodeExt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import DarockKit
import Alamofire
import SwiftyJSON
import Foundation
import Starscream
import AVFoundation
import CommonCrypto

Expand Down Expand Up @@ -624,40 +623,6 @@ public func getBuvid(url: String, callback: @escaping (String, String, String, S
}
}

class LiveWebSocketManager: WebSocketDelegate {
var socket: WebSocket!
var onConnected: () -> Void

init(serverUrl: String, onConnected: @escaping () -> Void) {
self.onConnected = onConnected

// 创建 WebSocket 连接
if let url = URL(string: serverUrl) {
var request = URLRequest(url: URL(string: "\(url):443")!)
request.timeoutInterval = 5
socket = WebSocket(request: request)
socket.delegate = self
socket.connect()
}
}

// 连接成功
func didReceive(event: Starscream.WebSocketEvent, client: Starscream.WebSocketClient) {
switch event {
case .connected(_):
print("WebSocket is connected.")

default:
break
}
}

// 发送 WebSocket 消息
func sendWebSocketMessage(data: Data) {
socket.write(data: data)
}
}

postfix operator ++
postfix operator --
prefix operator ++
Expand Down
1 change: 0 additions & 1 deletion DarockBili Watch App/Live/LiveMessagesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import SwiftUI
import DarockKit
import Alamofire
import SwiftyJSON
import Starscream

struct LiveMessagesView: View {
var roomId: Int
Expand Down
27 changes: 27 additions & 0 deletions DarockBili Watch App/Others/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ struct SettingsView: View {
Text("Settings.feedback")
}
})
NavigationLink(destination: {PrivacySettingsView().navigationTitle("隐私与安全性")}, label: {
HStack {
ZStack {
Color.blue
.frame(width: 20, height: 20)
.clipShape(Circle())
Image(systemName: "hand.raised.fill")
.font(.system(size: 12))
}
Text("隐私与安全性")
}
})
}
Section {
NavigationLink(destination: {AboutView()}, label: {
Expand Down Expand Up @@ -550,6 +562,9 @@ struct DebugMenuView: View {
NavigationLink(destination: {Buvid34Debug()}, label: {
Text("buvid3_4_actived")
})
NavigationLink(destination: {bMessageSendView(uid: 1926849243, username: "MC...")}, label: {
Text("bMessagePatch")
})
}
}

Expand Down Expand Up @@ -616,6 +631,18 @@ struct DebugMenuView: View {
}
}

struct PrivacySettingsView: View {
@AppStorage("IsAllowMixpanel") var isAllowMixpanel = true
var body: some View {
List {
Section {
Toggle("允许收集使用信息", isOn: $isAllowMixpanel)
} footer: {
Text("喵哩喵哩收集使用信息仅用以帮助改进质量,不会用于广告、个人画像之类,收集的信息不会关联到个人。此更改立即生效,不会影响哔哩哔哩官方对您的数据收集。")
}
}
}
}

struct SettingsView_Previews: PreviewProvider {
static var previews: some View {
Expand Down
11 changes: 11 additions & 0 deletions DarockBili Watch App/PersonalCenter/PersonAccountView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,17 @@ struct PersonAccountView: View {
isUserDetailSelfPresented = true
}
}
NavigationLink(destination: {SelfQrCardView()}, label: {
HStack {
HStack {
Image(systemName: "qrcode")
.foregroundColor(.accentColor)
Text("二维码名片")
}
.font(.system(size: 16))
Spacer()
}
})
Button(action: {isUserSwitchPresented = true}, label: {
HStack {
HStack {
Expand Down
91 changes: 91 additions & 0 deletions DarockBili Watch App/PersonalCenter/SelfQrCardView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
//
//
// SelfQrCodeView.swift
// DarockBili Watch App
//
// Created by memz233 on 2024/2/18.
//
//===----------------------------------------------------------------------===//
//
// This source file is part of the MeowBili open source project
//
// Copyright (c) 2023 Darock Studio and the MeowBili project authors
// Licensed under GNU General Public License v3
//
// See https://darock.top/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//

import UIKit
import SwiftUI
import EFQRCode
import DarockKit
import Alamofire
import SwiftyJSON
import SDWebImageSwiftUI

struct SelfQrCardView: View {
@AppStorage("DedeUserID") var dedeUserID = ""
@AppStorage("DedeUserID__ckMd5") var dedeUserID__ckMd5 = ""
@AppStorage("SESSDATA") var sessdata = ""
@AppStorage("bili_jct") var biliJct = ""
@State var shotting = false
@State var username = ""
@State var userFaceUrl = ""
@State var qrcodeImg: CGImage?
var body: some View {
VStack {
HStack {
WebImage(url: URL(string: userFaceUrl))
.resizable()
.frame(width: 20, height: 20)
.clipShape(Circle())
VStack {
Text(username)
.font(.system(size: 12))
.foregroundColor(.black)
Text("UID: \(dedeUserID)")
.font(.system(size: 12))
.foregroundColor(.black)
}
Spacer()
}
if let img = qrcodeImg {
Image(uiImage: UIImage(cgImage: img))
.resizable()
.frame(width: 80, height: 80)
.offset(y: 20)
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color(hex: 0xFAFAFD))
.ignoresSafeArea()
.onAppear {
qrcodeImg = EFQRCode.generate(for: "https://space.bilibili.com/\(dedeUserID)", foregroundColor: Color(hex: 0x2b4785).cgColor!)

getBuvid(url: "https://api.bilibili.com/x/space/wbi/acc/info".urlEncoded()) { buvid3, buvid4, _uuid, resp in
let headers: HTTPHeaders = [
"cookie": "SESSDATA=\(sessdata); innersign=0; buvid3=\(buvid3); b_nut=1704873471; i-wanna-go-back=-1; b_ut=7; b_lsid=9910433CB_18CF260AB89; _uuid=\(_uuid); enable_web_push=DISABLE; header_theme_version=undefined; home_feed_column=4; browser_resolution=3440-1440; buvid4=\(buvid4);",
"User-Agent": "Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
]
biliWbiSign(paramEncoded: "mid=\(dedeUserID)".base64Encoded()) { signed in
if let signed {
debugPrint(signed)
autoRetryRequestApi("https://api.bilibili.com/x/space/wbi/acc/info?\(signed)", headers: headers) { respJson, isSuccess in
if isSuccess {
debugPrint(respJson)
if !CheckBApiError(from: respJson) { return }
username = respJson["data"]["name"].string ?? ""
userFaceUrl = respJson["data"]["face"].string ?? "E"
}
}
}
}
}
}
}
}

#Preview {
SelfQrCardView()
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,10 @@ struct bMessageSendView: View {
if deleteAll {
messages.removeAll()
}
for message in respJson["data"]["messages"] {
messages.insert(["SenderID": String(message.1["sender_uid"].int!), "Text": String(message.1["content"].string!.split(separator: ":\"")[1].split(separator: "\"}")[0]).replacingOccurrences(of: "\\n", with: "\n"), "Timestamp": String(message.1["timestamp"].int!)], at: 0)
if respJson["data"]["messages"].dictionary != nil {
for message in respJson["data"]["messages"] {
messages.insert(["SenderID": String(message.1["sender_uid"].int64 ?? 0), "Text": String((message.1["content"].string ?? "获取失败").split(separator: ":\"")[1].split(separator: "\"}")[0]).replacingOccurrences(of: "\\n", with: "\n"), "Timestamp": String(message.1["timestamp"].int ?? Date.now.timeStamp)], at: 0)
}
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions DarockBili Watch App/Video/VideoDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import SwiftUI
import Marquee
import SFSymbol
import WatchKit
import Mixpanel
import DarockKit
import Alamofire
import SwiftyJSON
Expand All @@ -38,6 +39,7 @@ struct VideoDetailView: View {
@AppStorage("bili_jct") var biliJct = ""
@AppStorage("RecordHistoryTime") var recordHistoryTime = "into"
@AppStorage("VideoGetterSource") var videoGetterSource = "official"
@AppStorage("IsAllowMixpanel") var isAllowMixpanel = true
@State var isLoading = false
@State var isLiked = false
@State var isCoined = false
Expand Down Expand Up @@ -400,13 +402,21 @@ struct VideoDetailView: View {
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]))"
}

if isAllowMixpanel {
Mixpanel.mainInstance().time(event: "Watch Video")
}
}
.onDisappear {
goodVideos = [[String: String]]()
owner = [String: String]()
stat = [String: String]()
videoDesc = ""
SDImageCache.shared.clearMemory()

if isAllowMixpanel {
Mixpanel.mainInstance().track(event: "Watch Video", properties: videoDetails)
}
}
}

Expand Down
Loading

0 comments on commit e9bf66c

Please sign in to comment.