Skip to content

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.

1.3.1:点记录即可预览图片,去掉单独的「预览」按钮;复制的图片文件也能预览

baiyuze903fa4f70bd0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 660719a..b62dab7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,15 @@
# 更新记录 / Changelog
+## 1.3.1 — 2026-10-09
+
+- **点一下记录就能预览图片,去掉了单独的「预览」按钮**(它和悬停才出现的按钮挤在一起,位置看起来是错的)。
+ **Click a history item to preview it**; the separate Preview button is gone.
+- **复制的图片文件也能预览**:PNG、JPEG、GIF、WebP、BMP,Mac 上还有 iPhone 照片常见的 HEIC 和 TIFF
+ (由系统转换,按拍摄方向转正)。一次复制了几张图片的,可以用左右箭头或方向键翻看。
+ **Copied image files can be previewed too**: PNG, JPEG, GIF, WebP, BMP, plus HEIC and TIFF on Mac. Step through
+ several with the arrows or arrow keys.
+- 单张图片文件在列表里显示图片图标。 Single image files show an image icon in the list.
+
## 1.3.0 — 2026-10-09
- **界面支持简体中文、英文、日文**:默认跟随系统语言,也可以在「设置 → 这台 Mac / 这台电脑 → 语言」里切换。
diff --git a/client-core/cmd/copysyncd/main.go b/client-core/cmd/copysyncd/main.go
index 8bb6d4e..c1b8e33 100644
--- a/client-core/cmd/copysyncd/main.go
+++ b/client-core/cmd/copysyncd/main.go
@@ -324,7 +324,7 @@ func run(dataDir string) error {
Fetch: engine.Fetch,
FetchForPreview: engine.FetchForPreview,
ApplyToClipboard: engine.ApplyToClipboard,
- ImagePreviewPath: engine.ImagePreviewPath,
+ ImagePreview: engine.ImagePreview,
CacheBytesUsed: blobs.Size,
Permission: func() clipboard.Permission {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
diff --git a/client-core/internal/imagepreview/convert_darwin.go b/client-core/internal/imagepreview/convert_darwin.go
new file mode 100644
index 0000000..9ceffa1
--- /dev/null
+++ b/client-core/internal/imagepreview/convert_darwin.go
@@ -0,0 +1,64 @@
+//go:build darwin
+
+package imagepreview
+
+/*
+#cgo LDFLAGS: -framework ImageIO -framework CoreGraphics -framework CoreFoundation
+#include <ImageIO/ImageIO.h>
+#include <stdlib.h>
+#include <string.h>
+
+// 读入 ImageIO 认识的图片,按 EXIF 方向转正、长边缩到 maxPixels 以内(不放大),写成 PNG。
+static int cs_convert_png(const char *src, const char *dst, int maxPixels) {
+ int ok = 0;
+ CFURLRef inURL = CFURLCreateFromFileSystemRepresentation(NULL, (const UInt8 *)src, (CFIndex)strlen(src), false);
+ CFURLRef outURL = CFURLCreateFromFileSystemRepresentation(NULL, (const UInt8 *)dst, (CFIndex)strlen(dst), false);
+ CGImageSourceRef source = inURL ? CGImageSourceCreateWithURL(inURL, NULL) : NULL;
+ if (source != NULL && outURL != NULL) {
+ CFNumberRef size = CFNumberCreate(NULL, kCFNumberIntType, &maxPixels);
+ const void *keys[] = {
+ kCGImageSourceCreateThumbnailFromImageAlways,
+ kCGImageSourceCreateThumbnailWithTransform,
+ kCGImageSourceThumbnailMaxPixelSize,
+ };
+ const void *values[] = {kCFBooleanTrue, kCFBooleanTrue, size};
+ CFDictionaryRef options = CFDictionaryCreate(NULL, keys, values, 3,
+ &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CGImageRef image = CGImageSourceCreateThumbnailAtIndex(source, 0, options);
+ if (image != NULL) {
+ CGImageDestinationRef dest = CGImageDestinationCreateWithURL(outURL, CFSTR("public.png"), 1, NULL);
+ if (dest != NULL) {
+ CGImageDestinationAddImage(dest, image, NULL);
+ ok = CGImageDestinationFinalize(dest) ? 1 : 0;
+ CFRelease(dest);
+ }
+ CGImageRelease(image);
+ }
+ CFRelease(options);
+ CFRelease(size);
+ }
+ if (source != NULL) CFRelease(source);
+ if (inURL != NULL) CFRelease(inURL);
+ if (outURL != NULL) CFRelease(outURL);
+ return ok;
+}
+*/
+import "C"
+
+import (
+ "errors"
+ "unsafe"
+)
+
+// Mac 上由 ImageIO 转换的格式
+var converted = map[string]bool{".heic": true, ".heif": true, ".tif": true, ".tiff": true}
+
+func convert(src, dst string, maxPixels int) error {
+ cSrc, cDst := C.CString(src), C.CString(dst)
+ defer C.free(unsafe.Pointer(cSrc))
+ defer C.free(unsafe.Pointer(cDst))
+ if C.cs_convert_png(cSrc, cDst, C.int(maxPixels)) == 0 {
+ return errors.New("无法读取这张图片,文件可能已损坏")
+ }
+ return nil
+}
diff --git a/client-core/internal/imagepreview/convert_other.go b/client-core/internal/imagepreview/convert_other.go
new file mode 100644
index 0000000..d7addff
--- /dev/null
+++ b/client-core/internal/imagepreview/convert_other.go
@@ -0,0 +1,12 @@
+//go:build !darwin
+
+package imagepreview
+
+import "errors"
+
+// 只有 Mac 能转换 HEIC、TIFF;这里没有需要转换的格式,Previewable 也就不会认它们。
+var converted = map[string]bool{}
+
+func convert(string, string, int) error {
+ return errors.New("不支持预览这种图片格式")
+}
diff --git a/client-core/internal/imagepreview/imagepreview.go b/client-core/internal/imagepreview/imagepreview.go
new file mode 100644
index 0000000..fb48c75
--- /dev/null
+++ b/client-core/internal/imagepreview/imagepreview.go
@@ -0,0 +1,82 @@
+// Package imagepreview 决定复制记录里哪些图片能在界面上预览,并把图片准备成界面能直接解码的文件。
+//
+// 界面(Flutter)自己能解码 PNG、JPEG、GIF、WebP、BMP。iPhone 照片常见的 HEIC 和 TIFF 解不了:
+// Mac 上由系统的 ImageIO 转成 PNG(见 convert_darwin.go),其他平台不支持,也就不算可预览。
+package imagepreview
+
+import (
+ "crypto/sha256"
+ "encoding/hex"
+ "errors"
+ "fmt"
+ "os"
+ "path/filepath"
+ "strings"
+
+ "github.com/baiyuze/copysync/client-core/internal/store"
+)
+
+// MaxPixels 是转换出来的预览图长边的上限,与界面解码时的限制一致。
+const MaxPixels = 2048
+
+// 界面能直接解码的格式
+var native = map[string]bool{".png": true, ".jpg": true, ".jpeg": true, ".gif": true, ".webp": true, ".bmp": true}
+
+// Previewable 按文件名判断这是不是一张能预览的图片。
+func Previewable(name string) bool {
+ ext := strings.ToLower(filepath.Ext(name))
+ return native[ext] || converted[ext]
+}
+
+// ImageCount 返回一条记录里能预览的图片数:剪贴板图片算一张,文件记录数其中的图片文件(不进文件夹)。
+func ImageCount(c store.Clip) int32 {
+ switch c.Kind {
+ case store.KindImage:
+ return 1
+ case store.KindFile:
+ var n int32
+ for _, it := range c.Items {
+ if !it.IsDir && Previewable(it.Name) {
+ n++
+ }
+ }
+ return n
+ }
+ return 0
+}
+
+// Prepare 返回界面可以直接读取的图片路径。原生格式原样返回;其他格式转换成 PNG,
+// 放在系统临时目录里,按原文件的路径、大小、修改时间命名,同一张图第二次打开不再转换。
+func Prepare(path string) (string, error) {
+ ext := strings.ToLower(filepath.Ext(path))
+ if native[ext] {
+ return path, nil
+ }
+ if !converted[ext] {
+ return "", errors.New("不支持预览这种图片格式")
+ }
+ info, err := os.Stat(path)
+ if err != nil {
+ return "", err
+ }
+ sum := sha256.Sum256([]byte(fmt.Sprintf("%s|%d|%d", path, info.Size(), info.ModTime().UnixNano())))
+ dir := filepath.Join(os.TempDir(), "CopySync-preview")
+ if err := os.MkdirAll(dir, 0o700); err != nil {
+ return "", err
+ }
+ out := filepath.Join(dir, hex.EncodeToString(sum[:10])+".png")
+ if _, err := os.Stat(out); err == nil {
+ return out, nil
+ }
+ // 先写到临时名再改名:转换到一半时界面读到的不会是残缺的文件
+ tmp := out + ".partial"
+ if err := convert(path, tmp, MaxPixels); err != nil {
+ os.Remove(tmp)
+ return "", err
+ }
+ if err := os.Rename(tmp, out); err != nil {
+ os.Remove(tmp)
+ return "", err
+ }
+ return out, nil
+}
diff --git a/client-core/internal/imagepreview/imagepreview_test.go b/client-core/internal/imagepreview/imagepreview_test.go
new file mode 100644
index 0000000..a004193
--- /dev/null
+++ b/client-core/internal/imagepreview/imagepreview_test.go
@@ -0,0 +1,110 @@
+package imagepreview
+
+import (
+ "image"
+ "image/color"
+ "image/png"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
+ "testing"
+
+ "github.com/baiyuze/copysync/client-core/internal/store"
+)
+
+func TestPreviewableAndCount(t *testing.T) {
+ for name, want := range map[string]bool{
+ "a.png": true, "B.JPG": true, "c.jpeg": true, "d.gif": true, "e.webp": true, "f.bmp": true,
+ "notes.txt": false, "deck.key": false, "png": false, "": false,
+ "IMG_2041.HEIC": runtime.GOOS == "darwin", "scan.tiff": runtime.GOOS == "darwin",
+ } {
+ if got := Previewable(name); got != want {
+ t.Errorf("Previewable(%q) = %v,应为 %v", name, got, want)
+ }
+ }
+ clip := store.Clip{Kind: store.KindFile, Items: []store.Item{
+ {Name: "a.png"}, {Name: "b.jpg"}, {Name: "notes.txt"}, {Name: "photos.png", IsDir: true},
+ }}
+ if got := ImageCount(clip); got != 2 {
+ t.Errorf("文件记录的图片数 = %d,应为 2(文件夹不算)", got)
+ }
+ if got := ImageCount(store.Clip{Kind: store.KindImage}); got != 1 {
+ t.Errorf("剪贴板图片 = %d,应为 1", got)
+ }
+ if got := ImageCount(store.Clip{Kind: store.KindText}); got != 0 {
+ t.Errorf("文本 = %d,应为 0", got)
+ }
+}
+
+func writePNG(t *testing.T, path string, w, h int) {
+ t.Helper()
+ img := image.NewRGBA(image.Rect(0, 0, w, h))
+ for x := 0; x < w; x++ {
+ img.Set(x, 0, color.RGBA{R: 255, A: 255})
+ }
+ f, err := os.Create(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer f.Close()
+ if err := png.Encode(f, img); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestPrepareKeepsNativeFormats(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "原图.png")
+ writePNG(t, path, 4, 3)
+ got, err := Prepare(path)
+ if err != nil || got != path {
+ t.Fatalf("PNG 应原样返回:%q, %v", got, err)
+ }
+ if _, err := Prepare(filepath.Join(t.TempDir(), "a.txt")); err == nil {
+ t.Fatal("不是图片也返回了路径")
+ }
+}
+
+// HEIC 与 TIFF 在 Mac 上转成 PNG:大图缩到 MaxPixels,小图不放大。用系统自带的 sips 造测试图片。
+func TestPrepareConvertsOnMac(t *testing.T) {
+ if runtime.GOOS != "darwin" {
+ t.Skip("只有 Mac 转换 HEIC、TIFF")
+ }
+ dir := t.TempDir()
+ for _, tc := range []struct {
+ format, ext string
+ w, h int
+ wantW int
+ }{
+ {"heic", ".heic", 3000, 2000, MaxPixels},
+ {"tiff", ".tiff", 40, 30, 40},
+ } {
+ src := filepath.Join(dir, "src-"+tc.format+".png")
+ writePNG(t, src, tc.w, tc.h)
+ in := filepath.Join(dir, "照片"+tc.ext)
+ if out, err := exec.Command("sips", "-s", "format", tc.format, src, "--out", in).CombinedOutput(); err != nil {
+ t.Skipf("sips 无法生成 %s:%v %s", tc.format, err, out)
+ }
+ got, err := Prepare(in)
+ if err != nil {
+ t.Fatalf("%s 转换失败:%v", tc.format, err)
+ }
+ f, err := os.Open(got)
+ if err != nil {
+ t.Fatal(err)
+ }
+ cfg, err := png.DecodeConfig(f)
+ f.Close()
+ if err != nil {
+ t.Fatalf("%s 转出来的不是 PNG:%v", tc.format, err)
+ }
+ if cfg.Width != tc.wantW {
+ t.Errorf("%s 转换后宽 %d,应为 %d", tc.format, cfg.Width, tc.wantW)
+ }
+ // 第二次直接用上次转好的文件
+ again, err := Prepare(in)
+ if err != nil || again != got {
+ t.Errorf("第二次应复用 %q,得到 %q, %v", got, again, err)
+ }
+ }
+}
diff --git a/client-core/internal/rpc/convert.go b/client-core/internal/rpc/convert.go
index 8ed2b63..9a32724 100644
--- a/client-core/internal/rpc/convert.go
+++ b/client-core/internal/rpc/convert.go
@@ -5,6 +5,7 @@ import (
"github.com/baiyuze/copysync/client-core/internal/clipboard"
"github.com/baiyuze/copysync/client-core/internal/config"
+ "github.com/baiyuze/copysync/client-core/internal/imagepreview"
"github.com/baiyuze/copysync/client-core/internal/store"
pb "github.com/baiyuze/copysync/proto/gen/copysync/v1"
)
@@ -35,6 +36,7 @@ func clipToProto(c store.Clip) *pb.ClipRecord {
CreatedAtUnix: c.CreatedAt.Unix(),
ExpiresAtUnix: c.ExpiresAt.Unix(),
Error: c.Error,
+ ImageCount: imagepreview.ImageCount(c),
}
}
diff --git a/client-core/internal/rpc/image_preview_test.go b/client-core/internal/rpc/image_preview_test.go
index 87acc29..49489e8 100644
--- a/client-core/internal/rpc/image_preview_test.go
+++ b/client-core/internal/rpc/image_preview_test.go
@@ -19,12 +19,12 @@ func TestImagePreviewRPC(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
called := 0
- s := NewServer(Deps{ImagePreviewPath: func(_ context.Context, id string) (string, error) {
+ s := NewServer(Deps{ImagePreview: func(_ context.Context, id string, index int) (string, string, int, error) {
called++
if id == "missing" {
- return "", errors.New("图片已被清理")
+ return "", "", 0, errors.New("图片已被清理")
}
- return "/test/中文 图片.png", nil
+ return "/test/中文 图片.png", "中文 图片.png", 3 + index, nil
}}, NewHub(), "test-token")
port, server, err := s.Serve(ctx)
if err != nil {
@@ -52,8 +52,8 @@ func TestImagePreviewRPC(t *testing.T) {
if _, err := client.GetImagePreview(auth, &pb.GetImagePreviewRequest{ClipId: "missing"}); status.Code(err) != codes.FailedPrecondition {
t.Fatalf("missing image: %v", err)
}
- got, err := client.GetImagePreview(auth, &pb.GetImagePreviewRequest{ClipId: "image"})
- if err != nil || got.GetPath() != "/test/中文 图片.png" {
+ got, err := client.GetImagePreview(auth, &pb.GetImagePreviewRequest{ClipId: "image", Index: 1})
+ if err != nil || got.GetPath() != "/test/中文 图片.png" || got.GetName() != "中文 图片.png" || got.GetCount() != 4 {
t.Fatalf("preview response: %v, %v", got, err)
}
}
diff --git a/client-core/internal/rpc/server.go b/client-core/internal/rpc/server.go
index d28bf27..33e14e7 100644
--- a/client-core/internal/rpc/server.go
+++ b/client-core/internal/rpc/server.go
@@ -37,7 +37,7 @@ type Deps struct {
Fetch func(ctx context.Context, clipID string) error
FetchForPreview func(ctx context.Context, clipID string) error
ApplyToClipboard func(ctx context.Context, clipID string) error
- ImagePreviewPath func(ctx context.Context, clipID string) (string, error)
+ ImagePreview func(ctx context.Context, clipID string, index int) (path, name string, count int, err error)
Permission func() clipboard.Permission
OpenPermissionSettings func() error
// Network 返回最近一轮网络出口探测的结果
@@ -236,14 +236,14 @@ func (s *Server) GetImagePreview(ctx context.Context,
if req.GetClipId() == "" {
return nil, status.Error(codes.InvalidArgument, "缺少图片记录 ID")
}
- if s.deps.ImagePreviewPath == nil {
+ if s.deps.ImagePreview == nil {
return nil, status.Error(codes.Unimplemented, "请更新后台服务后再预览图片")
}
- path, err := s.deps.ImagePreviewPath(ctx, req.GetClipId())
+ path, name, count, err := s.deps.ImagePreview(ctx, req.GetClipId(), int(req.GetIndex()))
if err != nil {
return nil, status.Error(codes.FailedPrecondition, err.Error())
}
- return &pb.GetImagePreviewResponse{Path: path}, nil
+ return &pb.GetImagePreviewResponse{Path: path, Name: name, Count: int32(count)}, nil
}
// ─────────────────────────── 配置与状态 ───────────────────────────
diff --git a/client-core/internal/sync/engine.go b/client-core/internal/sync/engine.go
index dd1009f..bc6a2bd 100644
--- a/client-core/internal/sync/engine.go
+++ b/client-core/internal/sync/engine.go
@@ -20,6 +20,7 @@ import (
"log/slog"
"os"
"path/filepath"
+ "sort"
"strings"
"sync"
"time"
@@ -29,6 +30,7 @@ import (
"github.com/baiyuze/copysync/client-core/internal/cache"
"github.com/baiyuze/copysync/client-core/internal/clipboard"
"github.com/baiyuze/copysync/client-core/internal/config"
+ "github.com/baiyuze/copysync/client-core/internal/imagepreview"
"github.com/baiyuze/copysync/client-core/internal/pack"
"github.com/baiyuze/copysync/client-core/internal/store"
"github.com/baiyuze/copysync/client-core/internal/transport/p2p"
@@ -740,27 +742,51 @@ func (e *Engine) applyToClipboard(ctx context.Context, clip store.Clip) error {
return e.watcher.Write(ctx, content)
}
-// ImagePreviewPath 只解析本地图片位置,不拉取文件、不写剪贴板。
-func (e *Engine) ImagePreviewPath(_ context.Context, clipID string) (string, error) {
+// ImagePreview 解析一条记录里第 index 张图片在本机的位置,不拉取文件、不写剪贴板。
+// 剪贴板图片只有一张;文件记录按文件名排序,只看其中的图片文件,不进文件夹。
+// 返回界面可以直接解码的路径(HEIC 等格式是转换出来的 PNG)、文件名(剪贴板图片为空)
+// 与这条记录在本机能预览的图片数。
+func (e *Engine) ImagePreview(_ context.Context, clipID string, index int) (path, name string, count int, err error) {
clip, err := e.store.GetClip(clipID)
if err != nil {
- return "", errors.New("找不到这条图片记录")
+ return "", "", 0, errors.New("找不到这条记录")
}
- if clip.Kind != store.KindImage {
- return "", errors.New("这条记录不是图片")
+ if imagepreview.ImageCount(clip) == 0 {
+ return "", "", 0, errors.New("这条记录里没有能预览的图片")
}
if clip.Status != store.StatusReady {
- return "", errors.New("图片尚未下载或已经过期")
+ return "", "", 0, errors.New("图片尚未下载或已经过期")
}
paths, err := e.localPaths(clip)
- if err != nil || len(paths) != 1 {
- return "", errors.New("图片已不在本机,可能已被清理")
+ if err != nil {
+ return "", "", 0, errors.New("图片已不在本机,可能已被清理")
+ }
+ var images []string
+ for _, p := range paths {
+ info, err := os.Stat(p)
+ if err != nil || !info.Mode().IsRegular() {
+ continue
+ }
+ if clip.Kind == store.KindImage || imagepreview.Previewable(p) {
+ images = append(images, p)
+ }
}
- info, err := os.Stat(paths[0])
- if err != nil || !info.Mode().IsRegular() {
- return "", errors.New("图片文件不可用")
+ if len(images) == 0 || clip.Kind == store.KindImage && len(images) != 1 {
+ return "", "", 0, errors.New("图片已不在本机,可能已被清理")
+ }
+ if clip.Kind == store.KindImage {
+ // 剪贴板图片收发时统一存成 PNG,界面能直接解码
+ return images[0], "", 1, nil
+ }
+ sort.Slice(images, func(i, j int) bool { return filepath.Base(images[i]) < filepath.Base(images[j]) })
+ if index < 0 || index >= len(images) {
+ index = 0
+ }
+ path, err = imagepreview.Prepare(images[index])
+ if err != nil {
+ return "", "", 0, err
}
- return paths[0], nil
+ return path, filepath.Base(images[index]), len(images), nil
}
// localPaths 返回这条记录在本机可用的实际路径。
@@ -807,6 +833,7 @@ func (e *Engine) emitRecord(clip store.Clip) {
CreatedAtUnix: clip.CreatedAt.Unix(),
ExpiresAtUnix: clip.ExpiresAt.Unix(),
Error: clip.Error,
+ ImageCount: imagepreview.ImageCount(clip),
})
}
diff --git a/client-core/internal/sync/image_preview_test.go b/client-core/internal/sync/image_preview_test.go
index 65ab42e..03b4d31 100644
--- a/client-core/internal/sync/image_preview_test.go
+++ b/client-core/internal/sync/image_preview_test.go
@@ -13,7 +13,7 @@ import (
pb "github.com/baiyuze/copysync/proto/gen/copysync/v1"
)
-func TestImagePreviewPath(t *testing.T) {
+func TestImagePreview(t *testing.T) {
root := t.TempDir()
db, err := store.Open(filepath.Join(root, "test.db"))
if err != nil {
@@ -53,7 +53,7 @@ func TestImagePreviewPath(t *testing.T) {
if err := db.PutClip(tc.clip); err != nil {
t.Fatal(err)
}
- got, err := e.ImagePreviewPath(context.Background(), tc.name)
+ got, _, _, err := e.ImagePreview(context.Background(), tc.name, 0)
if tc.want == "" {
if err == nil {
t.Fatalf("unexpected path: %s", got)
@@ -63,7 +63,7 @@ func TestImagePreviewPath(t *testing.T) {
}
})
}
- if _, err := e.ImagePreviewPath(context.Background(), "missing-record"); err == nil {
+ if _, _, _, err := e.ImagePreview(context.Background(), "missing-record", 0); err == nil {
t.Fatal("missing record accepted")
}
if data, err := os.ReadFile(path); err != nil || string(data) != "unchanged image bytes" {
@@ -71,6 +71,52 @@ func TestImagePreviewPath(t *testing.T) {
}
}
+// 文件记录里的图片也能预览:只算图片文件,按文件名排序,越界时回到第一张。
+func TestImagePreviewOfFiles(t *testing.T) {
+ root := t.TempDir()
+ db, err := store.Open(filepath.Join(root, "test.db"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() { db.Close() })
+ blobs, err := cache.New(filepath.Join(root, "cache"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ e := &Engine{store: db, cache: blobs}
+ var paths []string
+ for _, name := range []string{"b.png", "a.jpg", "notes.txt"} {
+ p := filepath.Join(root, name)
+ if err := os.WriteFile(p, []byte(name), 0o600); err != nil {
+ t.Fatal(err)
+ }
+ paths = append(paths, p)
+ }
+ clip := store.Clip{ID: "files", Kind: store.KindFile, Status: store.StatusReady, SourcePaths: paths,
+ Items: []store.Item{{Name: "b.png"}, {Name: "a.jpg"}, {Name: "notes.txt"}}}
+ if err := db.PutClip(clip); err != nil {
+ t.Fatal(err)
+ }
+ for _, tc := range []struct {
+ index int
+ want string
+ }{{0, "a.jpg"}, {1, "b.png"}, {5, "a.jpg"}} {
+ path, name, count, err := e.ImagePreview(context.Background(), clip.ID, tc.index)
+ if err != nil || name != tc.want || path != filepath.Join(root, tc.want) || count != 2 {
+ t.Fatalf("第 %d 张:%q %q %d %v,应为 %s,共 2 张", tc.index, path, name, count, err, tc.want)
+ }
+ }
+
+ text := store.Clip{ID: "text-file", Kind: store.KindFile, Status: store.StatusReady,
+ SourcePaths: paths[2:], Items: []store.Item{{Name: "notes.txt"}}}
+ if err := db.PutClip(text); err != nil {
+ t.Fatal(err)
+ }
+ if _, _, _, err := e.ImagePreview(context.Background(), text.ID, 0); err == nil {
+ t.Fatal("没有图片的文件记录也返回了预览")
+ }
+}
+
func TestPreviewDownloadDoesNotApplyClipboard(t *testing.T) {
root := t.TempDir()
db, err := store.Open(filepath.Join(root, "test.db"))
@@ -110,7 +156,7 @@ func TestPreviewDownloadDoesNotApplyClipboard(t *testing.T) {
}
// 默认 AutoApplyToClipboard=true 且 watcher=nil:误写剪贴板会直接导致测试失败。
e.finishReceive(&receiver{clipID: clip.ID, streamID: "test-stream", from: "peer", start: time.Now()}, rel, []string{path})
- got, err := e.ImagePreviewPath(context.Background(), clip.ID)
+ got, _, _, err := e.ImagePreview(context.Background(), clip.ID, 0)
if err != nil || got != path {
t.Fatalf("downloaded preview: %q, %v", got, err)
}
diff --git a/docs/assets/screenshots/en/history-dark.png b/docs/assets/screenshots/en/history-dark.png
index df7da39..a4c1921 100644
Binary files a/docs/assets/screenshots/en/history-dark.png and b/docs/assets/screenshots/en/history-dark.png differ
diff --git a/docs/assets/screenshots/en/history.png b/docs/assets/screenshots/en/history.png
index ab6fd13..3f953e7 100644
Binary files a/docs/assets/screenshots/en/history.png and b/docs/assets/screenshots/en/history.png differ
diff --git a/docs/assets/screenshots/history-dark.png b/docs/assets/screenshots/history-dark.png
index 364f652..08759db 100644
Binary files a/docs/assets/screenshots/history-dark.png and b/docs/assets/screenshots/history-dark.png differ
diff --git a/docs/assets/screenshots/history.png b/docs/assets/screenshots/history.png
index 8264af8..5470e02 100644
Binary files a/docs/assets/screenshots/history.png and b/docs/assets/screenshots/history.png differ
diff --git a/docs/assets/screenshots/ja/history-dark.png b/docs/assets/screenshots/ja/history-dark.png
index 5583769..696b0ce 100644
Binary files a/docs/assets/screenshots/ja/history-dark.png and b/docs/assets/screenshots/ja/history-dark.png differ
diff --git a/docs/assets/screenshots/ja/history.png b/docs/assets/screenshots/ja/history.png
index 76cc8d0..9c04278 100644
Binary files a/docs/assets/screenshots/ja/history.png and b/docs/assets/screenshots/ja/history.png differ
diff --git a/docs/en/index.html b/docs/en/index.html
index b82afdd..9a6d0d4 100644
--- a/docs/en/index.html
+++ b/docs/en/index.html
@@ -38,7 +38,7 @@
"description": "Open-source app that syncs the clipboard and files between Mac and Windows computers. Copy text, images, files or folders on one computer and paste on the other. Devices connect directly over WebRTC with end-to-end DTLS encryption, falling back to a TURN relay on a server the user hosts.",
"applicationCategory": "UtilitiesApplication",
"operatingSystem": "macOS 13 or later (Intel and Apple silicon); Windows 10, Windows 11 (x64)",
- "softwareVersion": "1.3.0",
+ "softwareVersion": "1.3.1",
"datePublished": "2026-10-09",
"inLanguage": "en",
"license": "https://www.gnu.org/licenses/agpl-3.0.html",
@@ -166,7 +166,7 @@
<a class="button" href="https://github.com/baiyuze/copysync/releases/latest/download/CopySync.dmg"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 3v10m0 0-4-4m4 4 4-4M4 16h12"/></svg>Download for Mac</a>
<a class="button quiet" href="https://github.com/baiyuze/copysync/releases/latest/download/CopySync-Setup.exe"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 3v10m0 0-4-4m4 4 4-4M4 16h12"/></svg>Download for Windows</a>
</div>
- <p class="note">Version 1.3.0, free and open source. macOS 13 or later, Intel and Apple silicon; Windows 10 and 11.</p>
+ <p class="note">Version 1.3.1, free and open source. macOS 13 or later, Intel and Apple silicon; Windows 10 and 11.</p>
<div class="stage" data-play role="img" aria-label="Demo: Command C on a MacBook turns a file into a sheet that flies over a direct connection to a Windows laptop, where Ctrl V pastes it">
<figure class="device mac">
<div class="screen"><div class="desk">
@@ -417,7 +417,7 @@ sudo ./install.sh YOUR_PUBLIC_IP</code></pre>
<div class="table-scroll">
<table class="specs">
<tbody>
- <tr><th scope="row">Version</th><td>1.3.0, released <time datetime="2026-10-09">October 9, 2026</time></td></tr>
+ <tr><th scope="row">Version</th><td>1.3.1, released <time datetime="2026-10-09">October 9, 2026</time></td></tr>
<tr><th scope="row">Mac app</th><td>macOS 13 Ventura or later; universal binary for Intel and Apple silicon, no Rosetta; about 47 MB download</td></tr>
<tr><th scope="row">Windows app</th><td>Windows 10 (21H2 or later) and Windows 11, x64; installs per user, no administrator rights; about 23 MB download</td></tr>
<tr><th scope="row">Server</th><td>Linux on x86_64 or ARM64 (systemd or Docker), or macOS; about 15 MB of RAM</td></tr>
@@ -484,7 +484,7 @@ sudo ./install.sh YOUR_PUBLIC_IP</code></pre>
<a class="button" href="https://github.com/baiyuze/copysync/releases/latest/download/CopySync.dmg"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 3v10m0 0-4-4m4 4 4-4M4 16h12"/></svg>Download for Mac</a>
<a class="button quiet" href="https://github.com/baiyuze/copysync/releases/latest/download/CopySync-Setup.exe"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 3v10m0 0-4-4m4 4 4-4M4 16h12"/></svg>Download for Windows</a>
</div>
- <p class="note">Version 1.3.0, free and open source. macOS 13 or later, Intel and Apple silicon; Windows 10 and 11.</p>
+ <p class="note">Version 1.3.1, free and open source. macOS 13 or later, Intel and Apple silicon; Windows 10 and 11.</p>
<a class="source" href="https://github.com/baiyuze/copysync">View the source on GitHub</a>
</div>
</section>
diff --git a/docs/index.html b/docs/index.html
index 4d9315f..256721b 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -58,7 +58,7 @@
"description": "在 Mac 与 Windows 电脑之间同步剪贴板与文件的开源工具。复制文本、图片、文件或文件夹后,另一台电脑可直接粘贴。设备间 WebRTC 直连、DTLS 端到端加密,打不通时经用户自建服务器的 TURN 中转。",
"applicationCategory": "UtilitiesApplication",
"operatingSystem": "macOS 13 及以上(Intel 与 Apple 芯片);Windows 10、Windows 11(x64)",
- "softwareVersion": "1.3.0",
+ "softwareVersion": "1.3.1",
"datePublished": "2026-10-09",
"inLanguage": "zh-CN",
"license": "https://www.gnu.org/licenses/agpl-3.0.html",
@@ -186,7 +186,7 @@
<a class="button" href="https://github.com/baiyuze/copysync/releases/latest/download/CopySync.dmg"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 3v10m0 0-4-4m4 4 4-4M4 16h12"/></svg>下载 Mac 版</a>
<a class="button quiet" href="https://github.com/baiyuze/copysync/releases/latest/download/CopySync-Setup.exe"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 3v10m0 0-4-4m4 4 4-4M4 16h12"/></svg>下载 Windows 版</a>
</div>
- <p class="note">版本 1.3.0,免费开源。macOS 13 及以上,Intel 与 Apple 芯片通用;Windows 10、11。</p>
+ <p class="note">版本 1.3.1,免费开源。macOS 13 及以上,Intel 与 Apple 芯片通用;Windows 10、11。</p>
<div class="stage" data-play role="img" aria-label="演示:在 MacBook 上按下 Command C,文件化作一张纸,经直连飞到 Windows 笔记本,在那里按下 Ctrl V 粘贴出来">
<figure class="device mac">
<div class="screen"><div class="desk">
@@ -437,7 +437,7 @@ sudo ./install.sh 你的公网IP</code></pre>
<div class="table-scroll">
<table class="specs">
<tbody>
- <tr><th scope="row">版本</th><td>1.3.0,<time datetime="2026-10-09">2026 年 10 月 9 日</time>发布</td></tr>
+ <tr><th scope="row">版本</th><td>1.3.1,<time datetime="2026-10-09">2026 年 10 月 9 日</time>发布</td></tr>
<tr><th scope="row">Mac 客户端</th><td>macOS 13 Ventura 及以上;Intel 与 Apple 芯片通用,不需要 Rosetta;安装包约 47 MB</td></tr>
<tr><th scope="row">Windows 客户端</th><td>Windows 10(21H2 及以上)与 Windows 11,x64;按用户安装,不需要管理员权限;安装包约 23 MB</td></tr>
<tr><th scope="row">服务器</th><td>Linux x86_64 或 ARM64(systemd 或 Docker),也可以运行在 macOS 上;约 15 MB 内存</td></tr>
@@ -504,7 +504,7 @@ sudo ./install.sh 你的公网IP</code></pre>
<a class="button" href="https://github.com/baiyuze/copysync/releases/latest/download/CopySync.dmg"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 3v10m0 0-4-4m4 4 4-4M4 16h12"/></svg>下载 Mac 版</a>
<a class="button quiet" href="https://github.com/baiyuze/copysync/releases/latest/download/CopySync-Setup.exe"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 3v10m0 0-4-4m4 4 4-4M4 16h12"/></svg>下载 Windows 版</a>
</div>
- <p class="note">版本 1.3.0,免费开源。macOS 13 及以上,Intel 与 Apple 芯片通用;Windows 10、11。</p>
+ <p class="note">版本 1.3.1,免费开源。macOS 13 及以上,Intel 与 Apple 芯片通用;Windows 10、11。</p>
<a class="source" href="https://github.com/baiyuze/copysync">在 GitHub 上查看源码</a>
</div>
</section>
diff --git a/docs/ja/index.html b/docs/ja/index.html
index c7c77fc..f2317bc 100644
--- a/docs/ja/index.html
+++ b/docs/ja/index.html
@@ -38,7 +38,7 @@
"description": "Mac と Windows のコンピューター間でクリップボードとファイルを同期するオープンソースのアプリ。テキスト、画像、ファイル、フォルダを一台でコピーし、もう一台で貼り付けられる。デバイス間は WebRTC で直接つながり DTLS でエンドツーエンド暗号化、つながらないときはユーザーが用意したサーバーの TURN で中継する。",
"applicationCategory": "UtilitiesApplication",
"operatingSystem": "macOS 13 以降(Intel と Apple シリコン)、Windows 10、Windows 11(x64)",
- "softwareVersion": "1.3.0",
+ "softwareVersion": "1.3.1",
"datePublished": "2026-10-09",
"inLanguage": "ja",
"license": "https://www.gnu.org/licenses/agpl-3.0.html",
@@ -166,7 +166,7 @@
<a class="button" href="https://github.com/baiyuze/copysync/releases/latest/download/CopySync.dmg"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 3v10m0 0-4-4m4 4 4-4M4 16h12"/></svg>Mac 版をダウンロード</a>
<a class="button quiet" href="https://github.com/baiyuze/copysync/releases/latest/download/CopySync-Setup.exe"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 3v10m0 0-4-4m4 4 4-4M4 16h12"/></svg>Windows 版をダウンロード</a>
</div>
- <p class="note">バージョン 1.3.0、無料・オープンソース。macOS 13 以降(Intel と Apple シリコン)、Windows 10・11。</p>
+ <p class="note">バージョン 1.3.1、無料・オープンソース。macOS 13 以降(Intel と Apple シリコン)、Windows 10・11。</p>
<div class="stage" data-play role="img" aria-label="デモ:MacBook で Command C を押すと、ファイルが一枚の紙になって直接接続で Windows ノートへ飛び、そこで Ctrl V を押して貼り付けます">
<figure class="device mac">
<div class="screen"><div class="desk">
@@ -417,7 +417,7 @@ sudo ./install.sh グローバルIP</code></pre>
<div class="table-scroll">
<table class="specs">
<tbody>
- <tr><th scope="row">バージョン</th><td>1.3.0(<time datetime="2026-10-09">2026 年 10 月 9 日</time>公開)</td></tr>
+ <tr><th scope="row">バージョン</th><td>1.3.1(<time datetime="2026-10-09">2026 年 10 月 9 日</time>公開)</td></tr>
<tr><th scope="row">Mac アプリ</th><td>macOS 13 Ventura 以降。Intel と Apple シリコンのユニバーサルバイナリで Rosetta 不要。ダウンロードは約 47 MB</td></tr>
<tr><th scope="row">Windows アプリ</th><td>Windows 10(21H2 以降)と Windows 11、x64。ユーザーごとのインストールで管理者権限不要。ダウンロードは約 23 MB</td></tr>
<tr><th scope="row">サーバー</th><td>Linux(x86_64 または ARM64、systemd または Docker)、macOS でも動作。メモリは約 15 MB</td></tr>
@@ -484,7 +484,7 @@ sudo ./install.sh グローバルIP</code></pre>
<a class="button" href="https://github.com/baiyuze/copysync/releases/latest/download/CopySync.dmg"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 3v10m0 0-4-4m4 4 4-4M4 16h12"/></svg>Mac 版をダウンロード</a>
<a class="button quiet" href="https://github.com/baiyuze/copysync/releases/latest/download/CopySync-Setup.exe"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 3v10m0 0-4-4m4 4 4-4M4 16h12"/></svg>Windows 版をダウンロード</a>
</div>
- <p class="note">バージョン 1.3.0、無料・オープンソース。macOS 13 以降(Intel と Apple シリコン)、Windows 10・11。</p>
+ <p class="note">バージョン 1.3.1、無料・オープンソース。macOS 13 以降(Intel と Apple シリコン)、Windows 10・11。</p>
<a class="source" href="https://github.com/baiyuze/copysync">GitHub でソースコードを見る</a>
</div>
</section>
diff --git a/docs/llms.txt b/docs/llms.txt
index 168f388..9b9a682 100644
--- a/docs/llms.txt
+++ b/docs/llms.txt
@@ -6,7 +6,7 @@
Key facts:
-- Current version: 1.3.0, released 2026-10-09. Adds an English and Japanese interface (follows the system language, switchable in Settings) and moves to the GNU AGPL-3.0 with an optional commercial license. 1.2.0 added the Windows client.
+- Current version: 1.3.1, released 2026-10-09. Click a history item to preview images, including copied image files (PNG, JPEG, GIF, WebP, BMP; HEIC and TIFF on Mac), with arrows to step through several. 1.3.0 added an English and Japanese interface (follows the system language, switchable in Settings) and moves to the GNU AGPL-3.0 with an optional commercial license. 1.2.0 added the Windows client.
- Mac client: macOS 13 Ventura or later, universal binary for Intel and Apple silicon. Distributed as a DMG; not notarized by Apple, so the first launch needs "Open Anyway" in System Settings → Privacy & Security.
- Windows client: Windows 10 (21H2+) and Windows 11, x64. Per-user installer (CopySync-Setup.exe, no admin rights) or portable zip; not code-signed, so SmartScreen needs "More info → Run anyway" once. Runs in the notification area; pasted files are real files usable in Explorer, WeChat and Office. Skips content that password managers mark as sensitive.
- Server: a single static Go binary for Linux (x86_64, ARM64) or macOS, installed via systemd script or Docker Compose. Ports: 8787/tcp (signaling), 3478/udp (STUN/TURN), 32768–60999/udp (relay).
diff --git a/proto/copysync/v1/daemon.proto b/proto/copysync/v1/daemon.proto
index fb7a7ca..a502155 100644
--- a/proto/copysync/v1/daemon.proto
+++ b/proto/copysync/v1/daemon.proto
@@ -20,7 +20,7 @@ service DaemonService {
rpc Fetch(FetchRequest) returns (Empty);
// 把某条已就绪的记录重新放进本机剪贴板
rpc ApplyToClipboard(ApplyToClipboardRequest) returns (Empty);
- // 只返回已就绪图片在本机的路径,不改动剪贴板,也不把路径发给对端。
+ // 只返回已就绪图片(或图片文件)在本机的路径,不改动剪贴板,也不把路径发给对端。
rpc GetImagePreview(GetImagePreviewRequest) returns (GetImagePreviewResponse);
rpc ListDevices(Empty) returns (ListDevicesResponse);
@@ -85,6 +85,10 @@ message ClipRecord {
int64 created_at_unix = 10;
int64 expires_at_unix = 11;
string error = 12; // status=FAILED 时的具体原因
+
+ // 能在界面里预览的图片数:剪贴板图片为 1,文件记录是其中图片文件的个数。
+ // 由本机后台服务按文件名判断,HEIC、TIFF 这类格式只有能转换它的平台才算。
+ int32 image_count = 13;
}
// ─────────────────────────── 事件流 ───────────────────────────
@@ -260,8 +264,11 @@ message Status {
message GetImagePreviewRequest {
string clip_id = 1;
+ int32 index = 2; // 一条记录里有多张图片时看第几张,从 0 开始
}
message GetImagePreviewResponse {
- string path = 1;
+ string path = 1; // 界面可以直接解码的图片文件;HEIC 等格式是转换出来的 PNG
+ int32 count = 2; // 这条记录在本机实际能预览的图片数
+ string name = 3; // 文件名;剪贴板里的图片没有文件名,为空
}
diff --git a/proto/gen/copysync/v1/daemon.pb.go b/proto/gen/copysync/v1/daemon.pb.go
index 2e5a908..f8491b1 100644
--- a/proto/gen/copysync/v1/daemon.pb.go
+++ b/proto/gen/copysync/v1/daemon.pb.go
@@ -369,8 +369,11 @@ type ClipRecord struct {
CreatedAtUnix int64 `protobuf:"varint,10,opt,name=created_at_unix,json=createdAtUnix,proto3" json:"created_at_unix,omitempty"`
ExpiresAtUnix int64 `protobuf:"varint,11,opt,name=expires_at_unix,json=expiresAtUnix,proto3" json:"expires_at_unix,omitempty"`
Error string `protobuf:"bytes,12,opt,name=error,proto3" json:"error,omitempty"` // status=FAILED 时的具体原因
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
+ // 能在界面里预览的图片数:剪贴板图片为 1,文件记录是其中图片文件的个数。
+ // 由本机后台服务按文件名判断,HEIC、TIFF 这类格式只有能转换它的平台才算。
+ ImageCount int32 `protobuf:"varint,13,opt,name=image_count,json=imageCount,proto3" json:"image_count,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
}
func (x *ClipRecord) Reset() {
@@ -487,6 +490,13 @@ func (x *ClipRecord) GetError() string {
return ""
}
+func (x *ClipRecord) GetImageCount() int32 {
+ if x != nil {
+ return x.ImageCount
+ }
+ return 0
+}
+
type SubscribeRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
// 断线重连时带上最后收到的记录时间,daemon 补发这之后的记录
@@ -1800,6 +1810,7 @@ func (x *Status) GetVersion() string {
type GetImagePreviewRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
ClipId string `protobuf:"bytes,1,opt,name=clip_id,json=clipId,proto3" json:"clip_id,omitempty"`
+ Index int32 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"` // 一条记录里有多张图片时看第几张,从 0 开始
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -1841,9 +1852,18 @@ func (x *GetImagePreviewRequest) GetClipId() string {
return ""
}
+func (x *GetImagePreviewRequest) GetIndex() int32 {
+ if x != nil {
+ return x.Index
+ }
+ return 0
+}
+
type GetImagePreviewResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
- Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
+ Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` // 界面可以直接解码的图片文件;HEIC 等格式是转换出来的 PNG
+ Count int32 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"` // 这条记录在本机实际能预览的图片数
+ Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` // 文件名;剪贴板里的图片没有文件名,为空
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -1885,6 +1905,20 @@ func (x *GetImagePreviewResponse) GetPath() string {
return ""
}
+func (x *GetImagePreviewResponse) GetCount() int32 {
+ if x != nil {
+ return x.Count
+ }
+ return 0
+}
+
+func (x *GetImagePreviewResponse) GetName() string {
+ if x != nil {
+ return x.Name
+ }
+ return ""
+}
+
var File_copysync_v1_daemon_proto protoreflect.FileDescriptor
const file_copysync_v1_daemon_proto_rawDesc = "" +
@@ -1895,7 +1929,7 @@ const file_copysync_v1_daemon_proto_rawDesc = "" +
"\x04name\x18\x01 \x01(\tR\x04name\x12\x12\n" +
"\x04size\x18\x02 \x01(\x03R\x04size\x12\x15\n" +
"\x06is_dir\x18\x03 \x01(\bR\x05isDir\x12!\n" +
- "\fcontent_type\x18\x04 \x01(\tR\vcontentType\"\xc1\x03\n" +
+ "\fcontent_type\x18\x04 \x01(\tR\vcontentType\"\xe2\x03\n" +
"\n" +
"ClipRecord\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12)\n" +
@@ -1911,7 +1945,9 @@ const file_copysync_v1_daemon_proto_rawDesc = "" +
"\x0fcreated_at_unix\x18\n" +
" \x01(\x03R\rcreatedAtUnix\x12&\n" +
"\x0fexpires_at_unix\x18\v \x01(\x03R\rexpiresAtUnix\x12\x14\n" +
- "\x05error\x18\f \x01(\tR\x05error\"1\n" +
+ "\x05error\x18\f \x01(\tR\x05error\x12\x1f\n" +
+ "\vimage_count\x18\r \x01(\x05R\n" +
+ "imageCount\"1\n" +
"\x10SubscribeRequest\x12\x1d\n" +
"\n" +
"since_unix\x18\x01 \x01(\x03R\tsinceUnix\"\x8d\x01\n" +
@@ -2010,11 +2046,14 @@ const file_copysync_v1_daemon_proto_rawDesc = "" +
"\x14clipboard_permission\x18\x04 \x01(\x0e2 .copysync.v1.ClipboardPermissionR\x13clipboardPermission\x12(\n" +
"\x10cache_bytes_used\x18\x05 \x01(\x03R\x0ecacheBytesUsed\x12!\n" +
"\fpeers_online\x18\x06 \x01(\x05R\vpeersOnline\x12\x18\n" +
- "\aversion\x18\a \x01(\tR\aversion\"1\n" +
+ "\aversion\x18\a \x01(\tR\aversion\"G\n" +
"\x16GetImagePreviewRequest\x12\x17\n" +
- "\aclip_id\x18\x01 \x01(\tR\x06clipId\"-\n" +
+ "\aclip_id\x18\x01 \x01(\tR\x06clipId\x12\x14\n" +
+ "\x05index\x18\x02 \x01(\x05R\x05index\"W\n" +
"\x17GetImagePreviewResponse\x12\x12\n" +
- "\x04path\x18\x01 \x01(\tR\x04path*v\n" +
+ "\x04path\x18\x01 \x01(\tR\x04path\x12\x14\n" +
+ "\x05count\x18\x02 \x01(\x05R\x05count\x12\x12\n" +
+ "\x04name\x18\x03 \x01(\tR\x04name*v\n" +
"\bClipKind\x12\x19\n" +
"\x15CLIP_KIND_UNSPECIFIED\x10\x00\x12\x12\n" +
"\x0eCLIP_KIND_TEXT\x10\x01\x12\x12\n" +
diff --git a/proto/gen/copysync/v1/daemon_grpc.pb.go b/proto/gen/copysync/v1/daemon_grpc.pb.go
index 5511589..aa1b941 100644
--- a/proto/gen/copysync/v1/daemon_grpc.pb.go
+++ b/proto/gen/copysync/v1/daemon_grpc.pb.go
@@ -54,7 +54,7 @@ type DaemonServiceClient interface {
Fetch(ctx context.Context, in *FetchRequest, opts ...grpc.CallOption) (*Empty, error)
// 把某条已就绪的记录重新放进本机剪贴板
ApplyToClipboard(ctx context.Context, in *ApplyToClipboardRequest, opts ...grpc.CallOption) (*Empty, error)
- // 只返回已就绪图片在本机的路径,不改动剪贴板,也不把路径发给对端。
+ // 只返回已就绪图片(或图片文件)在本机的路径,不改动剪贴板,也不把路径发给对端。
GetImagePreview(ctx context.Context, in *GetImagePreviewRequest, opts ...grpc.CallOption) (*GetImagePreviewResponse, error)
ListDevices(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ListDevicesResponse, error)
CreatePairingCode(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*CreatePairingCodeResponse, error)
@@ -260,7 +260,7 @@ type DaemonServiceServer interface {
Fetch(context.Context, *FetchRequest) (*Empty, error)
// 把某条已就绪的记录重新放进本机剪贴板
ApplyToClipboard(context.Context, *ApplyToClipboardRequest) (*Empty, error)
- // 只返回已就绪图片在本机的路径,不改动剪贴板,也不把路径发给对端。
+ // 只返回已就绪图片(或图片文件)在本机的路径,不改动剪贴板,也不把路径发给对端。
GetImagePreview(context.Context, *GetImagePreviewRequest) (*GetImagePreviewResponse, error)
ListDevices(context.Context, *Empty) (*ListDevicesResponse, error)
CreatePairingCode(context.Context, *Empty) (*CreatePairingCodeResponse, error)
diff --git a/scripts/build-windows.ps1 b/scripts/build-windows.ps1
index 40c4e63..b9d1dfa 100644
--- a/scripts/build-windows.ps1
+++ b/scripts/build-windows.ps1
@@ -4,7 +4,7 @@
# CopySync-Setup.exe 安装程序(需要 Inno Setup 6)
# CopySync-windows-x64.zip 便携版
#
-# powershell -ExecutionPolicy Bypass -File scripts\build-windows.ps1 [-Version 1.3.0]
+# powershell -ExecutionPolicy Bypass -File scripts\build-windows.ps1 [-Version 1.3.1]
#
# 需要 Go、Flutter 与 Visual Studio(「使用 C++ 的桌面开发」)。
# 后台服务是纯 Go,也可以在 Mac 上交叉编译;界面只能在 Windows 上构建。
diff --git a/scripts/build.sh b/scripts/build.sh
index 0255728..4290ea9 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -14,7 +14,7 @@ set -euo pipefail
cd "$(dirname "$0")/.."
DIST=dist
-VERSION=${VERSION:-1.3.0}
+VERSION=${VERSION:-1.3.1}
rm -rf "$DIST" && mkdir -p "$DIST"
# 构建 x86_64 + arm64 通用二进制:两台 Mac 的芯片未必相同,单架构的
diff --git a/scripts/package.sh b/scripts/package.sh
index 22a9b12..5965405 100755
--- a/scripts/package.sh
+++ b/scripts/package.sh
@@ -18,7 +18,7 @@
set -euo pipefail
cd "$(dirname "$0")/.."
-export VERSION=${VERSION:-1.3.0}
+export VERSION=${VERSION:-1.3.1}
OUT=release
./scripts/build.sh
diff --git a/tools/installer/copysync.iss b/tools/installer/copysync.iss
index 1e5e911..c1c643a 100644
--- a/tools/installer/copysync.iss
+++ b/tools/installer/copysync.iss
@@ -1,6 +1,6 @@
; CopySync 的 Windows 安装程序(Inno Setup 6)。由 scripts\build-windows.ps1 调用:
;
-; iscc /DAppVersion=1.3.0 /DSourceDir=<构建好的目录> /DOutputDir=<输出目录> tools\installer\copysync.iss
+; iscc /DAppVersion=1.3.1 /DSourceDir=<构建好的目录> /DOutputDir=<输出目录> tools\installer\copysync.iss
;
; 按用户安装:装到 %LOCALAPPDATA%\Programs\CopySync,不需要管理员权限、不弹 UAC。
; 数据目录 %LOCALAPPDATA%\CopySync 与安装目录分开,升级、重装都不受影响。
diff --git a/tools/site/build.py b/tools/site/build.py
index a5419fe..42588eb 100644
--- a/tools/site/build.py
+++ b/tools/site/build.py
@@ -18,7 +18,7 @@ DOCS = ROOT / "docs"
SITE = "https://baiyuze.github.io/copysync/"
REPO = "https://github.com/baiyuze/copysync"
DL = REPO + "/releases/latest/download/"
-VERSION = "1.3.0"
+VERSION = "1.3.1"
DATE = "2026-10-09"
# 语言代码 → (页面目录, html 的 lang, og:locale, 语言名)
diff --git a/tools/site/content/en.py b/tools/site/content/en.py
index 355bdb3..6f1937a 100644
--- a/tools/site/content/en.py
+++ b/tools/site/content/en.py
@@ -25,7 +25,7 @@ C = {
"Data moves directly between your devices, and stays encrypted even when it passes through your own server.",
"dl_mac": "Download for Mac",
"dl_win": "Download for Windows",
- "dl_note": "Version 1.3.0, free and open source. macOS 13 or later, Intel and Apple silicon; Windows 10 and 11.",
+ "dl_note": "Version 1.3.1, free and open source. macOS 13 or later, Intel and Apple silicon; Windows 10 and 11.",
"stage_label": "Demo: Command C on a MacBook turns a file into a sheet that flies over a direct connection to a Windows "
"laptop, where Ctrl V pastes it",
"stage_file": "Q3 review - final.pptx",
@@ -181,7 +181,7 @@ C = {
"specs_h2": "Specifications",
"specs": [
- ("Version", '1.3.0, released <time datetime="2026-10-09">October 9, 2026</time>'),
+ ("Version", '1.3.1, released <time datetime="2026-10-09">October 9, 2026</time>'),
("Mac app", "macOS 13 Ventura or later; universal binary for Intel and Apple silicon, no Rosetta; about 47 MB download"),
("Windows app", "Windows 10 (21H2 or later) and Windows 11, x64; installs per user, no administrator rights; about 23 MB download"),
("Server", "Linux on x86_64 or ARM64 (systemd or Docker), or macOS; about 15 MB of RAM"),
diff --git a/tools/site/content/ja.py b/tools/site/content/ja.py
index 6af9ab7..520e710 100644
--- a/tools/site/content/ja.py
+++ b/tools/site/content/ja.py
@@ -25,7 +25,7 @@ C = {
"データはデバイス間を直接流れ、自分のサーバーを経由するときも暗号化されたままです。",
"dl_mac": "Mac 版をダウンロード",
"dl_win": "Windows 版をダウンロード",
- "dl_note": "バージョン 1.3.0、無料・オープンソース。macOS 13 以降(Intel と Apple シリコン)、Windows 10・11。",
+ "dl_note": "バージョン 1.3.1、無料・オープンソース。macOS 13 以降(Intel と Apple シリコン)、Windows 10・11。",
"stage_label": "デモ:MacBook で Command C を押すと、ファイルが一枚の紙になって直接接続で Windows ノートへ飛び、そこで Ctrl V を押して貼り付けます",
"stage_file": "四半期報告_最終版.pptx",
"stage_win": "Windows ノート",
@@ -172,7 +172,7 @@ C = {
"specs_h2": "仕様",
"specs": [
- ("バージョン", '1.3.0(<time datetime="2026-10-09">2026 年 10 月 9 日</time>公開)'),
+ ("バージョン", '1.3.1(<time datetime="2026-10-09">2026 年 10 月 9 日</time>公開)'),
("Mac アプリ", "macOS 13 Ventura 以降。Intel と Apple シリコンのユニバーサルバイナリで Rosetta 不要。ダウンロードは約 47 MB"),
("Windows アプリ", "Windows 10(21H2 以降)と Windows 11、x64。ユーザーごとのインストールで管理者権限不要。ダウンロードは約 23 MB"),
("サーバー", "Linux(x86_64 または ARM64、systemd または Docker)、macOS でも動作。メモリは約 15 MB"),
diff --git a/tools/site/content/zh.py b/tools/site/content/zh.py
index 3398110..86687b5 100644
--- a/tools/site/content/zh.py
+++ b/tools/site/content/zh.py
@@ -23,7 +23,7 @@ C = {
"数据在你的设备之间直接传输,经过你自己的服务器时也是加密的。",
"dl_mac": "下载 Mac 版",
"dl_win": "下载 Windows 版",
- "dl_note": "版本 1.3.0,免费开源。macOS 13 及以上,Intel 与 Apple 芯片通用;Windows 10、11。",
+ "dl_note": "版本 1.3.1,免费开源。macOS 13 及以上,Intel 与 Apple 芯片通用;Windows 10、11。",
"stage_label": "演示:在 MacBook 上按下 Command C,文件化作一张纸,经直连飞到 Windows 笔记本,在那里按下 Ctrl V 粘贴出来",
"stage_file": "季度汇报-终版.pptx",
"stage_win": "Windows 笔记本",
@@ -166,7 +166,7 @@ C = {
"specs_h2": "技术规格",
"specs": [
- ("版本", '1.3.0,<time datetime="2026-10-09">2026 年 10 月 9 日</time>发布'),
+ ("版本", '1.3.1,<time datetime="2026-10-09">2026 年 10 月 9 日</time>发布'),
("Mac 客户端", "macOS 13 Ventura 及以上;Intel 与 Apple 芯片通用,不需要 Rosetta;安装包约 47 MB"),
("Windows 客户端", "Windows 10(21H2 及以上)与 Windows 11,x64;按用户安装,不需要管理员权限;安装包约 23 MB"),
("服务器", "Linux x86_64 或 ARM64(systemd 或 Docker),也可以运行在 macOS 上;约 15 MB 内存"),
diff --git a/ui/lib/app_state.dart b/ui/lib/app_state.dart
index 7b8382b..63af45c 100644
--- a/ui/lib/app_state.dart
+++ b/ui/lib/app_state.dart
@@ -378,11 +378,11 @@ class AppState extends ChangeNotifier {
Future<void> applyToClipboard(String clipId) =>
_client.applyToClipboard(ApplyToClipboardRequest(clipId: clipId));
- Future<String> imagePreviewPath(String clipId) async {
- final response = await _client.getImagePreview(GetImagePreviewRequest(clipId: clipId),
- options: CallOptions(timeout: const Duration(seconds: 10)));
- return response.path;
- }
+ /// 一条记录里第 [index] 张图片:本机路径、文件名,以及能预览的图片总数。
+ /// HEIC 这类格式由后台服务先转换,大图可能要一两秒,超时放宽一些。
+ Future<GetImagePreviewResponse> imagePreview(String clipId, {int index = 0}) =>
+ _client.getImagePreview(GetImagePreviewRequest(clipId: clipId, index: index),
+ options: CallOptions(timeout: const Duration(seconds: 20)));
Future<void> requestClipboardPermission() =>
_client.requestClipboardPermission(Empty());
diff --git a/ui/lib/gen/copysync/v1/daemon.pb.dart b/ui/lib/gen/copysync/v1/daemon.pb.dart
index a52fa73..e843671 100644
--- a/ui/lib/gen/copysync/v1/daemon.pb.dart
+++ b/ui/lib/gen/copysync/v1/daemon.pb.dart
@@ -165,6 +165,7 @@ class ClipRecord extends $pb.GeneratedMessage {
$fixnum.Int64? createdAtUnix,
$fixnum.Int64? expiresAtUnix,
$core.String? error,
+ $core.int? imageCount,
}) {
final result = ClipRecord._();
if (id != null) result.id = id;
@@ -179,6 +180,7 @@ class ClipRecord extends $pb.GeneratedMessage {
if (createdAtUnix != null) result.createdAtUnix = createdAtUnix;
if (expiresAtUnix != null) result.expiresAtUnix = expiresAtUnix;
if (error != null) result.error = error;
+ if (imageCount != null) result.imageCount = imageCount;
return result;
}
@@ -210,6 +212,7 @@ class ClipRecord extends $pb.GeneratedMessage {
..aInt64(10, _omitFieldNames ? '' : 'createdAtUnix')
..aInt64(11, _omitFieldNames ? '' : 'expiresAtUnix')
..aOS(12, _omitFieldNames ? '' : 'error')
+ ..aI(13, _omitFieldNames ? '' : 'imageCount')
..hasRequiredFields = false;
@$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
@@ -333,6 +336,17 @@ class ClipRecord extends $pb.GeneratedMessage {
$core.bool hasError() => $_has(11);
@$pb.TagNumber(12)
void clearError() => $_clearField(12);
+
+ /// 能在界面里预览的图片数:剪贴板图片为 1,文件记录是其中图片文件的个数。
+ /// 由本机后台服务按文件名判断,HEIC、TIFF 这类格式只有能转换它的平台才算。
+ @$pb.TagNumber(13)
+ $core.int get imageCount => $_getIZ(12);
+ @$pb.TagNumber(13)
+ set imageCount($core.int value) => $_setSignedInt32(12, value);
+ @$pb.TagNumber(13)
+ $core.bool hasImageCount() => $_has(12);
+ @$pb.TagNumber(13)
+ void clearImageCount() => $_clearField(13);
}
class SubscribeRequest extends $pb.GeneratedMessage {
@@ -2073,9 +2087,11 @@ class Status extends $pb.GeneratedMessage {
class GetImagePreviewRequest extends $pb.GeneratedMessage {
factory GetImagePreviewRequest({
$core.String? clipId,
+ $core.int? index,
}) {
final result = GetImagePreviewRequest._();
if (clipId != null) result.clipId = clipId;
+ if (index != null) result.index = index;
return result;
}
@@ -2093,6 +2109,7 @@ class GetImagePreviewRequest extends $pb.GeneratedMessage {
package: const $pb.PackageName(_omitMessageNames ? '' : 'copysync.v1'),
createEmptyInstance: GetImagePreviewRequest.$_createMessage)
..aOS(1, _omitFieldNames ? '' : 'clipId')
+ ..aI(2, _omitFieldNames ? '' : 'index')
..hasRequiredFields = false;
@$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
@@ -2127,14 +2144,27 @@ class GetImagePreviewRequest extends $pb.GeneratedMessage {
$core.bool hasClipId() => $_has(0);
@$pb.TagNumber(1)
void clearClipId() => $_clearField(1);
+
+ @$pb.TagNumber(2)
+ $core.int get index => $_getIZ(1);
+ @$pb.TagNumber(2)
+ set index($core.int value) => $_setSignedInt32(1, value);
+ @$pb.TagNumber(2)
+ $core.bool hasIndex() => $_has(1);
+ @$pb.TagNumber(2)
+ void clearIndex() => $_clearField(2);
}
class GetImagePreviewResponse extends $pb.GeneratedMessage {
factory GetImagePreviewResponse({
$core.String? path,
+ $core.int? count,
+ $core.String? name,
}) {
final result = GetImagePreviewResponse._();
if (path != null) result.path = path;
+ if (count != null) result.count = count;
+ if (name != null) result.name = name;
return result;
}
@@ -2152,6 +2182,8 @@ class GetImagePreviewResponse extends $pb.GeneratedMessage {
package: const $pb.PackageName(_omitMessageNames ? '' : 'copysync.v1'),
createEmptyInstance: GetImagePreviewResponse.$_createMessage)
..aOS(1, _omitFieldNames ? '' : 'path')
+ ..aI(2, _omitFieldNames ? '' : 'count')
+ ..aOS(3, _omitFieldNames ? '' : 'name')
..hasRequiredFields = false;
@$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
@@ -2186,6 +2218,24 @@ class GetImagePreviewResponse extends $pb.GeneratedMessage {
$core.bool hasPath() => $_has(0);
@$pb.TagNumber(1)
void clearPath() => $_clearField(1);
+
+ @$pb.TagNumber(2)
+ $core.int get count => $_getIZ(1);
+ @$pb.TagNumber(2)
+ set count($core.int value) => $_setSignedInt32(1, value);
+ @$pb.TagNumber(2)
+ $core.bool hasCount() => $_has(1);
+ @$pb.TagNumber(2)
+ void clearCount() => $_clearField(2);
+
+ @$pb.TagNumber(3)
+ $core.String get name => $_getSZ(2);
+ @$pb.TagNumber(3)
+ set name($core.String value) => $_setString(2, value);
+ @$pb.TagNumber(3)
+ $core.bool hasName() => $_has(2);
+ @$pb.TagNumber(3)
+ void clearName() => $_clearField(3);
}
const $core.bool _omitFieldNames =
diff --git a/ui/lib/gen/copysync/v1/daemon.pbgrpc.dart b/ui/lib/gen/copysync/v1/daemon.pbgrpc.dart
index b43bd58..227010c 100644
--- a/ui/lib/gen/copysync/v1/daemon.pbgrpc.dart
+++ b/ui/lib/gen/copysync/v1/daemon.pbgrpc.dart
@@ -72,7 +72,7 @@ class DaemonServiceClient extends $grpc.Client {
return $createUnaryCall(_$applyToClipboard, request, options: options);
}
- /// 只返回已就绪图片在本机的路径,不改动剪贴板,也不把路径发给对端。
+ /// 只返回已就绪图片(或图片文件)在本机的路径,不改动剪贴板,也不把路径发给对端。
$grpc.ResponseFuture<$0.GetImagePreviewResponse> getImagePreview(
$0.GetImagePreviewRequest request, {
$grpc.CallOptions? options,
diff --git a/ui/lib/gen/copysync/v1/daemon.pbjson.dart b/ui/lib/gen/copysync/v1/daemon.pbjson.dart
index 26f018a..7d1cb2a 100644
--- a/ui/lib/gen/copysync/v1/daemon.pbjson.dart
+++ b/ui/lib/gen/copysync/v1/daemon.pbjson.dart
@@ -159,6 +159,7 @@ const ClipRecord$json = {
{'1': 'created_at_unix', '3': 10, '4': 1, '5': 3, '10': 'createdAtUnix'},
{'1': 'expires_at_unix', '3': 11, '4': 1, '5': 3, '10': 'expiresAtUnix'},
{'1': 'error', '3': 12, '4': 1, '5': 9, '10': 'error'},
+ {'1': 'image_count', '3': 13, '4': 1, '5': 5, '10': 'imageCount'},
],
};
@@ -172,7 +173,7 @@ final $typed_data.Uint8List clipRecordDescriptor = $convert.base64Decode(
'RlbXMSHQoKdG90YWxfc2l6ZRgIIAEoA1IJdG90YWxTaXplEiEKDHRleHRfcHJldmlldxgJIAEo'
'CVILdGV4dFByZXZpZXcSJgoPY3JlYXRlZF9hdF91bml4GAogASgDUg1jcmVhdGVkQXRVbml4Ei'
'YKD2V4cGlyZXNfYXRfdW5peBgLIAEoA1INZXhwaXJlc0F0VW5peBIUCgVlcnJvchgMIAEoCVIF'
- 'ZXJyb3I=');
+ 'ZXJyb3ISHwoLaW1hZ2VfY291bnQYDSABKAVSCmltYWdlQ291bnQ=');
@$core.Deprecated('Use subscribeRequestDescriptor instead')
const SubscribeRequest$json = {
@@ -644,23 +645,28 @@ const GetImagePreviewRequest$json = {
'1': 'GetImagePreviewRequest',
'2': [
{'1': 'clip_id', '3': 1, '4': 1, '5': 9, '10': 'clipId'},
+ {'1': 'index', '3': 2, '4': 1, '5': 5, '10': 'index'},
],
};
/// Descriptor for `GetImagePreviewRequest`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List getImagePreviewRequestDescriptor =
$convert.base64Decode(
- 'ChZHZXRJbWFnZVByZXZpZXdSZXF1ZXN0EhcKB2NsaXBfaWQYASABKAlSBmNsaXBJZA==');
+ 'ChZHZXRJbWFnZVByZXZpZXdSZXF1ZXN0EhcKB2NsaXBfaWQYASABKAlSBmNsaXBJZBIUCgVpbm'
+ 'RleBgCIAEoBVIFaW5kZXg=');
@$core.Deprecated('Use getImagePreviewResponseDescriptor instead')
const GetImagePreviewResponse$json = {
'1': 'GetImagePreviewResponse',
'2': [
{'1': 'path', '3': 1, '4': 1, '5': 9, '10': 'path'},
+ {'1': 'count', '3': 2, '4': 1, '5': 5, '10': 'count'},
+ {'1': 'name', '3': 3, '4': 1, '5': 9, '10': 'name'},
],
};
/// Descriptor for `GetImagePreviewResponse`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List getImagePreviewResponseDescriptor =
$convert.base64Decode(
- 'ChdHZXRJbWFnZVByZXZpZXdSZXNwb25zZRISCgRwYXRoGAEgASgJUgRwYXRo');
+ 'ChdHZXRJbWFnZVByZXZpZXdSZXNwb25zZRISCgRwYXRoGAEgASgJUgRwYXRoEhQKBWNvdW50GA'
+ 'IgASgFUgVjb3VudBISCgRuYW1lGAMgASgJUgRuYW1l');
diff --git a/ui/lib/icons.dart b/ui/lib/icons.dart
index 6348498..988766c 100644
--- a/ui/lib/icons.dart
+++ b/ui/lib/icons.dart
@@ -38,6 +38,8 @@ abstract final class AppIcons {
static IconData get docOnClipboard =>
_pick(CupertinoIcons.doc_on_clipboard, FluentIcons.clipboard_paste_24_regular);
static IconData get doc => _pick(CupertinoIcons.doc, FluentIcons.document_24_regular);
+ static IconData get chevronLeft => _pick(CupertinoIcons.chevron_left, FluentIcons.chevron_left_24_regular);
+ static IconData get chevronRight => _pick(CupertinoIcons.chevron_right, FluentIcons.chevron_right_24_regular);
static IconData get chevronUpDown =>
_pick(CupertinoIcons.chevron_up_chevron_down, FluentIcons.chevron_up_down_24_regular);
}
diff --git a/ui/lib/l10n/app_en.arb b/ui/lib/l10n/app_en.arb
index ea9cad6..8870f0c 100644
--- a/ui/lib/l10n/app_en.arb
+++ b/ui/lib/l10n/app_en.arb
@@ -180,7 +180,6 @@
"fetchStarted": "Pulling…",
"transferFailed": "Transfer failed",
"expired": "Expired",
- "preview": "Preview",
"putOnClipboard": "Copy to clipboard",
"putOnClipboardDone": "On the clipboard",
"deleteRecord": "Delete this item",
@@ -203,6 +202,8 @@
},
"imagePreviewTitle": "Image preview",
"closePreview": "Close preview",
+ "previousImage": "Previous image",
+ "nextImage": "Next image",
"previewHint": "Scroll or pinch to zoom, drag to move around",
"fitWindow": "Fit to window",
"previewDeleted": "This image has been deleted from the history",
diff --git a/ui/lib/l10n/app_ja.arb b/ui/lib/l10n/app_ja.arb
index f5887da..634769b 100644
--- a/ui/lib/l10n/app_ja.arb
+++ b/ui/lib/l10n/app_ja.arb
@@ -62,7 +62,6 @@
"fetchStarted": "取り込みを開始しました",
"transferFailed": "転送に失敗しました",
"expired": "期限切れ",
- "preview": "プレビュー",
"putOnClipboard": "クリップボードに入れる",
"putOnClipboardDone": "クリップボードに入れました",
"deleteRecord": "この履歴を削除",
@@ -72,6 +71,8 @@
"itemsSummary": "{name} ほか {others} 件",
"imagePreviewTitle": "画像プレビュー",
"closePreview": "プレビューを閉じる",
+ "previousImage": "前の画像",
+ "nextImage": "次の画像",
"previewHint": "ホイールやトラックパッドで拡大縮小、ドラッグで移動",
"fitWindow": "ウィンドウに合わせる",
"previewDeleted": "この画像は履歴から削除されました",
diff --git a/ui/lib/l10n/app_localizations.dart b/ui/lib/l10n/app_localizations.dart
index d432081..027c20e 100644
--- a/ui/lib/l10n/app_localizations.dart
+++ b/ui/lib/l10n/app_localizations.dart
@@ -472,12 +472,6 @@ abstract class AppLocalizations {
/// **'Expired'**
String get expired;
- /// No description provided for @preview.
- ///
- /// In en, this message translates to:
- /// **'Preview'**
- String get preview;
-
/// No description provided for @putOnClipboard.
///
/// In en, this message translates to:
@@ -532,6 +526,18 @@ abstract class AppLocalizations {
/// **'Close preview'**
String get closePreview;
+ /// No description provided for @previousImage.
+ ///
+ /// In en, this message translates to:
+ /// **'Previous image'**
+ String get previousImage;
+
+ /// No description provided for @nextImage.
+ ///
+ /// In en, this message translates to:
+ /// **'Next image'**
+ String get nextImage;
+
/// No description provided for @previewHint.
///
/// In en, this message translates to:
diff --git a/ui/lib/l10n/app_localizations_en.dart b/ui/lib/l10n/app_localizations_en.dart
index ae7120d..76dd067 100644
--- a/ui/lib/l10n/app_localizations_en.dart
+++ b/ui/lib/l10n/app_localizations_en.dart
@@ -279,9 +279,6 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get expired => 'Expired';
- @override
- String get preview => 'Preview';
-
@override
String get putOnClipboard => 'Copy to clipboard';
@@ -317,6 +314,12 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get closePreview => 'Close preview';
+ @override
+ String get previousImage => 'Previous image';
+
+ @override
+ String get nextImage => 'Next image';
+
@override
String get previewHint => 'Scroll or pinch to zoom, drag to move around';
diff --git a/ui/lib/l10n/app_localizations_ja.dart b/ui/lib/l10n/app_localizations_ja.dart
index a1c2ed0..f52f879 100644
--- a/ui/lib/l10n/app_localizations_ja.dart
+++ b/ui/lib/l10n/app_localizations_ja.dart
@@ -228,9 +228,6 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get expired => '期限切れ';
- @override
- String get preview => 'プレビュー';
-
@override
String get putOnClipboard => 'クリップボードに入れる';
@@ -260,6 +257,12 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get closePreview => 'プレビューを閉じる';
+ @override
+ String get previousImage => '前の画像';
+
+ @override
+ String get nextImage => '次の画像';
+
@override
String get previewHint => 'ホイールやトラックパッドで拡大縮小、ドラッグで移動';
diff --git a/ui/lib/l10n/app_localizations_zh.dart b/ui/lib/l10n/app_localizations_zh.dart
index 1810a0a..371a175 100644
--- a/ui/lib/l10n/app_localizations_zh.dart
+++ b/ui/lib/l10n/app_localizations_zh.dart
@@ -227,9 +227,6 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get expired => '已过期';
- @override
- String get preview => '预览';
-
@override
String get putOnClipboard => '放入剪贴板';
@@ -259,6 +256,12 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get closePreview => '关闭预览';
+ @override
+ String get previousImage => '上一张';
+
+ @override
+ String get nextImage => '下一张';
+
@override
String get previewHint => '滚轮或触控板缩放,拖动查看';
diff --git a/ui/lib/l10n/app_zh.arb b/ui/lib/l10n/app_zh.arb
index e0c8be7..fe1b8fd 100644
--- a/ui/lib/l10n/app_zh.arb
+++ b/ui/lib/l10n/app_zh.arb
@@ -62,7 +62,6 @@
"fetchStarted": "开始拉取",
"transferFailed": "传输失败",
"expired": "已过期",
- "preview": "预览",
"putOnClipboard": "放入剪贴板",
"putOnClipboardDone": "已放入剪贴板",
"deleteRecord": "删除这条记录",
@@ -72,6 +71,8 @@
"itemsSummary": "{name} 等 {count} 项",
"imagePreviewTitle": "图片预览",
"closePreview": "关闭预览",
+ "previousImage": "上一张",
+ "nextImage": "下一张",
"previewHint": "滚轮或触控板缩放,拖动查看",
"fitWindow": "适应窗口",
"previewDeleted": "这条图片记录已被删除",
diff --git a/ui/lib/pages/history_page.dart b/ui/lib/pages/history_page.dart
index ff67d04..4c3ab11 100644
--- a/ui/lib/pages/history_page.dart
+++ b/ui/lib/pages/history_page.dart
@@ -188,13 +188,15 @@ class _RecordRowState extends State<_RecordRow> {
Widget build(BuildContext context) {
final r = widget.record;
final p = context.palette;
+ // 剪贴板里的图片、以及复制的图片文件,点一下这一行就能预览,不另放按钮
+ final previewable = r.imageCount > 0;
return MouseRegion(
- cursor: r.kind == ClipKind.CLIP_KIND_IMAGE ? SystemMouseCursors.click : MouseCursor.defer,
+ cursor: previewable ? SystemMouseCursors.click : MouseCursor.defer,
onEnter: (_) => setState(() => _hovered = true),
onExit: (_) => setState(() => _hovered = false),
child: InkWell(
- onTap: r.kind == ClipKind.CLIP_KIND_IMAGE ? () => _preview(r) : null,
+ onTap: previewable ? () => showImagePreview(context, r.id) : null,
borderRadius: BorderRadius.circular(Radii.sm),
child: Container(
constraints: const BoxConstraints(minHeight: 52),
@@ -276,7 +278,7 @@ class _RecordRowState extends State<_RecordRow> {
return Text(l.expired, style: context.text.bodySmall?.copyWith(color: p.textFaint));
default:
// 悬停时才显示「放入剪贴板」与删除,静态时列表保持干净。
- // 不悬停时它们只是看不见,位置照样留着:鼠标移上来时「预览」不会被挤开,不容易点错
+ // 不悬停时它们只是看不见,位置照样留着:鼠标移上来时标题不会被挤短一截
Widget hoverOnly(Widget child) => Visibility(
visible: _hovered,
maintainSize: true,
@@ -287,8 +289,6 @@ class _RecordRowState extends State<_RecordRow> {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
- if (r.kind == ClipKind.CLIP_KIND_IMAGE)
- TextButton(onPressed: () => _preview(r), child: Text(l.preview)),
hoverOnly(TextButton(
onPressed: () =>
_run(() => AppScope.read(context).applyToClipboard(r.id), l.putOnClipboardDone),
@@ -304,8 +304,6 @@ class _RecordRowState extends State<_RecordRow> {
}
}
- void _preview(ClipRecord record) => showImagePreview(context, record.id);
-
Future<void> _run(Future<void> Function() action, String success) async {
setState(() => _busy = true);
try {
@@ -324,6 +322,8 @@ IconData kindIcon(ClipRecord r) => switch (r.kind) {
ClipKind.CLIP_KIND_TEXT => AppIcons.textAlignLeft,
ClipKind.CLIP_KIND_HTML => AppIcons.docRichtext,
ClipKind.CLIP_KIND_IMAGE => AppIcons.photo,
+ // 单张图片文件也用图片图标,一眼看出点开能预览
+ ClipKind.CLIP_KIND_FILE when r.items.length == 1 && r.imageCount == 1 => AppIcons.photo,
ClipKind.CLIP_KIND_FILE when r.items.length > 1 => AppIcons.docOnDoc,
ClipKind.CLIP_KIND_FILE when r.items.isNotEmpty && r.items.first.isDir =>
AppIcons.folder,
diff --git a/ui/lib/widgets/image_preview_dialog.dart b/ui/lib/widgets/image_preview_dialog.dart
index 8580a66..bd920ad 100644
--- a/ui/lib/widgets/image_preview_dialog.dart
+++ b/ui/lib/widgets/image_preview_dialog.dart
@@ -1,6 +1,7 @@
import 'dart:io';
import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
import '../app_state.dart';
import '../gen/copysync/v1/daemon.pb.dart';
@@ -26,10 +27,36 @@ class ImagePreviewDialog extends StatefulWidget {
class _ImagePreviewDialogState extends State<ImagePreviewDialog> {
final _transform = TransformationController();
- Future<String>? _preview;
+ Future<GetImagePreviewResponse>? _preview;
bool _requesting = false;
String? _downloadError;
+ // 一条记录里有多张图片时(复制了几张照片),左右翻看
+ int _index = 0;
+ int _count = 1;
+ String _name = '';
+
+ Future<GetImagePreviewResponse> _load(AppState state, String clipId) =>
+ state.imagePreview(clipId, index: _index).then((response) {
+ if (mounted) {
+ setState(() {
+ _count = response.count < 1 ? 1 : response.count;
+ _name = response.name;
+ });
+ }
+ return response;
+ });
+
+ void _go(int delta) {
+ if (_count < 2) return;
+ setState(() {
+ _index = (_index + delta) % _count;
+ if (_index < 0) _index += _count;
+ _preview = null;
+ _transform.value = Matrix4.identity();
+ });
+ }
+
@override
void dispose() {
_transform.dispose();
@@ -60,7 +87,8 @@ class _ImagePreviewDialogState extends State<ImagePreviewDialog> {
.firstOrNull;
// 预览框按应用窗口的比例定大小:窗口小,预览也小,不会一打开就把整个窗口盖满
final window = MediaQuery.sizeOf(context);
- return Dialog(
+ final l = context.l10n;
+ final dialog = Dialog(
insetPadding: EdgeInsets.zero,
child: SizedBox(
width: (window.width * 0.8).clamp(280.0, 1400.0),
@@ -77,10 +105,29 @@ class _ImagePreviewDialogState extends State<ImagePreviewDialog> {
child: Row(
children: [
Expanded(
- child: Text(context.l10n.imagePreviewTitle, style: context.text.titleMedium),
+ child: Text(
+ _name.isEmpty ? l.imagePreviewTitle : _name,
+ style: context.text.titleMedium,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
),
+ if (_count > 1) ...[
+ IconButton(
+ tooltip: l.previousImage,
+ onPressed: () => _go(-1),
+ icon: Icon(AppIcons.chevronLeft, size: 16),
+ ),
+ Text('${_index + 1} / $_count', style: context.text.bodySmall),
+ IconButton(
+ tooltip: l.nextImage,
+ onPressed: () => _go(1),
+ icon: Icon(AppIcons.chevronRight, size: 16),
+ ),
+ const SizedBox(width: Insets.sm),
+ ],
IconButton(
- tooltip: context.l10n.closePreview,
+ tooltip: l.closePreview,
onPressed: () => Navigator.pop(context),
icon: Icon(AppIcons.xmark),
),
@@ -115,6 +162,14 @@ class _ImagePreviewDialogState extends State<ImagePreviewDialog> {
),
),
);
+ // 左右方向键翻看上一张、下一张
+ return CallbackShortcuts(
+ bindings: {
+ const SingleActivator(LogicalKeyboardKey.arrowLeft): () => _go(-1),
+ const SingleActivator(LogicalKeyboardKey.arrowRight): () => _go(1),
+ },
+ child: Focus(autofocus: true, child: dialog),
+ );
}
Widget _content(AppState state, ClipRecord? record) {
@@ -151,8 +206,8 @@ class _ImagePreviewDialogState extends State<ImagePreviewDialog> {
return _message(context.l10n.previewUnavailable);
}
- _preview ??= state.imagePreviewPath(record.id);
- return FutureBuilder<String>(
+ _preview ??= _load(state, record.id);
+ return FutureBuilder<GetImagePreviewResponse>(
future: _preview,
builder: (context, snapshot) {
if (snapshot.hasError) {
@@ -177,7 +232,7 @@ class _ImagePreviewDialogState extends State<ImagePreviewDialog> {
key: const ValueKey('image-preview-content'),
// 预览限制解码尺寸并保持比例,超大截图不占用整张原图的内存。
image: ResizeImage(
- FileImage(File(snapshot.data!)),
+ FileImage(File(snapshot.data!.path)),
width: 2048,
height: 2048,
policy: ResizeImagePolicy.fit,
diff --git a/ui/pubspec.yaml b/ui/pubspec.yaml
index 5ee88ef..f5007d0 100644
--- a/ui/pubspec.yaml
+++ b/ui/pubspec.yaml
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
-version: 1.3.0+8
+version: 1.3.1+9
environment:
sdk: ^3.12.2
diff --git a/ui/test/image_preview_test.dart b/ui/test/image_preview_test.dart
index 0315f57..e207818 100644
--- a/ui/test/image_preview_test.dart
+++ b/ui/test/image_preview_test.dart
@@ -6,26 +6,31 @@ 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/services.dart';
import 'package:flutter_test/flutter_test.dart';
class PreviewState extends AppState {
- PreviewState(this.path, {ClipStatus status = ClipStatus.CLIP_STATUS_READY}) {
+ PreviewState(this.path, {ClipStatus status = ClipStatus.CLIP_STATUS_READY, List<ClipRecord>? records}) {
debugSeed(
status: Status(signalingConnected: true),
config: Config(),
self: Device(id: 'self'),
- records: [
- ClipRecord(
- id: 'image',
- kind: ClipKind.CLIP_KIND_IMAGE,
- status: status,
- textPreview: '测试图片',
- originDeviceName: '测试电脑',
- ),
- ],
+ records: records ??
+ [
+ ClipRecord(
+ id: 'image',
+ kind: ClipKind.CLIP_KIND_IMAGE,
+ status: status,
+ textPreview: '测试图片',
+ originDeviceName: '测试电脑',
+ imageCount: 1,
+ ),
+ ],
);
}
String path;
+ // 多张图片时每张的文件名;为空表示剪贴板里的单张图片
+ List<String> names = const [];
int previewCalls = 0;
int fetchCalls = 0;
int clipboardCalls = 0;
@@ -33,10 +38,14 @@ class PreviewState extends AppState {
bool failFetch = false;
@override
- Future<String> imagePreviewPath(String clipId) async {
+ Future<GetImagePreviewResponse> imagePreview(String clipId, {int index = 0}) async {
previewCalls++;
if (failPreview) throw StateError('图片已不在本机,可能已被清理');
- return path;
+ return GetImagePreviewResponse(
+ path: path,
+ count: names.isEmpty ? 1 : names.length,
+ name: names.isEmpty ? '' : names[index],
+ );
}
@override
@@ -56,14 +65,10 @@ class PreviewState extends AppState {
);
}
-Future<void> openPreview(
- WidgetTester tester,
- PreviewState state, {
- bool button = false,
-}) async {
+Future<void> openPreview(WidgetTester tester, PreviewState state) async {
await tester.pumpWidget(CopySyncApp(state: state));
await tester.pump();
- await tester.tap(button ? find.text('预览') : find.textContaining('来自 测试电脑'));
+ await tester.tap(find.textContaining('来自 测试电脑'));
await tester.pump(const Duration(milliseconds: 250));
expect(find.byType(ImagePreviewDialog), findsOneWidget);
}
@@ -112,13 +117,38 @@ void main() {
expect(tester.takeException(), isNull);
});
- testWidgets('预览按钮同样打开图片', (tester) async {
+ testWidgets('复制的几张图片文件点开后可以左右翻看', (tester) async {
final state = PreviewState(
File('test/fixtures/image-preview.png').absolute.path,
- );
+ records: [
+ ClipRecord(
+ id: 'photos',
+ kind: ClipKind.CLIP_KIND_FILE,
+ status: ClipStatus.CLIP_STATUS_READY,
+ originDeviceName: '测试电脑',
+ items: [ClipItem(name: 'a.heic'), ClipItem(name: 'b.jpg')],
+ imageCount: 2,
+ ),
+ ],
+ )..names = ['a.heic', 'b.jpg'];
addTearDown(state.dispose);
- await openPreview(tester, state, button: true);
+ await openPreview(tester, state);
await decodedImage(tester);
+ expect(find.text('a.heic'), findsWidgets);
+ expect(find.text('1 / 2'), findsOneWidget);
+
+ await tester.tap(find.byTooltip('下一张'));
+ await tester.pump();
+ await decodedImage(tester);
+ expect(find.text('2 / 2'), findsOneWidget);
+ expect(find.text('b.jpg'), findsOneWidget);
+
+ // 方向键也能翻,翻过最后一张回到第一张
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
+ await tester.pump();
+ await decodedImage(tester);
+ expect(find.text('1 / 2'), findsOneWidget);
+ expect(state.previewCalls, 3);
expect(state.clipboardCalls, 0);
});
@@ -227,26 +257,46 @@ void main() {
expect(image.fit, BoxFit.scaleDown);
});
- testWidgets('鼠标移到记录上时,「预览」按钮不挪位置', (tester) async {
- tester.view.physicalSize = const Size(1000, 700);
- tester.view.devicePixelRatio = 1;
- addTearDown(tester.view.reset);
+ testWidgets('列表里不放「预览」按钮,点记录本身预览;没有图片的记录点了不打开', (tester) async {
final state = PreviewState(
File('test/fixtures/image-preview.png').absolute.path,
+ records: [
+ ClipRecord(
+ id: 'image',
+ kind: ClipKind.CLIP_KIND_IMAGE,
+ status: ClipStatus.CLIP_STATUS_READY,
+ originDeviceName: '测试电脑',
+ imageCount: 1,
+ ),
+ ClipRecord(
+ id: 'notes',
+ kind: ClipKind.CLIP_KIND_FILE,
+ status: ClipStatus.CLIP_STATUS_READY,
+ originDeviceName: '另一台',
+ items: [ClipItem(name: 'notes.txt')],
+ ),
+ ],
);
addTearDown(state.dispose);
await tester.pumpWidget(CopySyncApp(state: state));
await tester.pump();
- final before = tester.getCenter(find.text('预览'));
- expect(find.text('放入剪贴板').hitTestable(), findsNothing);
+ expect(find.text('预览'), findsNothing);
+ // 悬停时才出现「放入剪贴板」
+ 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.textContaining('来自 测试电脑')));
await tester.pump();
-
expect(find.text('放入剪贴板').hitTestable(), findsOneWidget);
- expect(tester.getCenter(find.text('预览')), before);
+
+ await tester.tap(find.text('notes.txt'));
+ await tester.pump(const Duration(milliseconds: 250));
+ expect(find.byType(ImagePreviewDialog), findsNothing);
+
+ await tester.tap(find.textContaining('来自 测试电脑'));
+ await tester.pump(const Duration(milliseconds: 250));
+ expect(find.byType(ImagePreviewDialog), findsOneWidget);
});
}
diff --git a/ui/tool/l10n/strings.py b/ui/tool/l10n/strings.py
index 9dfec05..ef95e04 100644
--- a/ui/tool/l10n/strings.py
+++ b/ui/tool/l10n/strings.py
@@ -85,7 +85,6 @@ S = [
("fetchStarted", "Pulling…", "开始拉取", "取り込みを開始しました"),
("transferFailed", "Transfer failed", "传输失败", "転送に失敗しました"),
("expired", "Expired", "已过期", "期限切れ"),
- ("preview", "Preview", "预览", "プレビュー"),
("putOnClipboard", "Copy to clipboard", "放入剪贴板", "クリップボードに入れる"),
("putOnClipboardDone", "On the clipboard", "已放入剪贴板", "クリップボードに入れました"),
("deleteRecord", "Delete this item", "删除这条记录", "この履歴を削除"),
@@ -97,6 +96,8 @@ S = [
# ── 图片预览 ──
("imagePreviewTitle", "Image preview", "图片预览", "画像プレビュー"),
("closePreview", "Close preview", "关闭预览", "プレビューを閉じる"),
+ ("previousImage", "Previous image", "上一张", "前の画像"),
+ ("nextImage", "Next image", "下一张", "次の画像"),
("previewHint", "Scroll or pinch to zoom, drag to move around", "滚轮或触控板缩放,拖动查看", "ホイールやトラックパッドで拡大縮小、ドラッグで移動"),
("fitWindow", "Fit to window", "适应窗口", "ウィンドウに合わせる"),
("previewDeleted", "This image has been deleted from the history", "这条图片记录已被删除", "この画像は履歴から削除されました"),