Minor fixes

This commit is contained in:
世界
2026-01-03 00:55:17 +08:00
parent 52db9bbb39
commit 64e2ece819
7 changed files with 65 additions and 27 deletions
@@ -94,6 +94,7 @@ final class LubyTransformEncoder {
// Ideal Soliton Distribution for degree selection
private func getRandomDegree() -> Int {
guard k > 1 else { return k }
var probabilities = [Double](repeating: 0, count: k)
probabilities[0] = 1.0 / Double(k)
for d in 2 ... k {
@@ -78,11 +78,6 @@ public struct ProfileCard: View {
QRCodeSheet(profileName: profile.name, remoteURL: remoteURL)
}
}
.sheet(isPresented: $viewModel.showQRSShare) {
if let profile = selectedProfile, let data = try? profile.origin.toContent().encode() {
QRSSheet(profileName: profile.name, profileData: data)
}
}
#else
.sheet(isPresented: $viewModel.showNewProfile, onDismiss: {
environments.profileUpdate.send()
@@ -269,10 +264,12 @@ public struct ProfileCard: View {
}
}
Button {
viewModel.showQRSShare = true
} label: {
Label("Share as QRS Code", systemImage: "barcode")
if let data = try? profile.origin.toContent().encode() {
FormNavigationLink {
QRSSheet(profileName: profile.name, profileData: data)
} label: {
Label("Share as QRS Code", systemImage: "qrcode")
}
}
} label: {
Image(systemName: "square.and.arrow.up")
@@ -317,7 +314,7 @@ public struct ProfileCard: View {
Button {
viewModel.showQRSShare = true
} label: {
Label("Share as QRS Code", systemImage: "barcode")
Label("Share as QRS Code", systemImage: "qrcode")
}
} label: {
Image(systemName: "square.and.arrow.up")
@@ -497,10 +494,12 @@ extension ProfileCard {
@Published var alert: AlertState?
@Published var profileToEdit: Profile?
@Published var shareItemType: ShareItemType?
#if !os(tvOS)
@Published var profileExportDocument: ProfileExportDocument?
@Published var showProfileExporter = false
@Published var profileJSONExportDocument: ProfileJSONExportDocument?
@Published var showJSONExporter = false
#endif
#if os(macOS)
var shareButtonView: NSView?
#endif
@@ -570,11 +570,6 @@ private struct ProfilePickerRow: View {
QRCodeSheet(profileName: profile.name, remoteURL: remoteURL)
}
}
.sheet(isPresented: $showQRSShare) {
if let data = try? profile.origin.toContent().encode() {
QRSSheet(profileName: profile.name, profileData: data)
}
}
}
private var tvOSNormalBody: some View {
@@ -632,10 +627,12 @@ private struct ProfilePickerRow: View {
}
}
Button {
showQRSShare = true
} label: {
Label("Share as QRS Code", systemImage: "barcode")
if let data = try? profile.origin.toContent().encode() {
FormNavigationLink {
QRSSheet(profileName: profile.name, profileData: data)
} label: {
Label("Share as QRS Code", systemImage: "barcode")
}
}
} label: {
Label("Share", systemImage: "square.and.arrow.up")
+8 -5
View File
@@ -271,13 +271,16 @@ private struct LogContentInnerView: View {
@ViewBuilder
private var emptyContent: some View {
if dataModel.isConnected {
Text("Empty logs")
} else {
Text("Service not started").onAppear {
environments.connect()
Group {
if dataModel.isConnected {
Text("Empty logs")
} else {
Text("Service not started").onAppear {
environments.connect()
}
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
private var logScrollView: some View {
@@ -47,20 +47,56 @@ public struct QRSDisplayView: View {
HStack {
Text(String(localized: "FPS"))
Spacer()
#if os(tvOS)
Button {
fps = max(1, fps - 1)
} label: {
Image(systemName: "minus")
}
Text(verbatim: "\(Int(fps))")
.foregroundStyle(.secondary)
.frame(minWidth: 50)
Button {
fps = min(60, fps + 1)
} label: {
Image(systemName: "plus")
}
#else
Text(verbatim: "\(Int(fps))")
.foregroundStyle(.secondary)
#endif
}
#if !os(tvOS)
Slider(value: $fps, in: 1 ... 60, step: 1)
#endif
HStack {
Text(String(localized: "Slice Size"))
Spacer()
#if os(tvOS)
Button {
sliceSize = max(100, sliceSize - 100)
} label: {
Image(systemName: "minus")
}
Text("\(Int(sliceSize))")
.foregroundStyle(.secondary)
.frame(minWidth: 50)
Button {
sliceSize = min(1500, sliceSize + 100)
} label: {
Image(systemName: "plus")
}
#else
Text("\(Int(sliceSize))")
.foregroundStyle(.secondary)
#endif
}
#if !os(tvOS)
Slider(value: $sliceSize, in: 100 ... 1500, step: 100)
#endif
}
.padding(.horizontal)
@@ -96,10 +96,10 @@ public struct SettingView: View {
public init() {}
public var body: some View {
FormView {
#if os(macOS)
Tabs.app.navigationLink
#endif
Section {
#if os(macOS)
Tabs.app.navigationLink
#endif
ForEach([Tabs.core, Tabs.packetTunnel, Tabs.onDemandRules, Tabs.profileOverride]) { it in
it.navigationLink
}
@@ -118,6 +118,7 @@ public extension UTType {
static var profile: UTType { .init(exportedAs: "io.nekohasekai.sfavt.profile") }
}
#if !os(tvOS)
// MARK: - FileDocument for Export
public struct ProfileExportDocument: FileDocument {
@@ -175,3 +176,4 @@ public struct ProfileJSONExportDocument: FileDocument {
return FileWrapper(regularFileWithContents: data)
}
}
#endif