mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-09-24 04:53:31 +08:00
新增图片操作分类,支持调整大小、旋转、添加水印、裁剪、格式转换、图片信息、png2ico
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
filled
|
||||
:label="label"
|
||||
:placeholder="placeholder"
|
||||
:max="max"
|
||||
:min="min"
|
||||
class="number-input"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
@@ -20,7 +22,7 @@
|
||||
icon="keyboard_arrow_up"
|
||||
size="xs"
|
||||
class="number-btn"
|
||||
@click="updateNumber(100)"
|
||||
@click="updateNumber(step)"
|
||||
/>
|
||||
<q-btn
|
||||
flat
|
||||
@@ -28,7 +30,7 @@
|
||||
icon="keyboard_arrow_down"
|
||||
size="xs"
|
||||
class="number-btn"
|
||||
@click="updateNumber(-100)"
|
||||
@click="updateNumber(-step)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -64,6 +66,18 @@ export default defineComponent({
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
max: {
|
||||
type: Number,
|
||||
default: 1000000000,
|
||||
},
|
||||
min: {
|
||||
type: Number,
|
||||
default: -1000000000,
|
||||
},
|
||||
step: {
|
||||
type: Number,
|
||||
default: 1,
|
||||
},
|
||||
},
|
||||
emits: ["update:modelValue"],
|
||||
computed: {
|
||||
@@ -75,14 +89,28 @@ export default defineComponent({
|
||||
if (value === null || value === undefined || value === "") {
|
||||
this.$emit("update:modelValue", null);
|
||||
} else {
|
||||
this.$emit("update:modelValue", value);
|
||||
const numValue = Number(value);
|
||||
if (numValue > this.max) {
|
||||
this.$emit("update:modelValue", this.max);
|
||||
} else if (numValue < this.min) {
|
||||
this.$emit("update:modelValue", this.min);
|
||||
} else {
|
||||
this.$emit("update:modelValue", numValue);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
updateNumber(delta) {
|
||||
this.$emit("update:modelValue", (this.localValue || 0) + delta);
|
||||
const newValue = (this.localValue || 0) + delta;
|
||||
if (newValue > this.max) {
|
||||
this.$emit("update:modelValue", this.max);
|
||||
} else if (newValue < this.min) {
|
||||
this.$emit("update:modelValue", this.min);
|
||||
} else {
|
||||
this.$emit("update:modelValue", newValue);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
@@ -63,6 +63,8 @@ export const dataCommands = {
|
||||
key: "start",
|
||||
label: "起始位置",
|
||||
type: "numInput",
|
||||
min: 0,
|
||||
step: 1,
|
||||
icon: "first_page",
|
||||
width: 3,
|
||||
},
|
||||
@@ -71,6 +73,8 @@ export const dataCommands = {
|
||||
label: "结束位置",
|
||||
type: "numInput",
|
||||
icon: "last_page",
|
||||
min: 0,
|
||||
step: 1,
|
||||
width: 3,
|
||||
},
|
||||
],
|
||||
@@ -155,6 +159,7 @@ export const dataCommands = {
|
||||
{
|
||||
label: "起始位置",
|
||||
type: "numInput",
|
||||
step: 1,
|
||||
icon: "first_page",
|
||||
width: 4,
|
||||
},
|
||||
@@ -162,6 +167,7 @@ export const dataCommands = {
|
||||
label: "结束位置",
|
||||
type: "numInput",
|
||||
icon: "last_page",
|
||||
step: 1,
|
||||
width: 4,
|
||||
},
|
||||
],
|
||||
|
572
src/js/composer/commands/imageCommands.js
Normal file
572
src/js/composer/commands/imageCommands.js
Normal file
@@ -0,0 +1,572 @@
|
||||
import { newVarInputVal } from "js/composer/varInputValManager";
|
||||
|
||||
// 图片格式选项
|
||||
const IMAGE_FORMATS = [
|
||||
{ label: "JPEG", value: "jpeg" },
|
||||
{ label: "PNG", value: "png" },
|
||||
{ label: "WebP", value: "webp" },
|
||||
];
|
||||
|
||||
// 水印位置选项
|
||||
const WATERMARK_POSITIONS = [
|
||||
{ label: "左上角", value: "topLeft" },
|
||||
{ label: "右上角", value: "topRight" },
|
||||
{ label: "左下角", value: "bottomLeft" },
|
||||
{ label: "右下角", value: "bottomRight" },
|
||||
{ label: "居中", value: "center" },
|
||||
];
|
||||
|
||||
export const imageCommands = {
|
||||
label: "图片操作",
|
||||
icon: "image",
|
||||
defaultOpened: false,
|
||||
commands: [
|
||||
{
|
||||
value: "quickcomposer.image.analyze",
|
||||
label: "图片信息",
|
||||
desc: "分析图片基本信息",
|
||||
icon: "analytics",
|
||||
isAsync: true,
|
||||
config: [
|
||||
{
|
||||
key: "file",
|
||||
label: "图片文件",
|
||||
type: "varInput",
|
||||
icon: "image",
|
||||
width: 12,
|
||||
options: {
|
||||
dialog: {
|
||||
type: "open",
|
||||
options: {
|
||||
title: "选择图片",
|
||||
filters: [
|
||||
{
|
||||
name: "图片文件",
|
||||
extensions: ["jpg", "jpeg", "png", "webp"],
|
||||
},
|
||||
],
|
||||
properties: ["openFile", "showHiddenFiles"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: "quickcomposer.image.resize",
|
||||
label: "调整大小",
|
||||
desc: "调整图片尺寸",
|
||||
icon: "aspect_ratio",
|
||||
isAsync: true,
|
||||
config: [
|
||||
{
|
||||
key: "inputFile",
|
||||
label: "输入文件",
|
||||
type: "varInput",
|
||||
icon: "image",
|
||||
width: 12,
|
||||
options: {
|
||||
dialog: {
|
||||
type: "open",
|
||||
options: {
|
||||
title: "选择图片",
|
||||
filters: [
|
||||
{
|
||||
name: "图片文件",
|
||||
extensions: ["jpg", "jpeg", "png", "webp"],
|
||||
},
|
||||
],
|
||||
properties: ["openFile", "showHiddenFiles"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "outputFile",
|
||||
label: "输出文件",
|
||||
type: "varInput",
|
||||
icon: "save",
|
||||
width: 12,
|
||||
options: {
|
||||
dialog: {
|
||||
type: "save",
|
||||
options: {
|
||||
title: "保存图片",
|
||||
filters: [
|
||||
{
|
||||
name: "图片文件",
|
||||
extensions: ["jpg", "jpeg", "png", "webp"],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "width",
|
||||
label: "宽度(像素)",
|
||||
type: "numInput",
|
||||
icon: "compare_arrows",
|
||||
width: 6,
|
||||
min: 1,
|
||||
step: 10,
|
||||
defaultValue: "",
|
||||
},
|
||||
{
|
||||
key: "height",
|
||||
label: "高度(像素)",
|
||||
type: "numInput",
|
||||
icon: "height",
|
||||
width: 6,
|
||||
min: 1,
|
||||
step: 10,
|
||||
defaultValue: "",
|
||||
},
|
||||
{
|
||||
key: "keepAspectRatio",
|
||||
label: "保持宽高比",
|
||||
type: "select",
|
||||
icon: "aspect_ratio",
|
||||
width: 6,
|
||||
defaultValue: "true",
|
||||
options: [
|
||||
{ label: "是", value: "true" },
|
||||
{ label: "否", value: "false" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "quality",
|
||||
label: "图片质量(0-1)",
|
||||
type: "numInput",
|
||||
icon: "high_quality",
|
||||
width: 6,
|
||||
max: 1,
|
||||
min: 0,
|
||||
step: 0.05,
|
||||
defaultValue: 0.92,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: "quickcomposer.image.rotate",
|
||||
label: "旋转图片",
|
||||
desc: "旋转图片角度",
|
||||
icon: "rotate_right",
|
||||
isAsync: true,
|
||||
config: [
|
||||
{
|
||||
key: "inputFile",
|
||||
label: "输入文件",
|
||||
type: "varInput",
|
||||
icon: "image",
|
||||
width: 12,
|
||||
options: {
|
||||
dialog: {
|
||||
type: "open",
|
||||
options: {
|
||||
title: "选择图片",
|
||||
filters: [
|
||||
{
|
||||
name: "图片文件",
|
||||
extensions: ["jpg", "jpeg", "png", "webp"],
|
||||
},
|
||||
],
|
||||
properties: ["openFile", "showHiddenFiles"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "outputFile",
|
||||
label: "输出文件",
|
||||
type: "varInput",
|
||||
icon: "save",
|
||||
width: 12,
|
||||
options: {
|
||||
dialog: {
|
||||
type: "save",
|
||||
options: {
|
||||
title: "保存图片",
|
||||
filters: [
|
||||
{
|
||||
name: "图片文件",
|
||||
extensions: ["jpg", "jpeg", "png", "webp"],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "angle",
|
||||
label: "旋转角度",
|
||||
type: "numInput",
|
||||
icon: "rotate_right",
|
||||
width: 6,
|
||||
step: 90,
|
||||
defaultValue: 90,
|
||||
},
|
||||
{
|
||||
key: "quality",
|
||||
label: "图片质量(0-1)",
|
||||
type: "numInput",
|
||||
icon: "high_quality",
|
||||
width: 6,
|
||||
max: 1,
|
||||
min: 0,
|
||||
step: 0.05,
|
||||
defaultValue: 0.92,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: "quickcomposer.image.crop",
|
||||
label: "裁剪图片",
|
||||
desc: "裁剪图片区域",
|
||||
icon: "crop",
|
||||
isAsync: true,
|
||||
config: [
|
||||
{
|
||||
key: "inputFile",
|
||||
label: "输入文件",
|
||||
type: "varInput",
|
||||
icon: "image",
|
||||
width: 12,
|
||||
options: {
|
||||
dialog: {
|
||||
type: "open",
|
||||
options: {
|
||||
title: "选择图片",
|
||||
filters: [
|
||||
{
|
||||
name: "图片文件",
|
||||
extensions: ["jpg", "jpeg", "png", "webp"],
|
||||
},
|
||||
],
|
||||
properties: ["openFile", "showHiddenFiles"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "outputFile",
|
||||
label: "输出文件",
|
||||
type: "varInput",
|
||||
icon: "save",
|
||||
width: 12,
|
||||
options: {
|
||||
dialog: {
|
||||
type: "save",
|
||||
options: {
|
||||
title: "保存图片",
|
||||
filters: [
|
||||
{
|
||||
name: "图片文件",
|
||||
extensions: ["jpg", "jpeg", "png", "webp"],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "x",
|
||||
label: "起始X坐标",
|
||||
type: "numInput",
|
||||
icon: "arrow_right",
|
||||
width: 6,
|
||||
min: 0,
|
||||
step: 10,
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
key: "y",
|
||||
label: "起始Y坐标",
|
||||
type: "numInput",
|
||||
icon: "arrow_downward",
|
||||
width: 6,
|
||||
min: 0,
|
||||
step: 10,
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
key: "width",
|
||||
label: "裁剪宽度",
|
||||
type: "numInput",
|
||||
icon: "compare_arrows",
|
||||
width: 6,
|
||||
min: 1,
|
||||
step: 10,
|
||||
defaultValue: "",
|
||||
},
|
||||
{
|
||||
key: "height",
|
||||
label: "裁剪高度",
|
||||
type: "numInput",
|
||||
icon: "height",
|
||||
width: 6,
|
||||
min: 1,
|
||||
step: 10,
|
||||
defaultValue: "",
|
||||
},
|
||||
{
|
||||
key: "quality",
|
||||
label: "图片质量(0-1)",
|
||||
type: "numInput",
|
||||
icon: "high_quality",
|
||||
width: 6,
|
||||
max: 1,
|
||||
min: 0,
|
||||
step: 0.05,
|
||||
defaultValue: 0.92,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: "quickcomposer.image.watermark",
|
||||
label: "添加水印",
|
||||
desc: "添加文字水印",
|
||||
icon: "format_color_text",
|
||||
isAsync: true,
|
||||
config: [
|
||||
{
|
||||
key: "inputFile",
|
||||
label: "输入文件",
|
||||
type: "varInput",
|
||||
icon: "image",
|
||||
width: 12,
|
||||
options: {
|
||||
dialog: {
|
||||
type: "open",
|
||||
options: {
|
||||
title: "选择图片",
|
||||
filters: [
|
||||
{
|
||||
name: "图片文件",
|
||||
extensions: ["jpg", "jpeg", "png", "webp"],
|
||||
},
|
||||
],
|
||||
properties: ["openFile", "showHiddenFiles"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "outputFile",
|
||||
label: "输出文件",
|
||||
type: "varInput",
|
||||
icon: "save",
|
||||
width: 12,
|
||||
options: {
|
||||
dialog: {
|
||||
type: "save",
|
||||
options: {
|
||||
title: "保存图片",
|
||||
filters: [
|
||||
{
|
||||
name: "图片文件",
|
||||
extensions: ["jpg", "jpeg", "png", "webp"],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "text",
|
||||
label: "水印文字",
|
||||
type: "varInput",
|
||||
icon: "text_fields",
|
||||
width: 12,
|
||||
defaultValue: newVarInputVal("var", "水印文字"),
|
||||
},
|
||||
{
|
||||
key: "font",
|
||||
label: "字体设置",
|
||||
type: "varInput",
|
||||
icon: "font_download",
|
||||
width: 6,
|
||||
defaultValue: newVarInputVal("var", "24px Arial"),
|
||||
},
|
||||
{
|
||||
key: "color",
|
||||
label: "文字颜色",
|
||||
type: "varInput",
|
||||
icon: "format_color_text",
|
||||
width: 6,
|
||||
defaultValue: newVarInputVal("var", "rgba(255, 255, 255, 0.5)"),
|
||||
},
|
||||
{
|
||||
key: "position",
|
||||
label: "位置",
|
||||
type: "select",
|
||||
icon: "place",
|
||||
width: 6,
|
||||
defaultValue: "bottomRight",
|
||||
options: WATERMARK_POSITIONS,
|
||||
},
|
||||
{
|
||||
key: "margin",
|
||||
label: "边距",
|
||||
type: "numInput",
|
||||
icon: "space_bar",
|
||||
min: 0,
|
||||
step: 10,
|
||||
width: 6,
|
||||
defaultValue: 20,
|
||||
},
|
||||
{
|
||||
key: "opacity",
|
||||
label: "不透明度(0-1)",
|
||||
type: "numInput",
|
||||
icon: "opacity",
|
||||
max: 1,
|
||||
min: 0,
|
||||
step: 0.05,
|
||||
width: 6,
|
||||
defaultValue: 0.5,
|
||||
},
|
||||
{
|
||||
key: "quality",
|
||||
label: "图片质量(0-1)",
|
||||
type: "numInput",
|
||||
icon: "high_quality",
|
||||
max: 1,
|
||||
min: 0,
|
||||
step: 0.05,
|
||||
width: 6,
|
||||
defaultValue: 0.92,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: "quickcomposer.image.convert",
|
||||
label: "格式转换",
|
||||
desc: "转换图片格式",
|
||||
icon: "transform",
|
||||
isAsync: true,
|
||||
config: [
|
||||
{
|
||||
key: "inputFile",
|
||||
label: "输入文件",
|
||||
type: "varInput",
|
||||
icon: "image",
|
||||
width: 12,
|
||||
options: {
|
||||
dialog: {
|
||||
type: "open",
|
||||
options: {
|
||||
title: "选择图片",
|
||||
filters: [
|
||||
{
|
||||
name: "图片文件",
|
||||
extensions: ["jpg", "jpeg", "png", "webp"],
|
||||
},
|
||||
],
|
||||
properties: ["openFile", "showHiddenFiles"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "outputFile",
|
||||
label: "输出文件",
|
||||
type: "varInput",
|
||||
icon: "save",
|
||||
width: 12,
|
||||
options: {
|
||||
dialog: {
|
||||
type: "save",
|
||||
options: {
|
||||
title: "保存图片",
|
||||
filters: [
|
||||
{
|
||||
name: "图片文件",
|
||||
extensions: ["jpg", "jpeg", "png", "webp"],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "format",
|
||||
label: "输出格式",
|
||||
type: "select",
|
||||
icon: "transform",
|
||||
width: 6,
|
||||
defaultValue: "jpeg",
|
||||
options: IMAGE_FORMATS,
|
||||
},
|
||||
{
|
||||
key: "quality",
|
||||
label: "图片质量(0-1)",
|
||||
type: "numInput",
|
||||
icon: "high_quality",
|
||||
width: 6,
|
||||
max: 1,
|
||||
min: 0,
|
||||
step: 0.05,
|
||||
defaultValue: 0.92,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: "quickcomposer.image.pngToIcon",
|
||||
label: "PNG转图标",
|
||||
desc: "将PNG图片转换为图标",
|
||||
icon: "transform",
|
||||
config: [
|
||||
{
|
||||
key: "inputFile",
|
||||
label: "PNG路径/Base64",
|
||||
type: "varInput",
|
||||
icon: "image",
|
||||
width: 12,
|
||||
options: {
|
||||
dialog: {
|
||||
type: "open",
|
||||
options: {
|
||||
title: "选择图片",
|
||||
filters: [
|
||||
{
|
||||
name: "图片文件",
|
||||
extensions: ["png"],
|
||||
},
|
||||
],
|
||||
properties: ["openFile", "multiSelections"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "outputDir",
|
||||
label: "输出目录",
|
||||
type: "varInput",
|
||||
icon: "save",
|
||||
width: 9,
|
||||
defaultValue: newVarInputVal("str", window.utools.getPath("desktop")),
|
||||
options: {
|
||||
dialog: {
|
||||
type: "save",
|
||||
options: {
|
||||
title: "选择输出目录",
|
||||
defaultPath: ".",
|
||||
properties: ["openDirectory"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "type",
|
||||
label: "输出格式",
|
||||
type: "select",
|
||||
icon: "transform",
|
||||
width: 3,
|
||||
defaultValue: "ico",
|
||||
options: ["ico", "icns"],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
@@ -13,13 +13,14 @@ import { userdataCommands } from "./userdataCommands";
|
||||
import { utoolsCommands } from "./utoolsCommand";
|
||||
import { screenCommands } from "./screenCommands";
|
||||
import { audioCommands } from "./audioCommands";
|
||||
console.log(audioCommands);
|
||||
import { imageCommands } from "./imageCommands";
|
||||
|
||||
export const commandCategories = [
|
||||
fileCommands,
|
||||
networkCommands,
|
||||
systemCommands,
|
||||
audioCommands,
|
||||
imageCommands,
|
||||
notifyCommands,
|
||||
utoolsCommands,
|
||||
dataCommands,
|
||||
|
@@ -11,6 +11,8 @@ export const otherCommands = {
|
||||
key: "ms",
|
||||
label: "延迟的毫秒数",
|
||||
type: "numInput",
|
||||
min: 0,
|
||||
step: 100,
|
||||
icon: "schedule",
|
||||
defaultValue: 500,
|
||||
},
|
||||
|
@@ -121,12 +121,16 @@ export const simulateCommands = {
|
||||
label: "X坐标(留空则原地点击)",
|
||||
icon: "drag_handle",
|
||||
type: "numInput",
|
||||
min: 0,
|
||||
step: 10,
|
||||
width: 6,
|
||||
},
|
||||
{
|
||||
label: "Y坐标(留空则原地点击)",
|
||||
icon: "drag_handle",
|
||||
type: "numInput",
|
||||
min: 0,
|
||||
step: 10,
|
||||
width: 6,
|
||||
},
|
||||
],
|
||||
@@ -162,6 +166,8 @@ export const simulateCommands = {
|
||||
icon: "drag_handle",
|
||||
defaultValue: 0,
|
||||
type: "numInput",
|
||||
min: 0,
|
||||
step: 10,
|
||||
width: 6,
|
||||
},
|
||||
{
|
||||
@@ -169,6 +175,8 @@ export const simulateCommands = {
|
||||
icon: "drag_handle",
|
||||
defaultValue: 0,
|
||||
type: "numInput",
|
||||
min: 0,
|
||||
step: 10,
|
||||
width: 6,
|
||||
},
|
||||
],
|
||||
|
@@ -370,6 +370,8 @@ export const systemCommands = {
|
||||
{
|
||||
label: "进程ID",
|
||||
type: "numInput",
|
||||
min: 0,
|
||||
step: 100,
|
||||
icon: "developer_board",
|
||||
width: 7,
|
||||
},
|
||||
|
@@ -118,6 +118,8 @@ export const uiCommands = {
|
||||
{
|
||||
label: "显示时间(ms)",
|
||||
type: "numInput",
|
||||
min: 0,
|
||||
step: 100,
|
||||
width: 6,
|
||||
placeholder: "0为手动关闭,留空按文本长度调整",
|
||||
},
|
||||
@@ -152,6 +154,8 @@ export const uiCommands = {
|
||||
{
|
||||
label: "宽度",
|
||||
type: "numInput",
|
||||
min: 0,
|
||||
step: 100,
|
||||
defaultValue: 450,
|
||||
width: 3,
|
||||
placeholder: "对话框宽度",
|
||||
|
@@ -26,6 +26,8 @@ export const utoolsCommands = {
|
||||
key: "height",
|
||||
label: "高度",
|
||||
type: "numInput",
|
||||
min: 0,
|
||||
step: 100,
|
||||
icon: "straighten",
|
||||
width: 12,
|
||||
},
|
||||
|
Reference in New Issue
Block a user