iOS 1.0.3 source candidate only; no Apple build or installation acceptance
This commit is contained in:
+261
-94
@@ -5,7 +5,8 @@ struct ContentView: View {
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
UCVLColors.background.ignoresSafeArea()
|
||||
LandscapeArtwork()
|
||||
.ignoresSafeArea()
|
||||
if let profile = state.profile {
|
||||
DashboardView(profile: profile)
|
||||
} else {
|
||||
@@ -13,6 +14,8 @@ struct ContentView: View {
|
||||
}
|
||||
}
|
||||
.tint(UCVLColors.royal)
|
||||
.foregroundColor(UCVLColors.navy)
|
||||
.preferredColorScheme(.light)
|
||||
.alert("提示", isPresented: Binding(
|
||||
get: { !state.errorMessage.isEmpty },
|
||||
set: { if !$0 { state.errorMessage = "" } }
|
||||
@@ -24,23 +27,81 @@ struct ContentView: View {
|
||||
}
|
||||
}
|
||||
|
||||
// Both placements draw the same original asset with a native aspect-fill crop.
|
||||
// Artwork remains separate from the real controls and never changes VPN state.
|
||||
private struct LandscapeArtwork: View {
|
||||
var body: some View {
|
||||
GeometryReader { geometry in
|
||||
Image("MountainLandscape")
|
||||
.resizable()
|
||||
.scaledToFill()
|
||||
.frame(width: geometry.size.width, height: geometry.size.height)
|
||||
.clipped()
|
||||
}
|
||||
.background(UCVLColors.surface)
|
||||
.allowsHitTesting(false)
|
||||
.accessibilityHidden(true)
|
||||
}
|
||||
}
|
||||
|
||||
private struct ScenicPage<Content: View>: View {
|
||||
let maxWidth: CGFloat
|
||||
let content: Content
|
||||
|
||||
init(maxWidth: CGFloat, @ViewBuilder content: () -> Content) {
|
||||
self.maxWidth = maxWidth
|
||||
self.content = content()
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
content
|
||||
.frame(maxWidth: maxWidth)
|
||||
.padding(.horizontal, 18)
|
||||
.padding(.vertical, 24)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct BrandHeader: View {
|
||||
var compact = false
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: compact ? 8 : 16) {
|
||||
VStack(spacing: compact ? 8 : 12) {
|
||||
Image("UCVLLogo")
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(width: compact ? 84 : 132, height: compact ? 84 : 132)
|
||||
.accessibilityLabel("优创未来 Logo")
|
||||
Text("优创⁺纵横家")
|
||||
.frame(width: compact ? 60 : 88, height: compact ? 60 : 88)
|
||||
.accessibilityHidden(true)
|
||||
Text("纵横家")
|
||||
.font(compact ? .title2.bold() : .largeTitle.bold())
|
||||
.foregroundStyle(.white)
|
||||
Text("优创未来安全网络")
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(UCVLColors.sky)
|
||||
.foregroundStyle(UCVLColors.navy)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
Text(AppVersion.label)
|
||||
.font(.caption)
|
||||
.foregroundStyle(UCVLColors.muted)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
.multilineTextAlignment(.center)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, compact ? 16 : 24)
|
||||
.background {
|
||||
LandscapeArtwork()
|
||||
.overlay(Color.white.opacity(0.18))
|
||||
.mask(LinearGradient(colors: [.black, .black, .clear], startPoint: .top, endPoint: .bottom))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private enum AppVersion {
|
||||
static var label: String {
|
||||
let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String
|
||||
let build = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String
|
||||
guard let version, !version.isEmpty else { return "版本信息不可用" }
|
||||
guard let build, !build.isEmpty else { return "版本 \(version)" }
|
||||
return "版本 \(version) (\(build))"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,36 +109,39 @@ private struct LoginView: View {
|
||||
@EnvironmentObject private var state: AppState
|
||||
@State private var identifier = SecureStore.lastLogin
|
||||
@State private var password = ""
|
||||
@FocusState private var focusedField: Field?
|
||||
|
||||
private enum Field: Hashable { case identifier, password }
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
VStack(spacing: 28) {
|
||||
ScenicPage(maxWidth: 540) {
|
||||
VStack(spacing: 20) {
|
||||
BrandHeader()
|
||||
.padding(.top, 34)
|
||||
VStack(alignment: .leading, spacing: 18) {
|
||||
Text("公司统一账号登录")
|
||||
.font(.title2.bold())
|
||||
.foregroundStyle(UCVLColors.navy)
|
||||
TextField("用户名或邮箱", text: $identifier)
|
||||
.textInputAutocapitalization(.never)
|
||||
.autocorrectionDisabled()
|
||||
.disableAutocorrection(true)
|
||||
.keyboardType(.emailAddress)
|
||||
.textContentType(.username)
|
||||
.submitLabel(.next)
|
||||
.focused($focusedField, equals: .identifier)
|
||||
.ucvlField()
|
||||
.onSubmit { focusedField = .password }
|
||||
SecureField("密码", text: $password)
|
||||
.textContentType(.password)
|
||||
.submitLabel(.go)
|
||||
.focused($focusedField, equals: .password)
|
||||
.ucvlField()
|
||||
.onSubmit { Task { await state.login(identifier: identifier, password: password) } }
|
||||
Button {
|
||||
Task {
|
||||
await state.login(identifier: identifier, password: password)
|
||||
if state.profile != nil { password = "" }
|
||||
}
|
||||
} label: {
|
||||
.onSubmit { signIn() }
|
||||
Button(action: signIn) {
|
||||
HStack {
|
||||
if state.busy { ProgressView().tint(.white) }
|
||||
Text(state.busy ? "正在登录…" : "安全登录").fontWeight(.semibold)
|
||||
}
|
||||
.foregroundColor(.white)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.vertical, 14)
|
||||
}
|
||||
@@ -85,65 +149,113 @@ private struct LoginView: View {
|
||||
.disabled(state.busy)
|
||||
Text("账号停用后,设备授权与线路将自动失效。")
|
||||
.font(.footnote)
|
||||
.foregroundStyle(.secondary)
|
||||
HStack {
|
||||
Text("还没有账号?")
|
||||
.font(.footnote)
|
||||
.foregroundStyle(.secondary)
|
||||
Link("注册新用户", destination: URL(string: "https://vpn.toplc.cn/register/")!)
|
||||
.font(.footnote.weight(.semibold))
|
||||
}
|
||||
.foregroundStyle(UCVLColors.muted)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
RegistrationPrompt()
|
||||
}
|
||||
.padding(24)
|
||||
.background(.white, in: RoundedRectangle(cornerRadius: 24, style: .continuous))
|
||||
.shadow(color: .black.opacity(0.14), radius: 24, y: 12)
|
||||
.frame(maxWidth: 540)
|
||||
Text("vpn.toplc.cn · © 2026 UCVL")
|
||||
.font(.footnote)
|
||||
.foregroundStyle(UCVLColors.sky)
|
||||
.padding(.bottom, 30)
|
||||
.padding(20)
|
||||
.scenicCard(cornerRadius: 24)
|
||||
}
|
||||
.padding(.horizontal, 20)
|
||||
}
|
||||
.toolbar {
|
||||
ToolbarItemGroup(placement: .keyboard) {
|
||||
Spacer()
|
||||
Button("完成") { focusedField = nil }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func signIn() {
|
||||
focusedField = nil
|
||||
Task {
|
||||
await state.login(identifier: identifier, password: password)
|
||||
if state.profile != nil { password = "" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct RegistrationPrompt: View {
|
||||
private var message: AttributedString {
|
||||
var prompt = AttributedString("还没有账号?")
|
||||
prompt.foregroundColor = UCVLColors.muted
|
||||
var link = AttributedString("注册新用户")
|
||||
link.link = URL(string: "https://vpn.example.invalid/register/")
|
||||
link.foregroundColor = UCVLColors.royal
|
||||
link.font = .footnote.weight(.semibold)
|
||||
prompt.append(link)
|
||||
return prompt
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
// A single inline run shares a baseline and wraps naturally at large sizes.
|
||||
Text(message)
|
||||
.font(.footnote)
|
||||
.lineSpacing(4)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
}
|
||||
|
||||
private struct DashboardHeader: View {
|
||||
@Environment(\.horizontalSizeClass) private var sizeClass
|
||||
@Environment(\.dynamicTypeSize) private var dynamicTypeSize
|
||||
let profile: ClientProfile
|
||||
|
||||
private var account: some View {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Text("你好,\(profile.displayName.isEmpty ? profile.username : profile.displayName)")
|
||||
.font(.headline)
|
||||
Text(profile.email)
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(UCVLColors.muted)
|
||||
Text(profile.identityType == "employee" ? "内部员工" : "外部联系人")
|
||||
.font(.caption)
|
||||
.foregroundStyle(UCVLColors.muted)
|
||||
}
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
if sizeClass == .regular && !dynamicTypeSize.isAccessibilitySize {
|
||||
HStack(spacing: 24) {
|
||||
BrandHeader(compact: true)
|
||||
account
|
||||
}
|
||||
} else {
|
||||
VStack(spacing: 16) {
|
||||
BrandHeader(compact: true)
|
||||
account
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(18)
|
||||
.scenicCard()
|
||||
}
|
||||
}
|
||||
|
||||
private struct DashboardView: View {
|
||||
@EnvironmentObject private var state: AppState
|
||||
@Environment(\.horizontalSizeClass) private var sizeClass
|
||||
@Environment(\.dynamicTypeSize) private var dynamicTypeSize
|
||||
let profile: ClientProfile
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
ScenicPage(maxWidth: 760) {
|
||||
VStack(spacing: 18) {
|
||||
HStack(spacing: 16) {
|
||||
BrandHeader(compact: true)
|
||||
Spacer()
|
||||
VStack(alignment: .trailing, spacing: 4) {
|
||||
Text("你好,\(profile.displayName.isEmpty ? profile.username : profile.displayName)")
|
||||
.font(.headline)
|
||||
.foregroundStyle(.white)
|
||||
Text("\(profile.email) · \(profile.identityType == "employee" ? "内部员工" : "外部联系人")")
|
||||
.font(.caption)
|
||||
.foregroundStyle(UCVLColors.sky)
|
||||
}
|
||||
}
|
||||
.padding(.vertical, 8)
|
||||
DashboardHeader(profile: profile)
|
||||
|
||||
StatusCard()
|
||||
|
||||
UCVLCard(title: "工作节点与代理模式", systemImage: "point.3.connected.trianglepath.dotted") {
|
||||
VStack(spacing: 14) {
|
||||
HStack {
|
||||
Text("当前工作节点")
|
||||
Spacer()
|
||||
AdaptiveDetailRow(title: "当前工作节点") {
|
||||
Text(state.currentNode?.displayName ?? "由 vpn-ai 自动选择")
|
||||
.foregroundStyle(state.currentNode == nil ? .secondary : UCVLColors.royal)
|
||||
.multilineTextAlignment(.trailing)
|
||||
.foregroundStyle(state.currentNode == nil ? UCVLColors.muted : UCVLColors.royal)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
Divider()
|
||||
HStack {
|
||||
Text("代理模式")
|
||||
Spacer()
|
||||
AdaptiveDetailRow(title: "代理模式") {
|
||||
Picker("代理模式", selection: $state.selectedRouteID) {
|
||||
ForEach(profile.routeModes) { route in Text(route.name).tag(route.id) }
|
||||
}
|
||||
@@ -158,6 +270,7 @@ private struct DashboardView: View {
|
||||
Image(systemName: state.vpn.isConnected ? "stop.fill" : "bolt.shield.fill")
|
||||
Text(state.vpn.isConnected ? "断开连接" : "连接")
|
||||
}
|
||||
.foregroundColor(.white)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.vertical, 12)
|
||||
}
|
||||
@@ -169,25 +282,66 @@ private struct DashboardView: View {
|
||||
|
||||
UsageCard(subscription: profile.subscription)
|
||||
|
||||
HStack(spacing: 12) {
|
||||
Button { Task { await state.refresh() } } label: {
|
||||
Label("刷新", systemImage: "arrow.clockwise")
|
||||
.frame(maxWidth: .infinity)
|
||||
Group {
|
||||
if sizeClass == .regular && !dynamicTypeSize.isAccessibilitySize {
|
||||
HStack(spacing: 12) { accountActions }
|
||||
} else {
|
||||
VStack(spacing: 12) { accountActions }
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.disabled(state.busy)
|
||||
Button(role: .destructive) { Task { await state.logout() } } label: {
|
||||
Label("退出账号", systemImage: "rectangle.portrait.and.arrow.right")
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.disabled(state.busy)
|
||||
}
|
||||
.padding(16)
|
||||
.scenicCard()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder private var accountActions: some View {
|
||||
Button { Task { await state.refresh() } } label: {
|
||||
Label("刷新", systemImage: "arrow.clockwise")
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.vertical, 6)
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.disabled(state.busy)
|
||||
Button(role: .destructive) { Task { await state.logout() } } label: {
|
||||
Label("退出账号", systemImage: "rectangle.portrait.and.arrow.right")
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.vertical, 6)
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.disabled(state.busy)
|
||||
}
|
||||
}
|
||||
|
||||
private struct AdaptiveDetailRow<Content: View>: View {
|
||||
@Environment(\.dynamicTypeSize) private var dynamicTypeSize
|
||||
let title: String
|
||||
let content: Content
|
||||
|
||||
init(title: String, @ViewBuilder content: () -> Content) {
|
||||
self.title = title
|
||||
self.content = content()
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
if dynamicTypeSize.isAccessibilitySize {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Text(title)
|
||||
content
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
} else {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 12) {
|
||||
Text(title)
|
||||
.fixedSize(horizontal: true, vertical: false)
|
||||
content
|
||||
.multilineTextAlignment(.trailing)
|
||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: 760)
|
||||
.padding(.horizontal, 18)
|
||||
.padding(.vertical, 18)
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,17 +350,19 @@ private struct StatusCard: View {
|
||||
|
||||
var body: some View {
|
||||
UCVLCard(title: "连接状态", systemImage: "network.badge.shield.half.filled") {
|
||||
HStack(spacing: 14) {
|
||||
HStack(alignment: .top, spacing: 14) {
|
||||
Circle()
|
||||
.fill(state.statusIsActive ? Color.green : Color.gray)
|
||||
.fill(state.statusIsActive ? UCVLColors.success : UCVLColors.muted)
|
||||
.frame(width: 13, height: 13)
|
||||
.padding(.top, 6)
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text(state.statusTitle).font(.title3.bold())
|
||||
Text(state.message.isEmpty ? "点击连接,vpn-ai 将自动选择并验证工作节点" : state.message)
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(.secondary)
|
||||
.foregroundStyle(UCVLColors.muted)
|
||||
}
|
||||
Spacer()
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -223,17 +379,21 @@ private struct UsageCard: View {
|
||||
var body: some View {
|
||||
UCVLCard(title: "本期流量", systemImage: "chart.bar.fill") {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
HStack {
|
||||
AdaptiveDetailRow(title: "已用流量") {
|
||||
Text(format(subscription.usedBytes))
|
||||
Spacer()
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
AdaptiveDetailRow(title: "套餐流量") {
|
||||
Text(subscription.trafficLimitBytes > 0 ? format(subscription.trafficLimitBytes) : "不限流量")
|
||||
.foregroundStyle(UCVLColors.royal)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
ProgressView(value: fraction)
|
||||
.tint(UCVLColors.royal)
|
||||
Text("套餐:\(subscription.plan) · 设备上限 \(subscription.deviceLimit) 台\(expiryText)")
|
||||
.font(.footnote)
|
||||
.foregroundStyle(.secondary)
|
||||
.foregroundStyle(UCVLColors.muted)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -264,31 +424,38 @@ private struct UCVLCard<Content: View>: View {
|
||||
Label(title, systemImage: systemImage)
|
||||
.font(.headline)
|
||||
.foregroundStyle(UCVLColors.navy)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
content
|
||||
}
|
||||
.padding(20)
|
||||
.background(.white, in: RoundedRectangle(cornerRadius: 22, style: .continuous))
|
||||
.shadow(color: .black.opacity(0.08), radius: 14, y: 7)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.scenicCard()
|
||||
}
|
||||
}
|
||||
|
||||
private enum UCVLColors {
|
||||
static let navy = Color(red: 0.02, green: 0.10, blue: 0.26)
|
||||
static let royal = Color(red: 0.02, green: 0.39, blue: 0.86)
|
||||
static let sky = Color(red: 0.17, green: 0.73, blue: 0.98)
|
||||
static let background = LinearGradient(
|
||||
colors: [navy, Color(red: 0.03, green: 0.25, blue: 0.48)],
|
||||
startPoint: .topLeading,
|
||||
endPoint: .bottomTrailing
|
||||
)
|
||||
static let navy = Color(red: 10 / 255, green: 34 / 255, blue: 91 / 255)
|
||||
static let royal = Color(red: 0, green: 80 / 255, blue: 221 / 255)
|
||||
static let muted = Color(red: 52 / 255, green: 79 / 255, blue: 116 / 255)
|
||||
static let surface = Color(red: 237 / 255, green: 248 / 255, blue: 1)
|
||||
static let success = Color(red: 0, green: 113 / 255, blue: 110 / 255)
|
||||
}
|
||||
|
||||
private extension View {
|
||||
func scenicCard(cornerRadius: CGFloat = 22) -> some View {
|
||||
self
|
||||
.background(Color.white.opacity(0.50), in: RoundedRectangle(cornerRadius: cornerRadius, style: .continuous))
|
||||
.overlay(RoundedRectangle(cornerRadius: cornerRadius, style: .continuous).stroke(Color.white.opacity(0.55)))
|
||||
.shadow(color: UCVLColors.navy.opacity(0.08), radius: 14, y: 7)
|
||||
}
|
||||
|
||||
func ucvlField() -> some View {
|
||||
self
|
||||
.foregroundColor(UCVLColors.navy)
|
||||
.padding(.horizontal, 14)
|
||||
.frame(height: 52)
|
||||
.background(Color.gray.opacity(0.08), in: RoundedRectangle(cornerRadius: 13))
|
||||
.overlay(RoundedRectangle(cornerRadius: 13).stroke(Color.gray.opacity(0.2)))
|
||||
.padding(.vertical, 14)
|
||||
.frame(minHeight: 52)
|
||||
.background(Color.white.opacity(0.72), in: RoundedRectangle(cornerRadius: 13))
|
||||
.overlay(RoundedRectangle(cornerRadius: 13).stroke(UCVLColors.navy.opacity(0.16)))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user