Skip to content

Commit

Permalink
Update for Darock Browser Connectivity
Browse files Browse the repository at this point in the history
  • Loading branch information
WindowsMEMZ committed Nov 30, 2024
1 parent 68aaccd commit 617f263
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 130 deletions.
4 changes: 4 additions & 0 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -9858,8 +9858,12 @@
}
}
}
},
"在使用本 App 前,您需要先知晓以下信息:\n· 本 App 由第三方开发者以及部分社区用户贡献,与哔哩哔哩无合作关系,哔哩哔哩是上海宽娱数码科技有限公司的商标。\n· 本 App 并不是哔哩哔哩的替代品,我们建议您在能够使用官方客户端时尽量使用官方客户端。\n· 本 App 均使用来源于网络的公开信息进行开发。\n· 本 App 中和B站相关的功能完全免费\n· 本 App 中所呈现的B站内容来自哔哩哔哩官方。" : {

},
"在使用本 App 前,您需要先知晓以下信息:\n· 本 App 由第三方开发者以及部分社区用户贡献,与哔哩哔哩无合作关系,哔哩哔哩是上海宽娱数码科技有限公司的商标。\n· 本 App 并不是哔哩哔哩的替代品,我们建议您在能够使用官方客户端时尽量使用官方客户端。\n· 本 App 均使用来源于网络的公开信息进行开发。\n· 本 App 中和B站相关的功能完全免费\n· 本 App 中所呈现的B站内容来自哔哩哔哩官方。\n· 本 App 的开发者、负责人和实际责任人是%@\n 联系QQ:3245146430" : {
"extractionState" : "stale",
"localizations" : {
"en" : {
"stringUnit" : {
Expand Down
135 changes: 66 additions & 69 deletions MeowBili/InMain/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,83 +41,81 @@ struct ContentView: View {
@State var isNewFeaturePresented = false
@FocusState var isSearchKeyboardFocused: Bool
var body: some View {
NavigationStack {
TabView(selection: $mainTabSelection.onUpdate { oldValue, newValue in
if oldValue == newValue && newValue == 4 {
isSearchKeyboardFocused = true
}
}) {
MainView(mainTabSelection: $mainTabSelection)
TabView(selection: $mainTabSelection.onUpdate { oldValue, newValue in
if oldValue == newValue && newValue == 4 {
isSearchKeyboardFocused = true
}
}) {
MainView(mainTabSelection: $mainTabSelection)
#if !os(watchOS)
.toolbar {
ToolbarItem(placement: .topBarLeading) {
if dedeUserID != "" {
Button(action: {
mainTabSelection = 2
}, label: {
WebImage(url: URL(string: userFaceUrl))
.resizable()
.placeholder {
Circle()
.frame(width: 35, height: 35)
.redacted(reason: .placeholder)
}
.frame(width: 35, height: 35)
.clipShape(Circle())
})
.buttonStyle(.borderless)
}
.toolbar {
ToolbarItem(placement: .topBarLeading) {
if dedeUserID != "" {
Button(action: {
mainTabSelection = 2
}, label: {
WebImage(url: URL(string: userFaceUrl))
.resizable()
.placeholder {
Circle()
.frame(width: 35, height: 35)
.redacted(reason: .placeholder)
}
.frame(width: 35, height: 35)
.clipShape(Circle())
})
.buttonStyle(.borderless)
}
}
}
#endif
.tag(1)
.tabItem {
Label("navbar.suggest", systemImage: "sparkles")
}
PersonAccountView()
.tag(2)
.tabItem {
Label("navbar.my", systemImage: "person.fill")
}
UserDynamicMainView()
.tag(3)
.tabItem {
Label("navbar.dynamic", systemImage: "rectangle.stack.fill")
}
#if !os(watchOS)
SearchMainView(isSearchKeyboardFocused: $isSearchKeyboardFocused)
.tag(4)
.tabItem {
Label("搜索", systemImage: "magnifyingglass")
}
#endif
}
.accessibility(identifier: "MainTabView")
#if os(watchOS)
.sheet(isPresented: $isAudioControllerPresented, content: { AudioControllerView() })
.sheet(isPresented: $isNewFeaturePresented, onDismiss: {
isNewFeatureTipped = true
}, content: { NewFeaturesView() })
#endif
.sheet(isPresented: $isTermsPresented, onDismiss: {
isReadTerms = true
}, content: { TermsListView() })
.onAppear {
#if os(watchOS)
if !isNewFeatureTipped {
isNewFeaturePresented = true
.tag(1)
.tabItem {
Label("navbar.suggest", systemImage: "sparkles")
}
if !isReadTerms {
isTermsPresented = true
PersonAccountView()
.tag(2)
.tabItem {
Label("navbar.my", systemImage: "person.fill")
}
Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { _ in
if pShouldPresentAudioController {
pShouldPresentAudioController = false
isAudioControllerPresented = true
}
UserDynamicMainView()
.tag(3)
.tabItem {
Label("navbar.dynamic", systemImage: "rectangle.stack.fill")
}
#if !os(watchOS)
SearchMainView(isSearchKeyboardFocused: $isSearchKeyboardFocused)
.tag(4)
.tabItem {
Label("搜索", systemImage: "magnifyingglass")
}
#endif
}
.accessibility(identifier: "MainTabView")
#if os(watchOS)
.sheet(isPresented: $isAudioControllerPresented, content: { AudioControllerView() })
.sheet(isPresented: $isNewFeaturePresented, onDismiss: {
isNewFeatureTipped = true
}, content: { NewFeaturesView() })
#endif
.sheet(isPresented: $isTermsPresented, onDismiss: {
isReadTerms = true
}, content: { TermsListView() })
.onAppear {
#if os(watchOS)
if !isNewFeatureTipped {
isNewFeaturePresented = true
}
if !isReadTerms {
isTermsPresented = true
}
Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { _ in
if pShouldPresentAudioController {
pShouldPresentAudioController = false
isAudioControllerPresented = true
}
}
#endif
}
.onAppear {
updateBiliTicket(csrf: biliJct)
Expand Down Expand Up @@ -145,7 +143,6 @@ struct TermsListView: View {
· 本 App 均使用来源于网络的公开信息进行开发。
· 本 App 中和B站相关的功能完全免费
· 本 App 中所呈现的B站内容来自哔哩哔哩官方。
· 本 App 的开发者、负责人和实际责任人是\(Text("WindowsMEMZ").foregroundColor(Color.accentColor))\n 联系QQ:3245146430
""")
Button(action: {
isReadTerms = true
Expand Down
91 changes: 30 additions & 61 deletions MeowBili/MeowBiliApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,7 @@ struct DarockBili_Watch_AppApp: App {
@State var fileLockerInput = ""
@State var recoveryCodeInput = ""
// Navigators
@State var isUrlOpenVideoPresented = false
@State var urlOpenVideoDetails = [String: String]()
#if !os(watchOS)
@State var shouldShowAppName = false
#endif
@State var urlOpenVideoDetails: [String: String]?
var body: some SwiftUI.Scene {
WindowGroup {
if fileLockerPwd != "" {
Expand Down Expand Up @@ -192,63 +188,19 @@ struct DarockBili_Watch_AppApp: App {
}
} else {
ZStack {
#if os(watchOS)
ContentView()
NavigationStack {
ContentView()
.navigationDestination(item: $urlOpenVideoDetails) { detail in
VideoDetailView(videoDetails: detail)
}
}
if isReduceBrightness {
Rectangle()
.fill(Color.black)
.ignoresSafeArea()
.opacity(reduceBrightnessPercent)
.allowsHitTesting(false)
}
#else
NavigationStack {
ZStack {
// Hide NavigationLinks behind
NavigationLink("", isActive: $isUrlOpenVideoPresented, destination: { VideoDetailView(videoDetails: urlOpenVideoDetails) })
ContentView()
}
}
.onOpenURL { url in
let dec = url.absoluteString.urlDecoded()
let spd = dec.split(separator: "/").dropFirst()
debugPrint(spd)
switch spd[1] {
case "withvideodetail":
let kvs = dec.split(separator: "/", maxSplits: 1).dropFirst()[2].split(separator: "&") // e.g.: ["BV=xxx", "Title=xxx"]
urlOpenVideoDetails.removeAll()
for kv in kvs {
let kav = kv.split(separator: "=")
urlOpenVideoDetails.updateValue(String(kav[1]), forKey: String(kav[0]))
}
isUrlOpenVideoPresented = true
case "openbvid":
let bvid = spd[2]
urlOpenVideoDetails = ["Pic": "", "Title": "Loading...", "BV": String(bvid), "UP": "Loading...", "View": "1", "Danmaku": "1"]
isUrlOpenVideoPresented = true
default:
break
}
}
if shouldShowAppName {
VStack {
Spacer()
.frame(height: 12)
ZStack {
Capsule()
.fill(Color.accentColor)
.frame(width: 60, height: 20)
HStack {
Text("喵哩喵哩")
.foregroundStyle(Color.white)
.font(.system(size: 12, weight: .medium))
}
}
Spacer()
}
.ignoresSafeArea()
}
#endif
}
.blur(radius: isLuminanceReduced && blurWhenScreenSleep ? 12 : 0)
.onAppear {
Expand Down Expand Up @@ -361,19 +313,38 @@ struct DarockBili_Watch_AppApp: App {
.onContinueUserActivity(NSUserActivityTypeBrowsingWeb) { activity in
if let url = activity.webpageURL, let bvid = url.absoluteString.split(separator: "darock.top/meowbili/video/", maxSplits: 1)[from: 1] {
urlOpenVideoDetails = ["Pic": "", "Title": "Loading...", "BV": String(bvid), "UP": "Loading...", "View": "1", "Danmaku": "1"]
isUrlOpenVideoPresented = true
}
}
#if os(iOS)
.onOpenURL { url in
let dec = url.absoluteString.urlDecoded()
let spd = dec.split(separator: "/").dropFirst()
debugPrint(spd)
switch spd[1] {
case "withvideodetail":
let kvs = dec.split(separator: "/", maxSplits: 1).dropFirst()[2].split(separator: "&") // e.g.: ["BV=xxx", "Title=xxx"]
var details = [String: String]()
for kv in kvs {
let kav = kv.split(separator: "=")
details.updateValue(String(kav[1]), forKey: String(kav[0]))
}
urlOpenVideoDetails = details
case "openbvid":
let bvid = spd[2]
urlOpenVideoDetails = ["Pic": "", "Title": "Loading...", "BV": String(bvid), "UP": "Loading...", "View": "1", "Danmaku": "1"]
default:
break
}
}
#endif
}
}
.onChange(of: scenePhase) {
switch scenePhase {
case .background:
break
case .inactive:
#if os(iOS)
shouldShowAppName = false
#endif
break
case .active:
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
Expand All @@ -388,8 +359,6 @@ struct DarockBili_Watch_AppApp: App {
WKInterfaceDevice.current().isBatteryMonitoringEnabled = true
#else
InitHapticEngine()

shouldShowAppName = true
#endif

if isScreenTimeEnabled {
Expand Down

0 comments on commit 617f263

Please sign in to comment.