Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

允许通过哔哩哔哩打开小组件中的视频 #436

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1600"
version = "1.7">
version = "1.8">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -1885,7 +1885,7 @@
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "🇼🇸 Western Samoa 684"
"value" : "🇼🇸 Western Samoa 685"
}
}
}
Expand Down
21 changes: 16 additions & 5 deletions MeowBili/Others/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -589,12 +589,12 @@ struct SoundAHapticSettingsView: View {

struct WidgetSettingsView: View {
@AppStorage("WidgetRefreshInterval") var refreshInterval: Int = 10
// @State var isNewToWidget = true for future updates
@AppStorage("WidgetOpenWithBiliBili") var openWithBili = false
var body: some View {
// Here we go refreshment settings
Form {
Section(header: Text("小组件刷新时间")){
Picker("刷新时间", selection: $refreshInterval){
Section(header: Text("刷新")){
// Here we go refreshment settings
Picker("小组件刷新时间", selection: $refreshInterval){
Text("5分钟").tag(5)
Text("10分钟(默认)").tag(10)
Text("15分钟").tag(15)
Expand All @@ -603,8 +603,19 @@ struct WidgetSettingsView: View {
Text("2小时").tag(120)
}
}
// Customize which app to open
Section(header: Text("打开方式")){
Picker("小组件视频打开方式", selection: $openWithBili){
Text("喵哩喵哩").tag(false)
Text("哔哩哔哩").tag(true)
}
if openWithBili == true {
Text("要通过哔哩哔哩打开小组件中展示的视频,你需要在设备上安装哔哩哔哩客户端。")
} else {
Text("目前仅支持打开喵哩喵哩客户端主页。")
}
}
}
// Here comes more features
}
}

Expand Down
6 changes: 6 additions & 0 deletions MeowWidget/MeowWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ struct Provider: TimelineProvider {

struct MeowWidgetView: View {
@Environment(\.widgetFamily) var family
@AppStorage("WidgetOpenWithBiliBili") var openWithBili = false
var entry: MeowWidgetEntry

var body: some View {
let widgetURL = URL(string: "wget://openURL/\(entry.video.id)")
if openWithBili == true {
let widgetURL = URL(string: "https://www.bilibili.com/video/\(entry.video.id)")
} else {
let widgetURL = URL(string: "wget://openURL/\(entry.video.id)")
}
switch family {
case .accessoryInline:
Text(entry.video.title)
Expand Down