mirror of
https://github.com/usememos/memos.git
synced 2025-12-18 14:50:13 +08:00
Fix lint errors and implement feedback
This commit is contained in:
parent
0ede2e8410
commit
2dbaddc6a5
2 changed files with 21 additions and 12 deletions
|
|
@ -6,8 +6,6 @@ import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
_ "image/jpeg"
|
|
||||||
_ "image/png"
|
|
||||||
"io"
|
"io"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -549,7 +547,9 @@ func downscaleImage(imageBlob []byte, maxDimension int, quality int) ([]byte, er
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset reader position for actual decoding
|
// Reset reader position for actual decoding
|
||||||
reader.Seek(0, 0)
|
if _, err := reader.Seek(0, 0); err != nil {
|
||||||
|
return nil, errors.Wrap(err, "failed to reset reader position")
|
||||||
|
}
|
||||||
|
|
||||||
// Decode the image with auto-orientation support
|
// Decode the image with auto-orientation support
|
||||||
img, err := imaging.Decode(reader, imaging.AutoOrientation(true))
|
img, err := imaging.Decode(reader, imaging.AutoOrientation(true))
|
||||||
|
|
@ -574,9 +574,8 @@ func downscaleImage(imageBlob []byte, maxDimension int, quality int) ([]byte, er
|
||||||
targetHeight = maxDimension
|
targetHeight = maxDimension
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Keep original dimensions for small images
|
// Do not modify small images
|
||||||
targetWidth = width
|
return imageBlob, nil
|
||||||
targetHeight = height
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resize the image to the calculated dimensions
|
// Resize the image to the calculated dimensions
|
||||||
|
|
|
||||||
|
|
@ -43,13 +43,13 @@ const StorageSection = observer(() => {
|
||||||
if (workspaceStorageSetting.imageMaxSize < 0) {
|
if (workspaceStorageSetting.imageMaxSize < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (workspaceStorageSetting.jpegQuality <= 0 || workspaceStorageSetting.jpegQuality > 100) {
|
if (workspaceStorageSetting.jpegQuality < 1 || workspaceStorageSetting.jpegQuality > 100) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (workspaceStorageSetting.thumbnailMaxSize <= 0) {
|
if (workspaceStorageSetting.thumbnailMaxSize <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (workspaceStorageSetting.thumbnailJpegQuality <= 0 || workspaceStorageSetting.thumbnailJpegQuality > 100) {
|
if (workspaceStorageSetting.thumbnailJpegQuality < 1 || workspaceStorageSetting.thumbnailJpegQuality > 100) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -301,7 +301,7 @@ const StorageSection = observer(() => {
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="w-full flex flex-row justify-between items-center">
|
<div className="w-full flex flex-row justify-between items-center">
|
||||||
<div className="flex flex-row items-center">
|
<div className="flex flex-row items-center">
|
||||||
<span className="text-muted-foreground mr-1">Maximum image size (px)</span>
|
<span className="text-muted-foreground mr-1">Maximum image size (px)</span>
|
||||||
|
|
@ -311,7 +311,10 @@ const StorageSection = observer(() => {
|
||||||
<HelpCircleIcon className="w-4 h-auto" />
|
<HelpCircleIcon className="w-4 h-auto" />
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent>
|
<TooltipContent>
|
||||||
<p>Maximum size in pixels for the largest dimension when storing images. Images larger than this will be downscaled. Set to 0 to disable downscaling (default: 0, no downscaling).</p>
|
<p>
|
||||||
|
Maximum size in pixels for the largest dimension when storing images. Images larger than this will be downscaled. Set to 0
|
||||||
|
to disable downscaling (default: 0, no downscaling).
|
||||||
|
</p>
|
||||||
</TooltipContent>
|
</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</TooltipProvider>
|
</TooltipProvider>
|
||||||
|
|
@ -327,7 +330,10 @@ const StorageSection = observer(() => {
|
||||||
<HelpCircleIcon className="w-4 h-auto" />
|
<HelpCircleIcon className="w-4 h-auto" />
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent>
|
<TooltipContent>
|
||||||
<p>JPEG quality (0-100) used when downscaling uploaded images. Higher values = better quality but larger file size (default: 85).</p>
|
<p>
|
||||||
|
JPEG quality (0-100) used when downscaling uploaded images. Higher values = better quality but larger file size (default:
|
||||||
|
85).
|
||||||
|
</p>
|
||||||
</TooltipContent>
|
</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</TooltipProvider>
|
</TooltipProvider>
|
||||||
|
|
@ -364,7 +370,11 @@ const StorageSection = observer(() => {
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</TooltipProvider>
|
</TooltipProvider>
|
||||||
</div>
|
</div>
|
||||||
<Input className="w-20 font-mono" value={workspaceStorageSetting.thumbnailJpegQuality} onChange={handleThumbnailJpegQualityChanged} />
|
<Input
|
||||||
|
className="w-20 font-mono"
|
||||||
|
value={workspaceStorageSetting.thumbnailJpegQuality}
|
||||||
|
onChange={handleThumbnailJpegQualityChanged}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Button disabled={!allowSaveStorageSetting} onClick={saveWorkspaceStorageSetting}>
|
<Button disabled={!allowSaveStorageSetting} onClick={saveWorkspaceStorageSetting}>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue