PasteFerry (隔空贴): clipboard and file sync across macOS, Windows and Linux. Direct-first, end-to-end encrypted. Optional official access: no server to host. Independent self-hosting remains available.
Dart airdrop-alternativeclipboardclipboard-sharingclipboard-synccopy-pastecross-platformend-to-end-encryptionfile-syncfile-transferfluttergolanglinuxmacosnat-traversalp2pself-hostedtailscaleuniversal-clipboardwebrtcwindows
复制记录:操作按钮位置不再随悬停变化;图片预览按窗口比例定大小,小图不放大
baiyuzef8642e0d4dfe
diff --git a/ui/lib/pages/history_page.dart b/ui/lib/pages/history_page.dartindex 2669ce5..eed6978 100644--- a/ui/lib/pages/history_page.dart+++ b/ui/lib/pages/history_page.dart@@ -272,25 +272,30 @@ class _RecordRowState extends State<_RecordRow> {case ClipStatus.CLIP_STATUS_EXPIRED:return Text('已过期', style: context.text.bodySmall?.copyWith(color: p.textFaint));default:- // 悬停时才显示操作,静态时列表保持干净- if (!_hovered && r.kind != ClipKind.CLIP_KIND_IMAGE) return const SizedBox(height: 28);+ // 悬停时才显示「放入剪贴板」与删除,静态时列表保持干净。+ // 不悬停时它们只是看不见,位置照样留着:鼠标移上来时「预览」不会被挤开,不容易点错+ Widget hoverOnly(Widget child) => Visibility(+ visible: _hovered,+ maintainSize: true,+ maintainAnimation: true,+ maintainState: true,+ child: child,+ );return Row(mainAxisSize: MainAxisSize.min,children: [if (r.kind == ClipKind.CLIP_KIND_IMAGE)TextButton(onPressed: () => _preview(r), child: const Text('预览')),- if (_hovered) ...[- TextButton(- onPressed: () =>- _run(() => AppScope.read(context).applyToClipboard(r.id), '已放入剪贴板'),- child: const Text('放入剪贴板'),- ),- IconAction(- icon: AppIcons.trash,- tooltip: '删除这条记录',- onTap: () => _run(() => AppScope.read(context).deleteRecords(ids: [r.id]), '已删除'),- ),- ],+ hoverOnly(TextButton(+ onPressed: () =>+ _run(() => AppScope.read(context).applyToClipboard(r.id), '已放入剪贴板'),+ child: const Text('放入剪贴板'),+ )),+ hoverOnly(IconAction(+ icon: AppIcons.trash,+ tooltip: '删除这条记录',+ onTap: () => _run(() => AppScope.read(context).deleteRecords(ids: [r.id]), '已删除'),+ )),],);}diff --git a/ui/lib/widgets/image_preview_dialog.dart b/ui/lib/widgets/image_preview_dialog.dartindex bb28fc4..cb008ea 100644--- a/ui/lib/widgets/image_preview_dialog.dart+++ b/ui/lib/widgets/image_preview_dialog.dart@@ -57,11 +57,13 @@ class _ImagePreviewDialogState extends State<ImagePreviewDialog> {final record = state.records.where((r) => r.id == widget.clipId).firstOrNull;+ // 预览框按应用窗口的比例定大小:窗口小,预览也小,不会一打开就把整个窗口盖满+ final window = MediaQuery.sizeOf(context);return Dialog(- insetPadding: const EdgeInsets.all(Insets.xl),+ insetPadding: EdgeInsets.zero,child: SizedBox(- width: 920,- height: 640,+ width: (window.width * 0.8).clamp(280.0, 1400.0),+ height: (window.height * 0.8).clamp(240.0, 1000.0),child: Column(children: [Padding(@@ -179,7 +181,8 @@ class _ImagePreviewDialogState extends State<ImagePreviewDialog> {height: 2048,policy: ResizeImagePolicy.fit,),- fit: BoxFit.contain,+ // 比预览框小的图片按原始大小显示,大的才缩小到放得下:小图标不会被放大成一整屏+ fit: BoxFit.scaleDown,semanticLabel: '复制记录中的图片',frameBuilder: (_, child, frame, synchronous) =>frame != null || synchronousdiff --git a/ui/test/image_preview_test.dart b/ui/test/image_preview_test.dartindex d551380..7ce826f 100644--- a/ui/test/image_preview_test.dart+++ b/ui/test/image_preview_test.dart@@ -4,6 +4,7 @@ import 'package:copysync_ui/app_state.dart';import 'package:copysync_ui/gen/copysync/v1/daemon.pb.dart';import 'package:copysync_ui/main.dart';import 'package:copysync_ui/widgets/image_preview_dialog.dart';+import 'package:flutter/gestures.dart';import 'package:flutter/material.dart';import 'package:flutter_test/flutter_test.dart';@@ -207,4 +208,45 @@ void main() {expect(tester.takeException(), isNull);});}++ testWidgets('预览框按窗口比例定大小,小图按原始大小显示、不放大', (tester) async {+ tester.view.physicalSize = const Size(1000, 700);+ tester.view.devicePixelRatio = 1;+ addTearDown(tester.view.reset);+ final state = PreviewState(+ File('test/fixtures/image-preview.png').absolute.path,+ );+ addTearDown(state.dispose);+ await openPreview(tester, state);+ final box = tester.getSize(+ find.descendant(of: find.byType(Dialog), matching: find.byType(SizedBox)).first,+ );+ expect(box.width, closeTo(800, 0.5));+ expect(box.height, closeTo(560, 0.5));+ final image = await decodedImage(tester);+ expect(image.fit, BoxFit.scaleDown);+ });++ testWidgets('鼠标移到记录上时,「预览」按钮不挪位置', (tester) async {+ tester.view.physicalSize = const Size(1000, 700);+ tester.view.devicePixelRatio = 1;+ addTearDown(tester.view.reset);+ final state = PreviewState(+ File('test/fixtures/image-preview.png').absolute.path,+ );+ addTearDown(state.dispose);+ await tester.pumpWidget(CopySyncApp(state: state));+ await tester.pump();+ final before = tester.getCenter(find.text('预览'));+ expect(find.text('放入剪贴板').hitTestable(), findsNothing);++ final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);+ addTearDown(mouse.removePointer);+ await mouse.addPointer(location: Offset.zero);+ await mouse.moveTo(tester.getCenter(find.text('测试图片')));+ await tester.pump();++ expect(find.text('放入剪贴板').hitTestable(), findsOneWidget);+ expect(tester.getCenter(find.text('预览')), before);+ });}