cxk Claude Opus 4.6 commited on
Commit
e5900fc
·
1 Parent(s): 4cddefe

feat(image): refine import and preview flows

Browse files

Add a remote CPA import entry that routes users to settings and simplify image preview rendering to use native img elements consistently.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

web/src/app/accounts/components/account-import-dialog.tsx CHANGED
@@ -1,5 +1,6 @@
1
  "use client";
2
 
 
3
  import { useRef, useState, type ChangeEvent } from "react";
4
  import {
5
  ArrowLeft,
@@ -101,6 +102,7 @@ function MethodCard({
101
  }
102
 
103
  export function AccountImportDialog({ disabled, onImported }: AccountImportDialogProps) {
 
104
  const [open, setOpen] = useState(false);
105
  const [method, setMethod] = useState<ImportMethod>("menu");
106
  const [tokenInput, setTokenInput] = useState("");
@@ -420,6 +422,16 @@ export function AccountImportDialog({ disabled, onImported }: AccountImportDialo
420
  icon={Files}
421
  onClick={() => setMethod("cpa")}
422
  />
 
 
 
 
 
 
 
 
 
 
423
  </div>
424
  );
425
  };
 
1
  "use client";
2
 
3
+ import { useRouter } from "next/navigation";
4
  import { useRef, useState, type ChangeEvent } from "react";
5
  import {
6
  ArrowLeft,
 
102
  }
103
 
104
  export function AccountImportDialog({ disabled, onImported }: AccountImportDialogProps) {
105
+ const router = useRouter();
106
  const [open, setOpen] = useState(false);
107
  const [method, setMethod] = useState<ImportMethod>("menu");
108
  const [tokenInput, setTokenInput] = useState("");
 
422
  icon={Files}
423
  onClick={() => setMethod("cpa")}
424
  />
425
+ <MethodCard
426
+ title="从远程 CPA 服务器导入"
427
+ description="前往设置页面配置远程 CPA 服务器后再执行导入。"
428
+ icon={Files}
429
+ onClick={() => {
430
+ setOpen(false);
431
+ resetState();
432
+ router.push("/settings");
433
+ }}
434
+ />
435
  </div>
436
  );
437
  };
web/src/app/image/components/image-composer.tsx CHANGED
@@ -1,6 +1,4 @@
1
  "use client";
2
-
3
- import Image from "next/image";
4
  import { ArrowUp, ImagePlus, LoaderCircle, X } from "lucide-react";
5
  import type { RefObject } from "react";
6
 
@@ -80,13 +78,10 @@ export function ImageComposer({
80
 
81
  {mode === "edit" && referenceImagePreview ? (
82
  <div className="mb-3 flex items-center gap-3 rounded-[28px] border border-stone-200/80 bg-white px-4 py-4 shadow-[0_18px_48px_rgba(28,25,23,0.08)]">
83
- <Image
84
  src={referenceImagePreview}
85
  alt={referenceImageName || "参考图预览"}
86
- width={56}
87
- height={56}
88
- unoptimized
89
- className="rounded-xl object-cover"
90
  />
91
  <div className="min-w-0 flex-1">
92
  <div className="truncate text-sm font-medium text-stone-800">{referenceImageName}</div>
 
1
  "use client";
 
 
2
  import { ArrowUp, ImagePlus, LoaderCircle, X } from "lucide-react";
3
  import type { RefObject } from "react";
4
 
 
78
 
79
  {mode === "edit" && referenceImagePreview ? (
80
  <div className="mb-3 flex items-center gap-3 rounded-[28px] border border-stone-200/80 bg-white px-4 py-4 shadow-[0_18px_48px_rgba(28,25,23,0.08)]">
81
+ <img
82
  src={referenceImagePreview}
83
  alt={referenceImageName || "参考图预览"}
84
+ className="h-14 w-14 rounded-xl object-cover"
 
 
 
85
  />
86
  <div className="min-w-0 flex-1">
87
  <div className="truncate text-sm font-medium text-stone-800">{referenceImageName}</div>
web/src/app/image/components/image-results.tsx CHANGED
@@ -1,6 +1,4 @@
1
  "use client";
2
-
3
- import Image from "next/image";
4
  import { LoaderCircle } from "lucide-react";
5
 
6
  import type { ImageConversation, StoredImage } from "@/store/image-conversations";
@@ -49,12 +47,9 @@ export function ImageResults({
49
  <div className="flex w-full max-w-[80%] flex-col items-end gap-3 px-1 pt-1">
50
  {selectedConversation.referenceImage ? (
51
  <div className="w-full max-w-[240px] overflow-hidden rounded-[20px] border border-stone-200 bg-white shadow-sm">
52
- <Image
53
  src={selectedConversation.referenceImage.dataUrl}
54
  alt="参考图"
55
- width={480}
56
- height={480}
57
- unoptimized
58
  className="block h-auto w-full"
59
  />
60
  </div>
@@ -116,12 +111,9 @@ function ImageResultCard({
116
  if (image.status === "success" && image.b64_json) {
117
  return (
118
  <button type="button" onClick={() => onOpen(image.id)} className="group block w-full cursor-zoom-in">
119
- <Image
120
  src={`data:image/png;base64,${image.b64_json}`}
121
  alt={`Generated result ${index + 1}`}
122
- width={1024}
123
- height={1024}
124
- unoptimized
125
  className="block h-auto w-full transition duration-200 group-hover:brightness-90"
126
  />
127
  </button>
 
1
  "use client";
 
 
2
  import { LoaderCircle } from "lucide-react";
3
 
4
  import type { ImageConversation, StoredImage } from "@/store/image-conversations";
 
47
  <div className="flex w-full max-w-[80%] flex-col items-end gap-3 px-1 pt-1">
48
  {selectedConversation.referenceImage ? (
49
  <div className="w-full max-w-[240px] overflow-hidden rounded-[20px] border border-stone-200 bg-white shadow-sm">
50
+ <img
51
  src={selectedConversation.referenceImage.dataUrl}
52
  alt="参考图"
 
 
 
53
  className="block h-auto w-full"
54
  />
55
  </div>
 
111
  if (image.status === "success" && image.b64_json) {
112
  return (
113
  <button type="button" onClick={() => onOpen(image.id)} className="group block w-full cursor-zoom-in">
114
+ <img
115
  src={`data:image/png;base64,${image.b64_json}`}
116
  alt={`Generated result ${index + 1}`}
 
 
 
117
  className="block h-auto w-full transition duration-200 group-hover:brightness-90"
118
  />
119
  </button>
web/src/components/image-lightbox.tsx CHANGED
@@ -1,7 +1,6 @@
1
  "use client";
2
 
3
  import { useCallback, useEffect } from "react";
4
- import Image from "next/image";
5
  import * as DialogPrimitive from "@radix-ui/react-dialog";
6
  import { ChevronLeft, ChevronRight, Download, X } from "lucide-react";
7
 
@@ -116,14 +115,10 @@ export function ImageLightbox({
116
  className="flex max-h-[90vh] max-w-[90vw] items-center justify-center"
117
  onClick={() => onOpenChange(false)}
118
  >
119
- <Image
120
  src={current.src}
121
  alt=""
122
- width={1536}
123
- height={1536}
124
- unoptimized
125
  className="max-h-[90vh] max-w-[90vw] rounded-lg object-contain"
126
- style={{ width: "auto", height: "auto" }}
127
  onClick={(e) => e.stopPropagation()}
128
  draggable={false}
129
  />
 
1
  "use client";
2
 
3
  import { useCallback, useEffect } from "react";
 
4
  import * as DialogPrimitive from "@radix-ui/react-dialog";
5
  import { ChevronLeft, ChevronRight, Download, X } from "lucide-react";
6
 
 
115
  className="flex max-h-[90vh] max-w-[90vw] items-center justify-center"
116
  onClick={() => onOpenChange(false)}
117
  >
118
+ <img
119
  src={current.src}
120
  alt=""
 
 
 
121
  className="max-h-[90vh] max-w-[90vw] rounded-lg object-contain"
 
122
  onClick={(e) => e.stopPropagation()}
123
  draggable={false}
124
  />