From bde3b31efaf993b172d359173f4d5099626f54f5 Mon Sep 17 00:00:00 2001 From: DannyFeng Date: Mon, 20 Jan 2025 20:37:50 +0800 Subject: [PATCH] Real Chores (#434) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 完善了英语翻译 把QQ群号改为了最新的 .systemSmall不再显示具体信息 在AboutView的另一处添加了DannyFeng(看起来是iOS的关于) 这个提交来自Windows 11下的macOS Sequoia虚拟机(很爽) --- .../Alternative Destribution.xcscheme | 2 +- Localizable.xcstrings | 211 +++++++++++++++--- MeowBili/InMain/MainView.swift | 2 +- MeowBili/Others/AboutView.swift | 1 + MeowWidget/MeowWidget.swift | 168 +------------- 5 files changed, 192 insertions(+), 192 deletions(-) diff --git a/DarockBili.xcodeproj/xcshareddata/xcschemes/Alternative Destribution.xcscheme b/DarockBili.xcodeproj/xcshareddata/xcschemes/Alternative Destribution.xcscheme index 8245c0519..8e551bb00 100644 --- a/DarockBili.xcodeproj/xcshareddata/xcschemes/Alternative Destribution.xcscheme +++ b/DarockBili.xcodeproj/xcshareddata/xcschemes/Alternative Destribution.xcscheme @@ -1,7 +1,7 @@ + version = "1.7"> MeowWidgetEntry { - 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) -> ()) { - let entry = MeowWidgetEntry(date: Date(), videoTitle: "视频名称", videoDescription: "描述", videoAuthor: "作者", videoViews: "播放量") - completion(entry) - } - - func getTimeline(in context: Context, completion: @escaping (Timeline) -> ()) { - Task { - let trendingResult = await BiliBiliAPIService().fetchBiliBiliData(for: .trending, limit: 5) - let recommendationsResult = await BiliBiliAPIService().fetchBiliBiliData(for: .recommendations, limit: 5) - - var allVideos: [(title: String, description: String, author: String, views: String)] = [] - if case .success(let trendingVideos) = trendingResult { - allVideos.append(contentsOf: trendingVideos) - } - if case .success(let recommendationsVideos) = recommendationsResult { - allVideos.append(contentsOf: recommendationsVideos) - } - - // 如果有数据,则创建entries - if !allVideos.isEmpty { - var entries: [MeowWidgetEntry] = [] - let currentDate = Date() - - // 每隔 10 分钟轮播一个视频 - for (index, video) in allVideos.enumerated() { - let entryDate = Calendar.current.date(byAdding: .minute, value: index * 10, to: currentDate) ?? currentDate - let entry = MeowWidgetEntry( - date: entryDate, - videoTitle: video.title, - videoDescription: video.description, - videoAuthor: video.author, - videoViews: video.views - ) - entries.append(entry) - } - - let nextUpdateDate = Calendar.current.date(byAdding: .hour, value: 1, to: currentDate) ?? currentDate - let timeline = Timeline(entries: entries, policy: .after(nextUpdateDate)) - completion(timeline) - } else { - let entry = MeowWidgetEntry(date: Date(), videoTitle: "暂无数据", videoDescription: "", videoAuthor: "", videoViews: "") - completion(Timeline(entries: [entry], policy: .atEnd)) - } - } - } -} - -struct MeowWidgetEntryView: View { - var entry: Provider.Entry - @Environment(\.widgetFamily) var family - - var body: some View { - VStack(alignment: .leading) { - HStack { - Text("喵哩喵哩") - .font(.headline) - .foregroundColor(Color("WidgetTitleColor")) - } - - Spacer().frame(height: 10) - - switch family { - case .systemSmall: - Text("在喵哩喵哩查看视频") - .font(.headline) - - case .systemMedium: - Text(entry.videoTitle) - .font(.headline) - Text(entry.videoDescription) - .font(.subheadline) - - case .systemLarge: - Text(entry.videoTitle) - .font(.headline) - Text(entry.videoDescription) - .font(.subheadline) - VStack(alignment: .leading) { - Text("作者: \(entry.videoAuthor)") - .font(.footnote) - Text("播放量: \(entry.videoViews)") - .font(.footnote) - } - Spacer() - Text("在喵哩喵哩查看视频") - .font(.footnote) - .foregroundColor(.gray) - - case .accessoryCircular, .accessoryRectangular: - if entry.videoTitle == "打开喵哩喵哩" { - Text("打开喵哩喵哩") - .font(.headline) - } else { - Text(entry.videoTitle) - .font(.headline) - } - - default: - Text(entry.videoTitle) - .font(.headline) - Text(entry.videoDescription) - .font(.subheadline) - } - } - .padding() - .widgetURL(URL(string: "meowbili://")!) - } -} - - -struct MeowWidget: Widget { - let kind: String = "MeowWidget" - - var body: some WidgetConfiguration { - StaticConfiguration(kind: kind, provider: Provider()) { entry in - MeowWidgetEntryView(entry: entry) - } - .configurationDisplayName("喵哩喵哩小组件") - .description("热门或推荐的视频内容") - .supportedFamilies(families) - } - - private var families: [WidgetFamily] { - #if os(watchOS) - return [.accessoryCircular, .accessoryRectangular] - #else - return [.systemSmall, .systemMedium, .systemLarge, .accessoryCircular, .accessoryRectangular] - #endif - } -} -*/