|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <div ref="editor" style="width: 100%; height: 100%"></div>
|
|
|
|
|
|
|
+ <div ref="editor"></div>
|
|
|
</template>
|
|
</template>
|
|
|
<script setup>
|
|
<script setup>
|
|
|
import {useTemplateRef, onMounted, onUnmounted} from 'vue'
|
|
import {useTemplateRef, onMounted, onUnmounted} from 'vue'
|
|
@@ -8,22 +8,24 @@ import 'tui-color-picker/dist/tui-color-picker.css';
|
|
|
import 'tui-image-editor/dist/tui-image-editor.css';
|
|
import 'tui-image-editor/dist/tui-image-editor.css';
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
- includeUi: {
|
|
|
|
|
- type: Boolean,
|
|
|
|
|
- default: true,
|
|
|
|
|
- },
|
|
|
|
|
- /**
|
|
|
|
|
- * @see https://nhn.github.io/tui.image-editor/latest/ImageEditor
|
|
|
|
|
- */
|
|
|
|
|
- options: {
|
|
|
|
|
- type: Object,
|
|
|
|
|
- default() {
|
|
|
|
|
- return {
|
|
|
|
|
- cssMaxWidth: 700,
|
|
|
|
|
- cssMaxHeight: 900,
|
|
|
|
|
- };
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ // includeUi: {
|
|
|
|
|
+ // type: Boolean,
|
|
|
|
|
+ // default: true,
|
|
|
|
|
+ // },
|
|
|
|
|
+ // /**
|
|
|
|
|
+ // * @see https://nhn.github.io/tui.image-editor/latest/ImageEditor
|
|
|
|
|
+ // */
|
|
|
|
|
+ // options: {
|
|
|
|
|
+ // type: Object,
|
|
|
|
|
+ // default() {
|
|
|
|
|
+ // return {
|
|
|
|
|
+ // cssMaxWidth: 700,
|
|
|
|
|
+ // cssMaxHeight: 900,
|
|
|
|
|
+ // };
|
|
|
|
|
+ // },
|
|
|
|
|
+ // },
|
|
|
|
|
+ // 图片地址
|
|
|
|
|
+ image_url: String,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const includeUIOptions = {
|
|
const includeUIOptions = {
|
|
@@ -164,7 +166,7 @@ const zh_local = {
|
|
|
Multiply: "正片叠底",
|
|
Multiply: "正片叠底",
|
|
|
Blend: "混合色",
|
|
Blend: "混合色",
|
|
|
Double: '双击',
|
|
Double: '双击',
|
|
|
- Download: '预览图片'
|
|
|
|
|
|
|
+ Download: '下载图片'
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const theme = {
|
|
const theme = {
|
|
@@ -247,99 +249,195 @@ const theme = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+// -----------------------
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- // image 坐上角度图片
|
|
|
|
|
- "common.bi.image": "", // 在这里换上你喜欢的logo图片
|
|
|
|
|
- "common.bisize.width": "0px",
|
|
|
|
|
- "common.bisize.height": "0px",
|
|
|
|
|
- "common.backgroundImage": "none",
|
|
|
|
|
- "common.backgroundColor": "#f3f4f6",
|
|
|
|
|
- "common.border": "1px solid #444",
|
|
|
|
|
-
|
|
|
|
|
- // header
|
|
|
|
|
- "header.backgroundImage": "none",
|
|
|
|
|
- "header.backgroundColor": "#f3f4f6",
|
|
|
|
|
- "header.border": "0px",
|
|
|
|
|
- "header.margin": "0px auto",
|
|
|
|
|
-
|
|
|
|
|
- // load button
|
|
|
|
|
- "loadButton.backgroundColor": "#fff",
|
|
|
|
|
- "loadButton.border": "1px solid #ddd",
|
|
|
|
|
- "loadButton.color": "#222",
|
|
|
|
|
- "loadButton.fontFamily": "NotoSans, sans-serif",
|
|
|
|
|
- "loadButton.fontSize": "12px",
|
|
|
|
|
- // "loadButton.width": "150px",
|
|
|
|
|
- // "loadButton.display": "none", // 可以直接隐藏掉
|
|
|
|
|
-
|
|
|
|
|
- // download button
|
|
|
|
|
- "downloadButton.backgroundColor": "#fdba3b",
|
|
|
|
|
- "downloadButton.border": "1px solid #fdba3b",
|
|
|
|
|
- "downloadButton.color": "#fff",
|
|
|
|
|
- "downloadButton.fontFamily": "NotoSans, sans-serif",
|
|
|
|
|
- "downloadButton.fontSize": "12px",
|
|
|
|
|
- // "downloadButton.display": "none", // 可以直接隐藏掉
|
|
|
|
|
-
|
|
|
|
|
- // icons default
|
|
|
|
|
- "menu.normalIcon.color": "#8a8a8a",
|
|
|
|
|
- "menu.activeIcon.color": "#555555",
|
|
|
|
|
- "menu.disabledIcon.color": "#434343",
|
|
|
|
|
- "menu.hoverIcon.color": "#e9e9e9",
|
|
|
|
|
- "submenu.normalIcon.color": "#8a8a8a",
|
|
|
|
|
- "submenu.activeIcon.color": "#e9e9e9",
|
|
|
|
|
-
|
|
|
|
|
- "menu.iconSize.width": "24px",
|
|
|
|
|
- "menu.iconSize.height": "24px",
|
|
|
|
|
- "submenu.iconSize.width": "32px",
|
|
|
|
|
- "submenu.iconSize.height": "32px",
|
|
|
|
|
-
|
|
|
|
|
- // submenu primary color
|
|
|
|
|
- "submenu.backgroundColor": "#1e1e1e",
|
|
|
|
|
- "submenu.partition.color": "#858585",
|
|
|
|
|
-
|
|
|
|
|
- // submenu labels
|
|
|
|
|
- "submenu.normalLabel.color": "#858585",
|
|
|
|
|
- "submenu.normalLabel.fontWeight": "lighter",
|
|
|
|
|
- "submenu.activeLabel.color": "#fff",
|
|
|
|
|
- "submenu.activeLabel.fontWeight": "lighter",
|
|
|
|
|
-
|
|
|
|
|
- // checkbox style
|
|
|
|
|
- "checkbox.border": "1px solid #ccc",
|
|
|
|
|
- "checkbox.backgroundColor": "#fff",
|
|
|
|
|
-
|
|
|
|
|
- // rango style
|
|
|
|
|
- "range.pointer.color": "#fff",
|
|
|
|
|
- "range.bar.color": "#666",
|
|
|
|
|
- "range.subbar.color": "#d1d1d1",
|
|
|
|
|
-
|
|
|
|
|
- "range.disabledPointer.color": "#414141",
|
|
|
|
|
- "range.disabledBar.color": "#282828",
|
|
|
|
|
- "range.disabledSubbar.color": "#414141",
|
|
|
|
|
-
|
|
|
|
|
- "range.value.color": "#fff",
|
|
|
|
|
- "range.value.fontWeight": "lighter",
|
|
|
|
|
- "range.value.fontSize": "11px",
|
|
|
|
|
- "range.value.border": "1px solid #353535",
|
|
|
|
|
- "range.value.backgroundColor": "#151515",
|
|
|
|
|
- "range.title.color": "#fff",
|
|
|
|
|
- "range.title.fontWeight": "lighter",
|
|
|
|
|
-
|
|
|
|
|
- // colorpicker style
|
|
|
|
|
- "colorpicker.button.border": "1px solid #1e1e1e",
|
|
|
|
|
- "colorpicker.title.color": "#fff"
|
|
|
|
|
|
|
+ // // image 坐上角度图片
|
|
|
|
|
+ // "common.bi.image": "", // 在这里换上你喜欢的logo图片
|
|
|
|
|
+ // "common.bisize.width": "0px",
|
|
|
|
|
+ // "common.bisize.height": "0px",
|
|
|
|
|
+ // "common.backgroundImage": "none",
|
|
|
|
|
+ // "common.backgroundColor": "#f3f4f6",
|
|
|
|
|
+ // "common.border": "1px solid #444",
|
|
|
|
|
+
|
|
|
|
|
+ // // header
|
|
|
|
|
+ // "header.backgroundImage": "none",
|
|
|
|
|
+ // "header.backgroundColor": "#f3f4f6",
|
|
|
|
|
+ // "header.border": "0px",
|
|
|
|
|
+ // "header.margin": "0px auto",
|
|
|
|
|
+
|
|
|
|
|
+ // // load button
|
|
|
|
|
+ // "loadButton.backgroundColor": "#fff",
|
|
|
|
|
+ // "loadButton.border": "1px solid #ddd",
|
|
|
|
|
+ // "loadButton.color": "#222",
|
|
|
|
|
+ // "loadButton.fontFamily": "NotoSans, sans-serif",
|
|
|
|
|
+ // "loadButton.fontSize": "12px",
|
|
|
|
|
+ // // "loadButton.width": "150px",
|
|
|
|
|
+ // // "loadButton.display": "none", // 可以直接隐藏掉
|
|
|
|
|
+
|
|
|
|
|
+ // // download button
|
|
|
|
|
+ // "downloadButton.backgroundColor": "#fdba3b",
|
|
|
|
|
+ // "downloadButton.border": "1px solid #fdba3b",
|
|
|
|
|
+ // "downloadButton.color": "#fff",
|
|
|
|
|
+ // "downloadButton.fontFamily": "NotoSans, sans-serif",
|
|
|
|
|
+ // "downloadButton.fontSize": "12px",
|
|
|
|
|
+ // // "downloadButton.display": "none", // 可以直接隐藏掉
|
|
|
|
|
+
|
|
|
|
|
+ // // icons default
|
|
|
|
|
+ // "menu.normalIcon.color": "#8a8a8a",
|
|
|
|
|
+ // "menu.activeIcon.color": "#555555",
|
|
|
|
|
+ // "menu.disabledIcon.color": "#434343",
|
|
|
|
|
+ // "menu.hoverIcon.color": "#e9e9e9",
|
|
|
|
|
+ // "submenu.normalIcon.color": "#8a8a8a",
|
|
|
|
|
+ // "submenu.activeIcon.color": "#e9e9e9",
|
|
|
|
|
+
|
|
|
|
|
+ // "menu.iconSize.width": "24px",
|
|
|
|
|
+ // "menu.iconSize.height": "24px",
|
|
|
|
|
+ // "submenu.iconSize.width": "32px",
|
|
|
|
|
+ // "submenu.iconSize.height": "32px",
|
|
|
|
|
+
|
|
|
|
|
+ // // submenu primary color
|
|
|
|
|
+ // "submenu.backgroundColor": "#1e1e1e",
|
|
|
|
|
+ // "submenu.partition.color": "#858585",
|
|
|
|
|
+
|
|
|
|
|
+ // // submenu labels
|
|
|
|
|
+ // "submenu.normalLabel.color": "#858585",
|
|
|
|
|
+ // "submenu.normalLabel.fontWeight": "lighter",
|
|
|
|
|
+ // "submenu.activeLabel.color": "#fff",
|
|
|
|
|
+ // "submenu.activeLabel.fontWeight": "lighter",
|
|
|
|
|
+
|
|
|
|
|
+ // // checkbox style
|
|
|
|
|
+ // "checkbox.border": "1px solid #ccc",
|
|
|
|
|
+ // "checkbox.backgroundColor": "#fff",
|
|
|
|
|
+
|
|
|
|
|
+ // // rango style
|
|
|
|
|
+ // "range.pointer.color": "#fff",
|
|
|
|
|
+ // "range.bar.color": "#666",
|
|
|
|
|
+ // "range.subbar.color": "#d1d1d1",
|
|
|
|
|
+
|
|
|
|
|
+ // "range.disabledPointer.color": "#414141",
|
|
|
|
|
+ // "range.disabledBar.color": "#282828",
|
|
|
|
|
+ // "range.disabledSubbar.color": "#414141",
|
|
|
|
|
+
|
|
|
|
|
+ // "range.value.color": "#fff",
|
|
|
|
|
+ // "range.value.fontWeight": "lighter",
|
|
|
|
|
+ // "range.value.fontSize": "11px",
|
|
|
|
|
+ // "range.value.border": "1px solid #353535",
|
|
|
|
|
+ // "range.value.backgroundColor": "#151515",
|
|
|
|
|
+ // "range.title.color": "#fff",
|
|
|
|
|
+ // "range.title.fontWeight": "lighter",
|
|
|
|
|
+
|
|
|
|
|
+ // // colorpicker style
|
|
|
|
|
+ // "colorpicker.button.border": "1px solid #1e1e1e",
|
|
|
|
|
+ // "colorpicker.title.color": "#fff",
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// -----------------------
|
|
|
|
|
+
|
|
|
|
|
+ "common.bi.image": "", // 左上角logo图片
|
|
|
|
|
+ "common.bisize.width": "0px",
|
|
|
|
|
+ "common.bisize.height": "0px",
|
|
|
|
|
+ "common.backgroundImage": "none",
|
|
|
|
|
+ "common.backgroundColor": "#f3f4f6",
|
|
|
|
|
+ "common.border": "1px solid #333",
|
|
|
|
|
+
|
|
|
|
|
+ // header
|
|
|
|
|
+ "header.backgroundImage": "none",
|
|
|
|
|
+ "header.backgroundColor": "#f3f4f6",
|
|
|
|
|
+ "header.border": "0px",
|
|
|
|
|
+
|
|
|
|
|
+ // load button
|
|
|
|
|
+ "loadButton.backgroundColor": "#fff",
|
|
|
|
|
+ "loadButton.border": "1px solid #ddd",
|
|
|
|
|
+ "loadButton.color": "#222",
|
|
|
|
|
+ "loadButton.fontFamily": "NotoSans, sans-serif",
|
|
|
|
|
+ "loadButton.fontSize": "12px",
|
|
|
|
|
+ // "loadButton.display": "none", // 隐藏
|
|
|
|
|
+
|
|
|
|
|
+ // download button
|
|
|
|
|
+ "downloadButton.backgroundColor": "#fdba3b",
|
|
|
|
|
+ "downloadButton.border": "1px solid #fdba3b",
|
|
|
|
|
+ "downloadButton.color": "#fff",
|
|
|
|
|
+ "downloadButton.fontFamily": "NotoSans, sans-serif",
|
|
|
|
|
+ "downloadButton.fontSize": "12px",
|
|
|
|
|
+ // "downloadButton.display": "none", // 隐藏
|
|
|
|
|
+
|
|
|
|
|
+ // icons default
|
|
|
|
|
+ "menu.normalIcon.color": "#8a8a8a",
|
|
|
|
|
+ "menu.activeIcon.color": "#555555",
|
|
|
|
|
+ "menu.disabledIcon.color": "#ccc",
|
|
|
|
|
+ "menu.hoverIcon.color": "#e9e9e9",
|
|
|
|
|
+ "submenu.normalIcon.color": "#8a8a8a",
|
|
|
|
|
+ "submenu.activeIcon.color": "#e9e9e9",
|
|
|
|
|
+
|
|
|
|
|
+ "menu.iconSize.width": "24px",
|
|
|
|
|
+ "menu.iconSize.height": "24px",
|
|
|
|
|
+ "submenu.iconSize.width": "32px",
|
|
|
|
|
+ "submenu.iconSize.height": "32px",
|
|
|
|
|
+
|
|
|
|
|
+ // submenu primary color
|
|
|
|
|
+ "submenu.backgroundColor": "#1e1e1e",
|
|
|
|
|
+ "submenu.partition.color": "#858585",
|
|
|
|
|
+
|
|
|
|
|
+ // submenu labels
|
|
|
|
|
+ "submenu.normalLabel.color": "#858585",
|
|
|
|
|
+ "submenu.normalLabel.fontWeight": "lighter",
|
|
|
|
|
+ "submenu.activeLabel.color": "#fff",
|
|
|
|
|
+ "submenu.activeLabel.fontWeight": "lighter",
|
|
|
|
|
+
|
|
|
|
|
+ // checkbox style
|
|
|
|
|
+ "checkbox.border": "1px solid #ccc",
|
|
|
|
|
+ "checkbox.backgroundColor": "#fff",
|
|
|
|
|
+
|
|
|
|
|
+ // rango style
|
|
|
|
|
+ "range.pointer.color": "#fff",
|
|
|
|
|
+ "range.bar.color": "#666",
|
|
|
|
|
+ "range.subbar.color": "#d1d1d1",
|
|
|
|
|
+
|
|
|
|
|
+ "range.disabledPointer.color": "#414141",
|
|
|
|
|
+ "range.disabledBar.color": "#282828",
|
|
|
|
|
+ "range.disabledSubbar.color": "#414141",
|
|
|
|
|
+
|
|
|
|
|
+ "range.value.color": "#fff",
|
|
|
|
|
+ "range.value.fontWeight": "lighter",
|
|
|
|
|
+ "range.value.fontSize": "11px",
|
|
|
|
|
+ "range.value.border": "1px solid #353535",
|
|
|
|
|
+ "range.value.backgroundColor": "#151515",
|
|
|
|
|
+ "range.title.color": "#fff",
|
|
|
|
|
+ "range.title.fontWeight": "lighter",
|
|
|
|
|
+
|
|
|
|
|
+ // colorpicker style
|
|
|
|
|
+ "colorpicker.button.border": "1px solid #1e1e1e",
|
|
|
|
|
+ "colorpicker.title.color": "#fff",
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
- let options = props.options;
|
|
|
|
|
-
|
|
|
|
|
- if (props.includeUi) {
|
|
|
|
|
- options = Object.assign(includeUIOptions, props.options);
|
|
|
|
|
|
|
+ // let options = props.options;
|
|
|
|
|
+
|
|
|
|
|
+ // if (props.includeUi) {
|
|
|
|
|
+ // options = Object.assign(includeUIOptions, props.options);
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // options.includeUI.locale = zh_local;
|
|
|
|
|
+ // options.includeUI.theme = theme;
|
|
|
|
|
+
|
|
|
|
|
+ const opts = {
|
|
|
|
|
+ includeUI: {
|
|
|
|
|
+ loadImage: {
|
|
|
|
|
+ // path: "https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/c1d7a1feb60346449c1a64893888989a~tplv-k3u1fbpfcp-watermark.image",
|
|
|
|
|
+ // path: 'http://localhost/src/assets/slider/logo.jpg',
|
|
|
|
|
+ path: props.image_url,
|
|
|
|
|
+ name: "image",
|
|
|
|
|
+ },
|
|
|
|
|
+ initMenu: "draw", // 默认打开的菜单项
|
|
|
|
|
+ menuBarPosition: "bottom", // 菜单所在的位置
|
|
|
|
|
+ locale: zh_local, // 本地化语言为中文
|
|
|
|
|
+ theme: theme
|
|
|
|
|
+ },
|
|
|
|
|
+ cssMaxWidth: 1000, // canvas 最大宽度
|
|
|
|
|
+ cssMaxHeight: 600, // canvas 最大高度
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- options.includeUI.locale = zh_local;
|
|
|
|
|
- options.includeUI.theme = theme;
|
|
|
|
|
-
|
|
|
|
|
- editorInstance = new ImageEditor(editor.value, options);
|
|
|
|
|
|
|
+ editorInstance = new ImageEditor(editor.value, opts);
|
|
|
addEventListener();
|
|
addEventListener();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -352,3 +450,9 @@ onUnmounted(() => {
|
|
|
editorInstance = null;
|
|
editorInstance = null;
|
|
|
});
|
|
});
|
|
|
</script>
|
|
</script>
|
|
|
|
|
+
|
|
|
|
|
+<style>
|
|
|
|
|
+.image-editor-body .tui-image-editor{
|
|
|
|
|
+ top: 0 !important;
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|