Skip to content

Commit

Permalink
Merge pull request #325 from Darock-Studio/feat/article
Browse files Browse the repository at this point in the history
feat: Decode article html on Apple Watch (not full)
  • Loading branch information
WindowsMEMZ authored Mar 17, 2024
2 parents 9a85729 + 9b5a713 commit 2147413
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 24 deletions.
24 changes: 12 additions & 12 deletions DarockBili.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 904;
CURRENT_PROJECT_VERSION = 912;
DEVELOPMENT_TEAM = B57D8PP775;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = SafariExtension/Info.plist;
Expand Down Expand Up @@ -1610,7 +1610,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 904;
CURRENT_PROJECT_VERSION = 912;
DEVELOPMENT_TEAM = B57D8PP775;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = SafariExtension/Info.plist;
Expand Down Expand Up @@ -1646,7 +1646,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Vision App.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 904;
CURRENT_PROJECT_VERSION = 912;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1681,7 +1681,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Vision App.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 904;
CURRENT_PROJECT_VERSION = 912;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1718,7 +1718,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBili.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 904;
CURRENT_PROJECT_VERSION = 912;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1765,7 +1765,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBili.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 904;
CURRENT_PROJECT_VERSION = 912;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1809,7 +1809,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconWatch;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 904;
CURRENT_PROJECT_VERSION = 912;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview\\ Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1845,7 +1845,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconWatch;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 904;
CURRENT_PROJECT_VERSION = 912;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview\\ Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1884,7 +1884,7 @@
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Mac App.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 904;
CURRENT_PROJECT_VERSION = 912;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -1917,7 +1917,7 @@
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Mac App.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 904;
CURRENT_PROJECT_VERSION = 912;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -1946,7 +1946,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 904;
CURRENT_PROJECT_VERSION = 912;
DEVELOPMENT_TEAM = B57D8PP775;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
Expand All @@ -1969,7 +1969,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 904;
CURRENT_PROJECT_VERSION = 912;
DEVELOPMENT_TEAM = B57D8PP775;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
Expand Down
4 changes: 2 additions & 2 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -9276,10 +9276,10 @@
"输入错误" : {

},
"退出" : {
"退出 App" : {

},
"退出 App" : {
"退出播放" : {

},
"选择图片" : {
Expand Down
39 changes: 39 additions & 0 deletions MeowBili/PersonalCenter/ArticleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import SwiftUI
import DarockKit
import Alamofire
import SwiftSoup
#if !os(watchOS)
import WebKit
Expand All @@ -37,3 +38,41 @@ struct ArticleView_Previews: PreviewProvider {
}
}
#endif

#if os(watchOS)
struct ArticleView: View {
var cvid: String
@State var title = ""
@State var content = ""
var body: some View {
ScrollView {
VStack {
Text(content)
}

}
.navigationTitle(title)
.navigationBarTitleDisplayMode(.large)
.onAppear {
DarockKit.Network.shared.requestString("https://www.bilibili.com/read/cv\(cvid)") { respStr, isSuccess in
if isSuccess {
do {
let doc: Document = try SwiftSoup.parse(respStr)
let ps = try doc.select("p")
for i in 0..<ps.count {
if i == 0 {
title = try ps[i].text()
} else {
content += "\(try ps[i].text())\n\n"
}
}
} catch {
debugPrint(error)

}
}
}
}
}
}
#endif
16 changes: 6 additions & 10 deletions MeowBili/PersonalCenter/UserDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -700,9 +700,11 @@ struct UserDetailView: View {
.frame(height: 20)
HStack {
Spacer()
CachedAsyncImage(url: URL(string: userFaceUrl + "@50w_50h"))
.cornerRadius(100)
.frame(width: 50, height: 50)
if userFaceUrl != "" {
CachedAsyncImage(url: URL(string: userFaceUrl + "@50w_50h"))
.cornerRadius(100)
.frame(width: 50, height: 50)
}
Spacer()
}
HStack {
Expand Down Expand Up @@ -977,13 +979,7 @@ struct UserDetailView: View {
VStack {
if articles.count != 0 {
ForEach(0...articles.count - 1, id: \.self) { i in
Button(action: {
let session = ASWebAuthenticationSession(url: URL(string: "https://www.bilibili.com/read/cv\(articles[i]["CV"]!)")!, callbackURLScheme: nil) { _, _ in
return
}
session.prefersEphemeralWebBrowserSession = true
session.start()
}, label: {
NavigationLink(destination: { ArticleView(cvid: articles[i]["CV"]!) }, label: {
VStack {
Text(articles[i]["Title"]!)
.font(.system(size: 16, weight: .bold))
Expand Down

0 comments on commit 2147413

Please sign in to comment.