mirror of
https://github.com/xweiba/location-spoofer.git
synced 2026-09-26 16:41:54 +08:00
feat: add GitHub community and bug workflows
This commit is contained in:
+13
-9
@@ -7,15 +7,17 @@ struct BugReportView: View {
|
||||
@State private var isReproducible = true
|
||||
@State private var isRunning = false
|
||||
@State private var showCopiedAlert = false
|
||||
@State private var githubDestination: SafariDestination?
|
||||
@ObservedObject private var runtimeMode = ProxyRuntimeModeStore.shared
|
||||
@ObservedObject private var thirdPartyProxy = ThirdPartyProxyManager.shared
|
||||
@ObservedObject private var thirdPartyClient = ThirdPartyProxyClientStore.shared
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
// 说明
|
||||
Text("遇到问题时,在这里生成 Issue 报告。系统会运行一次诊断测试,将测试结果和你的描述一起复制到剪切板,然后跳转到 GitHub 提交。")
|
||||
Text("遇到问题时,在这里生成 Bug 报告。系统会运行一次诊断测试,并将完整报告复制到剪切板。跳转到 GitHub 后,请粘贴到“App 生成的诊断报告”字段。")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
|
||||
@@ -54,7 +56,7 @@ struct BugReportView: View {
|
||||
if isRunning {
|
||||
ProgressView().tint(.white)
|
||||
}
|
||||
Text(isRunning ? "正在生成报告…" : "生成 Issue 报告")
|
||||
Text(isRunning ? "正在生成报告…" : "生成 Bug 报告")
|
||||
.font(.body.weight(.medium))
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
@@ -67,20 +69,21 @@ struct BugReportView: View {
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.bottom, 12)
|
||||
}
|
||||
.navigationTitle("报告 Issue")
|
||||
.navigationTitle("报告 Bug")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.alert("已生成", isPresented: $showCopiedAlert) {
|
||||
Button("跳转到 GitHub") {
|
||||
dismiss()
|
||||
if let url = URL(string: "https://github.com/xweiba/location-spoofer/issues/new") {
|
||||
UIApplication.shared.open(url)
|
||||
}
|
||||
Button("打开 GitHub 表单") {
|
||||
githubDestination = SafariDestination(url: GitHubSubmission.bugReportURL)
|
||||
}
|
||||
Button("稍后再说", role: .cancel) {
|
||||
dismiss()
|
||||
}
|
||||
} message: {
|
||||
Text("Issue 报告已复制到剪切板。请在 GitHub Issues 页面粘贴并提交。")
|
||||
Text("Bug 报告已复制到剪切板。请在 GitHub 表单的“App 生成的诊断报告”字段中粘贴并提交。")
|
||||
}
|
||||
.sheet(item: $githubDestination) { destination in
|
||||
SafariView(url: destination.url)
|
||||
.ignoresSafeArea()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +118,7 @@ struct BugReportView: View {
|
||||
App 版本: \(appVersion)
|
||||
系统版本: iOS \(systemVersion)
|
||||
运行模式: \(runtimeMode.mode.displayName)
|
||||
第三方客户端: \(runtimeMode.mode == .thirdParty ? thirdPartyClient.selectedClient.name : "不适用")
|
||||
可复现环境: \(isReproducible ? "是" : "否")
|
||||
|
||||
### 问题描述
|
||||
|
||||
+17
-41
@@ -75,6 +75,7 @@ struct MapHomeView: View {
|
||||
@State private var pendingCommunityContributionClient: ThirdPartyProxyClient?
|
||||
@State private var communityContributionClient: ThirdPartyProxyClient?
|
||||
@State private var showCommunityTemplateCopied = false
|
||||
@State private var githubDestination: SafariDestination?
|
||||
@State private var editingFavorite: FavoriteLocation?
|
||||
@State private var editName = ""
|
||||
@State private var reverseGeocodeTask: Task<Void, Never>?
|
||||
@@ -267,17 +268,28 @@ struct MapHomeView: View {
|
||||
.sheet(item: $activeTip) { kind in
|
||||
TipSheetView(kind: kind, runtimeMode: runtimeMode.mode)
|
||||
}
|
||||
.sheet(item: $githubDestination) { destination in
|
||||
SafariView(url: destination.url)
|
||||
.ignoresSafeArea()
|
||||
}
|
||||
.alert("社区分享成功配置?", isPresented: Binding(
|
||||
get: { communityContributionClient != nil },
|
||||
set: { if !$0 { communityContributionClient = nil } }
|
||||
)) {
|
||||
Button("去提交") {
|
||||
guard let client = communityContributionClient else { return }
|
||||
openCommunityContributionIssue(for: client)
|
||||
UIPasteboard.general.string = GitHubSubmission.communityContributionTemplate(
|
||||
for: client,
|
||||
systemVersion: UIDevice.current.systemVersion
|
||||
)
|
||||
openCommunityContributionPage()
|
||||
}
|
||||
Button("复制模板") {
|
||||
guard let client = communityContributionClient else { return }
|
||||
UIPasteboard.general.string = communityContributionIssueBody(for: client)
|
||||
UIPasteboard.general.string = GitHubSubmission.communityContributionTemplate(
|
||||
for: client,
|
||||
systemVersion: UIDevice.current.systemVersion
|
||||
)
|
||||
showCommunityTemplateCopied = true
|
||||
}
|
||||
if communityPromptPreferences.canSuppress() {
|
||||
@@ -289,7 +301,7 @@ struct MapHomeView: View {
|
||||
}
|
||||
} message: {
|
||||
Text(
|
||||
"你正在使用 \(communityContributionClient?.name ?? "第三方客户端")。欢迎分享成功配置,采纳后将收录到 README,可选择是否匿名署名。提交前请移除账号、订阅和其他敏感信息。"
|
||||
"你正在使用 \(communityContributionClient?.name ?? "第三方客户端")。点击“去提交”会先复制投稿模板,并在 App 内打开社区页面。采纳后将收录到 README,可选择是否匿名署名。"
|
||||
)
|
||||
}
|
||||
.alert("已复制投稿模板", isPresented: $showCommunityTemplateCopied) {
|
||||
@@ -781,44 +793,8 @@ struct MapHomeView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private func openCommunityContributionIssue(for client: ThirdPartyProxyClient) {
|
||||
let issueBody = communityContributionIssueBody(for: client)
|
||||
var components = URLComponents(
|
||||
string: "https://github.com/xweiba/location-spoofer/issues/new"
|
||||
)
|
||||
components?.queryItems = [
|
||||
URLQueryItem(
|
||||
name: "title",
|
||||
value: "[第三方配置分享] \(client.name) 成功配置"
|
||||
),
|
||||
URLQueryItem(
|
||||
name: "body",
|
||||
value: issueBody
|
||||
),
|
||||
URLQueryItem(
|
||||
name: "labels",
|
||||
value: "community-config,client-\(client.rawValue)"
|
||||
)
|
||||
]
|
||||
guard let url = components?.url else { return }
|
||||
UIApplication.shared.open(url)
|
||||
}
|
||||
|
||||
private func communityContributionIssueBody(for client: ThirdPartyProxyClient) -> String {
|
||||
"""
|
||||
## 客户端
|
||||
\(client.name)
|
||||
|
||||
## 配置说明
|
||||
请描述模块导入、MITM、证书和代理连接步骤,并附上必要截图。
|
||||
|
||||
## README 收录署名
|
||||
- [ ] 匿名收录,不在 README 展示投稿账号
|
||||
|
||||
## 隐私确认
|
||||
- [ ] 已移除账号、订阅地址、密码、设备标识、真实位置等敏感信息
|
||||
- [ ] 原始截图除敏感信息遮挡外未添加其他标注
|
||||
"""
|
||||
private func openCommunityContributionPage() {
|
||||
githubDestination = SafariDestination(url: GitHubSubmission.communityContributionURL)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import SafariServices
|
||||
import SwiftUI
|
||||
|
||||
struct SafariDestination: Identifiable {
|
||||
let id = UUID()
|
||||
let url: URL
|
||||
}
|
||||
|
||||
struct SafariView: UIViewControllerRepresentable {
|
||||
let url: URL
|
||||
|
||||
|
||||
+32
-1
@@ -14,6 +14,7 @@ struct SettingsView: View {
|
||||
@State private var modeOperationRunning = false
|
||||
@State private var copiedClient: ThirdPartyProxyClient?
|
||||
@State private var showCertificateResetConfirmation = false
|
||||
@State private var githubDestination: SafariDestination?
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
@@ -120,7 +121,33 @@ struct SettingsView: View {
|
||||
NavigationLink {
|
||||
BugReportView(setup: setup)
|
||||
} label: {
|
||||
Label("报告 Issue", systemImage: "ladybug")
|
||||
Label("报告 Bug", systemImage: "ladybug")
|
||||
}
|
||||
|
||||
Button {
|
||||
githubDestination = SafariDestination(url: GitHubSubmission.usageHelpURL)
|
||||
} label: {
|
||||
Label("使用帮助", systemImage: "questionmark.circle")
|
||||
}
|
||||
|
||||
Button {
|
||||
githubDestination = SafariDestination(url: GitHubSubmission.featureRequestURL)
|
||||
} label: {
|
||||
Label("功能建议", systemImage: "lightbulb")
|
||||
}
|
||||
|
||||
if runtimeMode.mode == .thirdParty {
|
||||
Button {
|
||||
UIPasteboard.general.string = GitHubSubmission.communityContributionTemplate(
|
||||
for: thirdPartyClient.selectedClient,
|
||||
systemVersion: UIDevice.current.systemVersion
|
||||
)
|
||||
githubDestination = SafariDestination(
|
||||
url: GitHubSubmission.communityContributionURL
|
||||
)
|
||||
} label: {
|
||||
Label("分享第三方配置", systemImage: "square.and.arrow.up")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,6 +183,10 @@ struct SettingsView: View {
|
||||
.sheet(item: $activeTip) { kind in
|
||||
TipSheetView(kind: kind)
|
||||
}
|
||||
.sheet(item: $githubDestination) { destination in
|
||||
SafariView(url: destination.url)
|
||||
.ignoresSafeArea()
|
||||
}
|
||||
.alert(proxyOperationAlertTitle, isPresented: Binding(
|
||||
get: { !proxyOperationError.isEmpty },
|
||||
set: { if !$0 { proxyOperationError = "" } }
|
||||
|
||||
Reference in New Issue
Block a user