diff --git a/DarockBili.xcodeproj/project.pbxproj b/DarockBili.xcodeproj/project.pbxproj
index 45f427f97..596212562 100644
--- a/DarockBili.xcodeproj/project.pbxproj
+++ b/DarockBili.xcodeproj/project.pbxproj
@@ -202,6 +202,13 @@
8CF148962CC40A4C00C13711 /* BiliAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CF148922CC403BF00C13711 /* BiliAPI.swift */; };
8CF148972CC40AAB00C13711 /* ResponseModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CF148942CC4040E00C13711 /* ResponseModels.swift */; };
8CF148982CC40AAB00C13711 /* ResponseModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CF148942CC4040E00C13711 /* ResponseModels.swift */; };
+ B28D73A92CCBD66400AF5AA4 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2B8137E2CC3D0ED00C69D17 /* WidgetKit.framework */; };
+ B28D73AA2CCBD66400AF5AA4 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2B813802CC3D0ED00C69D17 /* SwiftUI.framework */; };
+ B28D73B92CCBD8A200AF5AA4 /* BiliBiliAPIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2B813962CC3D22800C69D17 /* BiliBiliAPIService.swift */; };
+ B28D73E32CCD288D00AF5AA4 /* MeowWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2B813872CC3D0ED00C69D17 /* MeowWidget.swift */; };
+ B28D73E42CCD288E00AF5AA4 /* MeowWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2B813872CC3D0ED00C69D17 /* MeowWidget.swift */; };
+ B28D73E52CCD28AA00AF5AA4 /* MeowWidgetBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2B813832CC3D0ED00C69D17 /* MeowWidgetBundle.swift */; };
+ B28D73E62CCD28AB00AF5AA4 /* MeowWidgetBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2B813832CC3D0ED00C69D17 /* MeowWidgetBundle.swift */; };
B2B8137F2CC3D0ED00C69D17 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2B8137E2CC3D0ED00C69D17 /* WidgetKit.framework */; };
B2B813812CC3D0ED00C69D17 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2B813802CC3D0ED00C69D17 /* SwiftUI.framework */; };
B2B813842CC3D0ED00C69D17 /* MeowWidgetBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2B813832CC3D0ED00C69D17 /* MeowWidgetBundle.swift */; };
@@ -504,6 +511,15 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ B28D73A52CCBD66400AF5AA4 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ B28D73AA2CCBD66400AF5AA4 /* SwiftUI.framework in Frameworks */,
+ B28D73A92CCBD66400AF5AA4 /* WidgetKit.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
B2B8137A2CC3D0ED00C69D17 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -976,10 +992,12 @@
8CA7CBCC2B77AC4C008E587F /* Frameworks */,
8CA7CBCD2B77AC4C008E587F /* Resources */,
8C2026822CBBA33300D7C5F9 /* Embed Frameworks */,
+ B28D73B42CCBD66C00AF5AA4 /* Embed Foundation Extensions */,
);
buildRules = (
);
dependencies = (
+ B28D73B22CCBD66C00AF5AA4 /* PBXTargetDependency */,
);
name = "MeowBili Watch App";
packageProductDependencies = (
@@ -1068,6 +1086,9 @@
CreatedOnToolsVersion = 15.2;
TestTargetID = 8CA7CBBF2B77AC4A008E587F;
};
+ B28D73A72CCBD66400AF5AA4 = {
+ CreatedOnToolsVersion = 15.1;
+ };
B2B8137C2CC3D0ED00C69D17 = {
CreatedOnToolsVersion = 15.1;
};
@@ -1177,6 +1198,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ B28D73A62CCBD66400AF5AA4 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
B2B8137B2CC3D0ED00C69D17 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -1255,6 +1283,7 @@
8CA7CCA62B77B315008E587F /* CommentsView.swift in Sources */,
8CA7CC6F2B77AEB4008E587F /* SearchView.swift in Sources */,
8C2DFCB02C4AA15C003AEC67 /* NewFeaturesView.swift in Sources */,
+ B28D73E52CCD28AA00AF5AA4 /* MeowWidgetBundle.swift in Sources */,
8CA7CCD82B77B54F008E587F /* LivePlayerView.swift in Sources */,
8CA7CCB62B77B3BF008E587F /* UserDetailView.swift in Sources */,
8CA7CCCE2B77B4DF008E587F /* DynamicSendView.swift in Sources */,
@@ -1307,6 +1336,7 @@
8CA7CC992B77B127008E587F /* SkinDownloadView.swift in Sources */,
8CA7CCDA2B77B55F008E587F /* LiveDetailView.swift in Sources */,
8CA7CC6C2B77AE80008E587F /* DownloadObj.swift in Sources */,
+ B28D73E32CCD288D00AF5AA4 /* MeowWidget.swift in Sources */,
8CC3D55D2B7CC936005636DC /* OCCodeExt.m in Sources */,
8C3C52F62CBAE79B00622CE4 /* SeasonArchiveListView.swift in Sources */,
8CA7CCD12B77B504008E587F /* BangumiDetailView.swift in Sources */,
@@ -1324,6 +1354,7 @@
8CBFF0C72B85E55F00350E0F /* VideoDownloadView.swift in Sources */,
03B2F8102C45AED7007EB850 /* PhoneFormatterExt.swift in Sources */,
8CBFF0E32B85E55F00350E0F /* AboutView.swift in Sources */,
+ B28D73E62CCD28AB00AF5AA4 /* MeowWidgetBundle.swift in Sources */,
8CBFF0E52B85E55F00350E0F /* CodingTime.m in Sources */,
8CBFF0C52B85E55F00350E0F /* SkinExplorerView.swift in Sources */,
8CBFF0BC2B85E55F00350E0F /* HistoryView.swift in Sources */,
@@ -1376,6 +1407,7 @@
8CBFF0DE2B85E55F00350E0F /* DownloadsView.swift in Sources */,
8CBFF0C92B85E55F00350E0F /* BangumiDownloadView.swift in Sources */,
8CBFF0D52B85E55F00350E0F /* SettingsView.swift in Sources */,
+ B28D73E42CCD288E00AF5AA4 /* MeowWidget.swift in Sources */,
8CBFF0BB2B85E55F00350E0F /* DynamicDetailView.swift in Sources */,
8C3C52F72CBAE79B00622CE4 /* SeasonArchiveListView.swift in Sources */,
8CBFF0E42B85E55F00350E0F /* BangumiDetailView.swift in Sources */,
@@ -1390,6 +1422,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ B28D73A42CCBD66400AF5AA4 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ B28D73B92CCBD8A200AF5AA4 /* BiliBiliAPIService.swift in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
B2B813792CC3D0ED00C69D17 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -1681,6 +1721,7 @@
8C82F7812BB6DF2D009AEFD2 /* Alternative */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconWatch;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
@@ -1899,6 +1940,7 @@
8CA7CBE02B77AC4D008E587F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconWatch;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "Entitlements/Watch Debug.entitlements";
@@ -1937,6 +1979,7 @@
8CA7CBE12B77AC4D008E587F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconWatch;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "Entitlements/Watch Release.entitlements";
diff --git a/DarockBili.xcodeproj/xcshareddata/xcschemes/Alternative Destribution.xcscheme b/DarockBili.xcodeproj/xcshareddata/xcschemes/Alternative Destribution.xcscheme
deleted file mode 100644
index 8e551bb00..000000000
--- a/DarockBili.xcodeproj/xcshareddata/xcschemes/Alternative Destribution.xcscheme
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/DarockBili.xcodeproj/xcshareddata/xcschemes/MeowBili Watch App.xcscheme b/DarockBili.xcodeproj/xcshareddata/xcschemes/MeowBili Watch App.xcscheme
index 736917fd6..3c3a8487b 100644
--- a/DarockBili.xcodeproj/xcshareddata/xcschemes/MeowBili Watch App.xcscheme
+++ b/DarockBili.xcodeproj/xcshareddata/xcschemes/MeowBili Watch App.xcscheme
@@ -77,8 +77,7 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
- allowLocationSimulation = "YES"
- notificationPayloadFile = "Examples/SDWebImage Watch Demo Extension/PushNotificationPayload.apns">
+ allowLocationSimulation = "YES">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/MeowWidget/Assets.xcassets/MeowBili.appiconset/Contents.json b/MeowWidget/Assets.xcassets/MeowBili.appiconset/Contents.json
deleted file mode 100644
index 4753f60ca..000000000
--- a/MeowWidget/Assets.xcassets/MeowBili.appiconset/Contents.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "images" : [
- {
- "filename" : "ico1.png",
- "idiom" : "universal",
- "platform" : "ios",
- "size" : "1024x1024"
- }
- ],
- "info" : {
- "author" : "xcode",
- "version" : 1
- }
-}
diff --git a/MeowWidget/Assets.xcassets/MeowBili.appiconset/ico1.png b/MeowWidget/Assets.xcassets/MeowBili.appiconset/ico1.png
deleted file mode 100644
index 324f01d9e..000000000
Binary files a/MeowWidget/Assets.xcassets/MeowBili.appiconset/ico1.png and /dev/null differ
diff --git a/MeowWidget/Assets.xcassets/WidgetBackgroundColor.colorset/Contents.json b/MeowWidget/Assets.xcassets/WidgetBackgroundColor.colorset/Contents.json
deleted file mode 100644
index 806450676..000000000
--- a/MeowWidget/Assets.xcassets/WidgetBackgroundColor.colorset/Contents.json
+++ /dev/null
@@ -1,38 +0,0 @@
-{
- "colors" : [
- {
- "color" : {
- "color-space" : "srgb",
- "components" : {
- "alpha" : "1.000",
- "blue" : "255",
- "green" : "255",
- "red" : "255"
- }
- },
- "idiom" : "universal"
- },
- {
- "appearances" : [
- {
- "appearance" : "luminosity",
- "value" : "dark"
- }
- ],
- "color" : {
- "color-space" : "srgb",
- "components" : {
- "alpha" : "1.000",
- "blue" : "26",
- "green" : "24",
- "red" : "23"
- }
- },
- "idiom" : "universal"
- }
- ],
- "info" : {
- "author" : "xcode",
- "version" : 1
- }
-}
diff --git a/MeowWidget/MeowWidget.swift b/MeowWidget/MeowWidget.swift
index 84e04aa9c..c091a77fa 100644
--- a/MeowWidget/MeowWidget.swift
+++ b/MeowWidget/MeowWidget.swift
@@ -30,7 +30,7 @@ struct MeowWidgetEntry: TimelineEntry {
struct Provider: TimelineProvider {
func placeholder(in context: Context) -> MeowWidgetEntry {
- MeowWidgetEntry(date: Date(), videoTitle: "视频名称", videoDescription: "描述", videoAuthor: "作者", videoViews: "播放量")
+ MeowWidgetEntry(date: Date(), videoTitle: "miku miku oo ee oo", videoDescription: "https://twitter.com/i/status/1697029186777706544 channel(twi:_CASTSTATION)", videoAuthor: "未来de残像", videoViews: "365.4万")
}
func getSnapshot(in context: Context, completion: @escaping (MeowWidgetEntry) -> ()) {
@@ -87,9 +87,6 @@ struct MeowWidgetEntryView : View {
var body: some View {
VStack(alignment: .leading) {
HStack {
- Image("MeowBili")
- .resizable()
- .frame(width: 24, height: 24)
Text("喵哩喵哩")
.font(.headline)
.foregroundColor(Color("WidgetTitleColor"))
@@ -99,7 +96,7 @@ struct MeowWidgetEntryView : View {
switch family {
case .systemSmall:
- Text(entry.videoTitle)
+ Text("在喵哩喵哩查看视频")
.font(.headline)
case .systemMedium:
@@ -108,9 +105,6 @@ struct MeowWidgetEntryView : View {
Text(entry.videoDescription)
.font(.subheadline)
Spacer()
- Text("在喵哩喵哩查看更多内容")
- .font(.footnote)
- .foregroundColor(.gray)
case .systemLarge:
Text(entry.videoTitle)
@@ -143,7 +137,6 @@ struct MeowWidgetEntryView : View {
}
}
.padding()
- .background(Color("WidgetBackgroundColor"))
.widgetURL(URL(string: "meowbili://")!)
}
}
@@ -156,7 +149,7 @@ struct MeowWidget: Widget {
StaticConfiguration(kind: kind, provider: Provider()) { entry in
MeowWidgetEntryView(entry: entry)
}
- .configurationDisplayName("喵哩喵哩Widget")
+ .configurationDisplayName("喵哩喵哩小组件")
.description("热门或推荐的视频内容")
.supportedFamilies(families)
}
diff --git a/SharedCode/BiliBiliAPIService.swift b/SharedCode/BiliBiliAPIService.swift
index 69e496c12..1b997901b 100644
--- a/SharedCode/BiliBiliAPIService.swift
+++ b/SharedCode/BiliBiliAPIService.swift
@@ -34,35 +34,33 @@ class BiliBiliAPIService {
switch type {
case .trending:
urlString = "https://api.bilibili.com/x/web-interface/popular?ps=\(limit)"
- //这里ps=几就会让返回数据有几条
case .recommendations:
urlString = "https://api.bilibili.com/x/web-interface/index/top/rcmd?ps=1"
- //这里ps=任何数字都不影响返回值 所以不更改\(limit)
}
-
+
guard let url = URL(string: urlString) else {
throw URLError(.badURL)
}
-
+
let (data, _) = try await URLSession.shared.data(from: url)
if let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
let dataDict = json["data"] as? [String: Any],
- let list = dataDict["list"] as? [[String: Any]] {
-
- let videos = list.prefix(limit).map { video -> (String, String, String, String) in
+ let itemList = dataDict["item"] as? [[String: Any]] {
+
+ let videos = itemList.prefix(limit).map { video -> (String, String, String, String) in
let videoTitle = video["title"] as? String ?? "无标题"
let videoDesc = video["desc"] as? String ?? "无描述"
- let videoAuthor = video["author"] as? String ?? "未知作者"
- let videoViews = video["view"] as? String ?? "未知播放量"
- return (title: videoTitle, description: videoDesc, author: videoAuthor, views: videoViews)
+ let videoAuthor = (video["owner"] as? [String: Any])?["name"] as? String ?? "未知作者"
+ let videoViews = (video["stat"] as? [String: Any])?["view"] as? Int ?? 0
+ return (title: videoTitle, description: videoDesc, author: videoAuthor, views: "\(videoViews)")
}
return .success(videos)
} else {
return .failure(NSError(domain: "BiliBiliAPIService", code: -1, userInfo: [NSLocalizedDescriptionKey: "数据格式错误"]))
}
-
+
} catch {
return .failure(error)
}