SOURCE RECORD · S06

S06 · VPN TP

Explicit UI test arguments and local sample import

公开摘录 · 截取原件于 2026-09-12 / Captured 2026-09-12

保留原行号。个人/账户信息如有删除,已用 REDACTED 标识。原文件 SHA-256 只用于识别截取时的本机原文件;不能证明编写或提交时间,也不等于脱敏下载文件的哈希。

Original line numbers are retained. Redactions are explicitly marked. The original full-file hash identifies a captured local file, not its creation/submission time or the redacted download. Public-file hashes are listed separately. This is selected source, not a whole-repository or binary absence finding.

Project key: vpn
Original relative path: ConfigStudio/App/ConfigStudioApp.swift
Captured: 2026-09-12T18:57:15+08:00
Original full-file SHA256: 4dfb80e53764be28f98a0adca6e2fe2b03f63dd8d58e958b7cf7d70efda77985
Evidence level: local source excerpt
Build correspondence: not yet established with an Apple-received binary.
Line numbers refer to the captured original file. Gaps are explicitly marked. No source code was changed.

Original lines 1 to 44

0001  import SwiftUI
0002  #if DEBUG && targetEnvironment(macCatalyst)
0003  import UIKit
0004  #endif
0005  
0006  @main
0007  struct ConfigStudioApp: App {
0008      @Environment(\.scenePhase) private var scenePhase
0009      @StateObject private var model: AppViewModel
0010      init() {
0011          let arguments = ProcessInfo.processInfo.arguments
0012          let isTesting = arguments.contains("-UITesting")
0013          if arguments.contains("-ResetAppLanguageForUITest") { UserDefaults.standard.removeObject(forKey: AppLanguage.storageKey) }
0014          if arguments.contains("-ResetOnboardingForUITest") { UserDefaults.standard.set(false, forKey: "hasCompletedOnboarding") }
0015          else if isTesting { UserDefaults.standard.set(true, forKey: "hasCompletedOnboarding") }
0016          let model = AppViewModel(dependencies: AppDependencies(inMemory: isTesting))
0017          if arguments.contains("-LoadDemoDataForUITest") { _ = model.loadDemoDataset() }
0018          if arguments.contains("-LoadSubscriptionGroupForUITest"),
0019             let sourceURL = URL(string: "https://provider.example/nodes.yaml") {
0020              let content = """
0021              trojan://first-password@node-one.example.com:443#Source%20Node%20A
0022              trojan://second-password@node-two.example.com:8443#Source%20Node%20B
0023              """
0024              let items = model.dependencies.importer.preview(content, fileExtension: nil, existing: [])
0025              _ = try? model.importSubscriptionItems(items.items, source: SubscriptionSourceDescriptor(url: sourceURL))
0026          }
0027          if let optionIndex = arguments.firstIndex(of: "-InitialTabForUITest"),
0028             arguments.indices.contains(optionIndex + 1),
0029             let tab = AppTab(rawValue: arguments[optionIndex + 1]) {
0030              model.selectedTab = tab
0031          }
0032          if let optionIndex = arguments.firstIndex(of: "-InitialFeatureForUITest"),
0033             arguments.indices.contains(optionIndex + 1),
0034             let route = FeatureRoute(rawValue: arguments[optionIndex + 1]) {
0035              model.present(route)
0036          }
0037          _model = StateObject(wrappedValue: model)
0038      }
0039      var body: some Scene {
0040          WindowGroup {
0041              AppRootView().environmentObject(model)
0042                  .task { await AdMobManager.shared.configure() }
0043                  .onChange(of: scenePhase) { phase in
0044                      model.handleScenePhase(phase)