Skip to content

Update plugin Imgbatch v0.1.6#173

Open
ReaderC wants to merge 2 commits into
ZToolsCenter:mainfrom
ReaderC:plugin/imgbatch
Open

Update plugin Imgbatch v0.1.6#173
ReaderC wants to merge 2 commits into
ZToolsCenter:mainfrom
ReaderC:plugin/imgbatch

Conversation

@ReaderC
Copy link
Copy Markdown
Contributor

@ReaderC ReaderC commented May 11, 2026

插件信息

  • 名称: Imgbatch
  • 插件ID: imgbatch
  • 版本: 0.1.6
  • 描述: 图片批量处理插件,支持压缩、格式转换、加水印、圆角、补边、裁剪、旋转、翻转,以及合并为 PDF、图片和 GIF。
  • 作者: readerc
  • 类型: 更新

本次变更

  • 将 Imgbatch 更新至 0.1.6
  • 调整官方插件仓库分发结构,改用 runtime-packages 携带运行时依赖,避免安装后缺少 sharp 导致本地图片处理不可用
  • 移除插件包内截图资源,减少分发体积,并避免无关图片文件进入官方插件仓库
  • 修正合并为 PDF 时缺少 fork 引入导致的执行失败问题
  • 修正“修改尺寸”中“对齐最大 / 对齐最小”在锁定比例开启时未真正统一输出尺寸的问题
  • 修正水印页点击锚点位置后工具面板回到顶部的问题
  • 优化旋转页常用角度管理,支持添加、删除、排序和恢复默认角度
  • 将图标改为本地 SVG 资源,避免首次打开时依赖外网图标源
  • 修正结果文件缺失时点击“查看结果”的回退处理

截图 / 演示

image

自检清单

  • plugin.json 的 name / title / version / description / author 字段均已检查
  • 已移除调试日志、未使用文件、敏感信息(.env、token、密钥等)
  • 本次 PR 的 diff 仅涉及 plugins/imgbatch/ 目录
  • 已在本地 ZTools 客户端实际加载并测试过此插件,主要功能正常
  • 同意以仓库声明的开源协议发布此插件

此 PR 由 ztools-plugin-cli 自动管理:每次 ztools publish 在分支上追加一个 commit,PR 链接保持不变。

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the plugin to version 0.1.6, introducing a local SVG icon system to replace external font dependencies and a new management dialog for rotation angle presets. It also improves user experience by preserving panel scroll positions during refreshes and fixes issues with resize alignment. Architecturally, it optimizes the publishing workflow with a dedicated CLI build script and a runtime-packages structure. The review feedback recommends centralizing the DEFAULT_ROTATE_PRESET_ANGLES constant to reduce duplication and unifying the normalizeRotatePresetAngles logic to ensure consistent and robust input validation across the application.

]
const SETTINGS_TOOL_ID = 'settings'
const PREVIEW_CACHE_LIMIT = 12
const DEFAULT_ROTATE_PRESET_ANGLES = [-135, -90, -45, 0, 45, 90, 135, 180]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

DEFAULT_ROTATE_PRESET_ANGLES 常量在 main.js (L62)、tool-pages.js (L63) 和 store.js (L19) 中被多次定义或硬编码。建议将其提取到统一的常量定义文件中(例如 assets/app/config/constants.js),以减少代码重复并确保默认值的一致性。

Comment on lines +72 to +83
function normalizeRotatePresetAngles(value) {
const source = Array.isArray(value) && value.length ? value : DEFAULT_ROTATE_PRESET_ANGLES
const seen = new Set()
const next = []
for (let index = 0; index < source.length; index += 1) {
const numeric = Math.max(-360, Math.min(360, Math.round(Number(source[index]) || 0)))
if (seen.has(numeric)) continue
seen.add(numeric)
next.push(numeric)
}
return next
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

此处的 normalizeRotatePresetAngles 函数实现与 main.js 中的版本不一致。当前实现使用 Number(...) || 0,这会将无效输入(如非数字字符串)静默转换为 0,可能导致预设列表中出现意外的 。建议统一使用 main.js 中更严谨的过滤逻辑(即跳过无效数值),并考虑将该函数提取为共享工具函数。

function normalizeRotatePresetAngles(value) {
  const source = Array.isArray(value) && value.length ? value : DEFAULT_ROTATE_PRESET_ANGLES
  const seen = new Set()
  const next = []
  for (let index = 0; index < source.length; index += 1) {
    const numeric = Number(source[index])
    if (!Number.isFinite(numeric)) continue
    const angle = Math.max(-360, Math.min(360, Math.round(numeric)))
    if (seen.has(angle)) continue
    seen.add(angle)
    next.push(angle)
  }
  return next
}

@ReaderC ReaderC marked this pull request as ready for review May 11, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant