From 2bbdfaaa0cb1107cbddc19557273e20279bc117c Mon Sep 17 00:00:00 2001 From: x007xyz <1026161550@qq.com> Date: Fri, 15 Nov 2024 08:48:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=9B=BE=E7=89=87):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E8=A3=81=E5=89=AA=E5=8A=9F=E8=83=BD=20(#543)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(图片): 添加图片裁剪功能 * fix: 图片裁剪兼容本地图片不存在src的情况 * chore: 裁剪细节调整 --- .eslintrc-auto-import.json | 2 +- .vscode/settings.json | 5 +- package.json | 1 + src/components/cropperDialog.vue | 290 +++++++++++++++++++++++++++++++ src/components/cropperImg.vue | 89 ++++++++++ src/language/zh.json | 3 +- src/views/home/index.vue | 10 ++ 7 files changed, 397 insertions(+), 3 deletions(-) create mode 100644 src/components/cropperDialog.vue create mode 100644 src/components/cropperImg.vue diff --git a/.eslintrc-auto-import.json b/.eslintrc-auto-import.json index a9f62599..80862845 100644 --- a/.eslintrc-auto-import.json +++ b/.eslintrc-auto-import.json @@ -71,4 +71,4 @@ "watchPostEffect": true, "watchSyncEffect": true } -} \ No newline at end of file +} diff --git a/.vscode/settings.json b/.vscode/settings.json index fb5f9ac5..0641a795 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,5 +11,8 @@ "src/language" ], "i18n-ally.sourceLanguage": "zh", - "i18n-ally.keystyle": "nested" // 需要Prettier的配置文件 + "i18n-ally.keystyle": "nested", + "[vue]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + } // 需要Prettier的配置文件 } \ No newline at end of file diff --git a/package.json b/package.json index d51c0b93..a12b5d35 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "view-ui-plus": "^1.3.7", "vite-svg-loader": "^5.1.0", "vue": "^3.2.25", + "vue-cropper": "^1.1.4", "vue-i18n": "9.0.0", "vue-masonry": "^0.16.0", "vue-router": "^4.0.16", diff --git a/src/components/cropperDialog.vue b/src/components/cropperDialog.vue new file mode 100644 index 00000000..826ae03d --- /dev/null +++ b/src/components/cropperDialog.vue @@ -0,0 +1,290 @@ + + + + + diff --git a/src/components/cropperImg.vue b/src/components/cropperImg.vue new file mode 100644 index 00000000..2aa5d802 --- /dev/null +++ b/src/components/cropperImg.vue @@ -0,0 +1,89 @@ + + + + diff --git a/src/language/zh.json b/src/language/zh.json index 628272d3..143fc750 100644 --- a/src/language/zh.json +++ b/src/language/zh.json @@ -91,6 +91,7 @@ }, "select_json": "选择JSON文件", "repleaceImg": "替换图片", + "cropperImg": "裁剪图片", "createClip": "添加裁切", "removeClip": "移除裁切", "polygonClip": "多边形", @@ -258,4 +259,4 @@ }, "mine": "我的", "batch": "批量" -} +} \ No newline at end of file diff --git a/src/views/home/index.vue b/src/views/home/index.vue index b53039c2..910b711c 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -125,6 +125,8 @@ + + @@ -210,6 +212,7 @@ import material from '@/components/material.vue'; import bgBar from '@/components/bgBar.vue'; import setSize from '@/components/setSize.vue'; import replaceImg from '@/components/replaceImg.vue'; +import cropperImg from '@/components/cropperImg.vue'; import filters from '@/components/filters.vue'; import imgStroke from '@/components/imgStroke.vue'; // import elementData from '@/components/elementData.vue'; @@ -451,6 +454,7 @@ provide('canvasEditor', canvasEditor); width: 380px; } } + // 右侧容器 .right-bar { width: 304px; @@ -507,6 +511,7 @@ provide('canvasEditor', canvasEditor); border-radius: 4px; display: flex; align-items: center; + .ivu-tooltip { text-align: center; flex: 1; @@ -539,11 +544,13 @@ provide('canvasEditor', canvasEditor); .right { display: flex; align-items: center; + img { display: block; margin-right: 10px; } } + .home, .ivu-layout { height: 100vh; @@ -556,6 +563,7 @@ provide('canvasEditor', canvasEditor); .canvas-box { position: relative; } + // 画布内阴影 .inside-shadow { position: absolute; @@ -591,10 +599,12 @@ provide('canvasEditor', canvasEditor); .ivu-menu-light.ivu-menu-vertical .ivu-menu-item-active:not(.ivu-menu-submenu) { background: none; } + // 标尺 .switch { margin-right: 10px; } + // 网格背景 .design-stage-grid { --offsetX: 0px;