1b94df1604
- #7 隔夜被迫重新登录:auth.ts 加 refreshInFlight 单飞刷新。根因=broker 单次轮换 refresh token + 冷启并发 401(引擎 boot 同时 startHub/refreshSessionScope/healIOSIdentity/refreshICEServers,隔夜 access 已过期全部 401)各自用同一 refresh 刷新,首个轮换、其余 replay 失效旧 token → 401 invalid → forceLogout → 清 Keychain → 重登。单飞使并发 401 共享一次轮换。 - #2 通知系统重做:删 EngineController.deviceActionStatus/clipboardStatus 两字段及设备页/设置页内联灰字(串页、不清除);改瞬时横幅 NotificationBanner(NoticeOverlay 顶部覆盖,成功绿/失败红/信息中性、4s 自动消失、可点叉清除),设备移除/改名/剪贴板结果统一走 notify。 - #5 未读红点:EngineController unreadMessages/unreadTransfers/activeTab/seenIncomingTransfers + setActiveTab(进入对应 tab 清零)+ noteIncomingTransfer;RootView Tab .badge + onChange(selection) 同步当前页。 - #1 标签栏重排:传输 / 文件 / 消息 / 设备 / 设置(文件域相邻、设备归管理区近设置)。 - #3 日志独立界面:EngineController logs 环形缓冲(cap 300)+ clearLogs;新增 LogView(最近 N 条、分级配色、可选中、可清空),设置页引擎段「查看日志」NavigationLink。 - #8 扫码登录他端:iOS 此前仅能展示自身码被扫,缺扫描方批准能力。新增 ScannerView(VisionKit DataScannerViewController + 相机权限 + /link?r=&c= 校验);engine/main.ts 导入 qr.ts 加 fetchLoginRequest/approveLogin/denyLogin(qrRequest/qrApprove(full,persist)/qrDeny)+ 回报 loginRequest/loginApproved/loginDenied/loginFailed;EngineController pendingLoginRequest + 方法 + handleNotify;设备页工具栏「扫码登录设备」入口 + 批准确认(展示对端名/类型/IP)。 - #6 主屏小组件 + 应用外反馈:除控制中心两控件外,新增 CloudClipboardWidget(交互式主屏/锁屏小组件,上传/拉取按钮复用同一 AppIntent);新增 WidgetFeedback(App 外触发弹本地通知反馈);ClipboardIntents perform 加成功/失败/空/needApp 反馈。品牌色 Color.cdropAccent 从 RootView 移入 Shared/Theme(主 app 与扩展共用)。 - 长条行交互统一:设备 / 传输历史 / 收到的文件 一致为「点按打开 + 尾部滑动删除 + 长按菜单」。设备去掉「点按即删」、加长按移除;修滑动移除时「析构按钮预演删除动画致下方设备上移又复位」的抖动(改普通按钮 + 红色,真正删除在二次确认后);传输页 ScrollView→List 以获原生滑动删除,卡片观感经 .plain + 透明行背景 + 隐藏分隔线保留。 - i18n:3 locale 新增 ios.logs./ios.scan./ios.widget./ios.settings.viewLogs 等键并重生 iOS JSON。
93 lines
3.2 KiB
Swift
93 lines
3.2 KiB
Swift
import AppIntents
|
||
import SwiftUI
|
||
import WidgetKit
|
||
|
||
// 主屏 / 锁屏小组件「云剪贴板」(#6):在控制中心两控件之外,提供一个可放主屏的交互式小组件,含上传 /
|
||
// 拉取两个按钮(iOS 17+ 交互式小组件,按钮直接跑 AppIntent,无需打开 app)。触发结果经 WidgetFeedback
|
||
// 弹本地通知反馈。按钮复用与控制中心相同的 Upload/PullClipboardIntent。
|
||
struct ClipboardWidgetEntry: TimelineEntry
|
||
{
|
||
let date: Date
|
||
}
|
||
|
||
// 纯按钮小组件,无动态内容:单条永不刷新的时间线即可(交互由按钮的 AppIntent 驱动)。
|
||
struct ClipboardWidgetProvider: TimelineProvider
|
||
{
|
||
func placeholder(in context: Context) -> ClipboardWidgetEntry { ClipboardWidgetEntry(date: Date()) }
|
||
|
||
func getSnapshot(in context: Context, completion: @escaping (ClipboardWidgetEntry) -> Void)
|
||
{
|
||
completion(ClipboardWidgetEntry(date: Date()))
|
||
}
|
||
|
||
func getTimeline(in context: Context, completion: @escaping (Timeline<ClipboardWidgetEntry>) -> Void)
|
||
{
|
||
completion(Timeline(entries: [ ClipboardWidgetEntry(date: Date()) ], policy: .never))
|
||
}
|
||
}
|
||
|
||
struct ClipboardWidgetView: View
|
||
{
|
||
@Environment(\.widgetFamily) private var family
|
||
var entry: ClipboardWidgetEntry
|
||
|
||
var body: some View
|
||
{
|
||
VStack(alignment: .leading, spacing: 10)
|
||
{
|
||
HStack(spacing: 6)
|
||
{
|
||
Image(systemName: "doc.on.clipboard")
|
||
.foregroundStyle(.tint)
|
||
Text(t("ios.widget.clipboardName"))
|
||
.font(.caption).bold()
|
||
.lineLimit(1)
|
||
}
|
||
// 小尺寸纵向堆叠两按钮;中尺寸并排。
|
||
if family == .systemSmall
|
||
{
|
||
actionButton(t("ios.control.upload"), "square.and.arrow.up", UploadClipboardIntent())
|
||
actionButton(t("ios.control.pull"), "square.and.arrow.down", PullClipboardIntent())
|
||
}
|
||
else
|
||
{
|
||
HStack(spacing: 10)
|
||
{
|
||
actionButton(t("ios.control.upload"), "square.and.arrow.up", UploadClipboardIntent())
|
||
actionButton(t("ios.control.pull"), "square.and.arrow.down", PullClipboardIntent())
|
||
}
|
||
}
|
||
}
|
||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
|
||
.padding()
|
||
.containerBackground(.fill.tertiary, for: .widget)
|
||
}
|
||
|
||
private func actionButton(_ title: String, _ symbol: String, _ intent: some AppIntent) -> some View
|
||
{
|
||
Button(intent: intent)
|
||
{
|
||
Label(title, systemImage: symbol)
|
||
.font(.caption2)
|
||
.lineLimit(1)
|
||
.frame(maxWidth: .infinity)
|
||
}
|
||
.buttonStyle(.bordered)
|
||
.tint(.cdropAccent)
|
||
}
|
||
}
|
||
|
||
struct CloudClipboardWidget: Widget
|
||
{
|
||
var body: some WidgetConfiguration
|
||
{
|
||
StaticConfiguration(kind: "net.commilitia.cdrop.widget.clipboard", provider: ClipboardWidgetProvider())
|
||
{ entry in
|
||
ClipboardWidgetView(entry: entry)
|
||
}
|
||
.configurationDisplayName(t("ios.widget.clipboardName"))
|
||
.description(t("ios.widget.clipboardDesc"))
|
||
.supportedFamilies([ .systemSmall, .systemMedium ])
|
||
}
|
||
}
|