画布双击添加内部图片
This commit is contained in:
@@ -2595,7 +2595,7 @@ export class CreateImageLayerCommand extends Command {
|
|||||||
|
|
||||||
// 生成图层名称
|
// 生成图层名称
|
||||||
const fileName =
|
const fileName =
|
||||||
this.layerName || `图片 ${new Date().toLocaleTimeString()}`;
|
this.layerName || `${new Date().toLocaleString()}`;
|
||||||
|
|
||||||
this.fabricImage.set({
|
this.fabricImage.set({
|
||||||
id: this.imageId,
|
id: this.imageId,
|
||||||
|
|||||||
@@ -58,11 +58,15 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="btn" @click="clickflipHorizontal(v)">
|
<div class="btn" @click="clickflipHorizontal(v)">
|
||||||
<i class="iconfont icon-flip-horizontal"></i>
|
<i class="iconfont icon-flip-horizontal"></i>
|
||||||
<p class="tip">{{ t('Canvas.flipHorizontal') }}</p>
|
<p class="tip">
|
||||||
|
{{ t("Canvas.flipHorizontal") }}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn" @click="clickflipVertical(v)">
|
<div class="btn" @click="clickflipVertical(v)">
|
||||||
<i class="iconfont icon-flip-vertical"></i>
|
<i class="iconfont icon-flip-vertical"></i>
|
||||||
<p class="tip">{{ t('Canvas.flipVertical') }}</p>
|
<p class="tip">
|
||||||
|
{{ t("Canvas.flipVertical") }}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -225,16 +229,22 @@
|
|||||||
const initialState = TransformCommand.captureTransformState(obj);
|
const initialState = TransformCommand.captureTransformState(obj);
|
||||||
const finalState = { ...initialState };
|
const finalState = { ...initialState };
|
||||||
const angle = e.target.value;
|
const angle = e.target.value;
|
||||||
const { x, y } = calculateRotatedTopLeftDeg(
|
if (obj.originX === "left" && obj.originY === "top") {
|
||||||
obj.width * obj.scaleX,
|
const width = obj.width * obj.scaleX;
|
||||||
obj.height * obj.scaleY,
|
const height = obj.height * obj.scaleY;
|
||||||
obj.left,
|
const left = obj.left;
|
||||||
obj.top,
|
const top = obj.top;
|
||||||
obj.angle,
|
const { x, y } = calculateRotatedTopLeftDeg(
|
||||||
angle
|
width,
|
||||||
);
|
height,
|
||||||
finalState.left = x;
|
left,
|
||||||
finalState.top = y;
|
top,
|
||||||
|
obj.angle,
|
||||||
|
angle
|
||||||
|
);
|
||||||
|
finalState.left = x;
|
||||||
|
finalState.top = y;
|
||||||
|
}
|
||||||
finalState.angle = angle;
|
finalState.angle = angle;
|
||||||
transformObject(obj, initialState, finalState);
|
transformObject(obj, initialState, finalState);
|
||||||
};
|
};
|
||||||
@@ -257,7 +267,12 @@
|
|||||||
arrs.forEach((v) => {
|
arrs.forEach((v) => {
|
||||||
activeObjects.value.forEach((item) => {
|
activeObjects.value.forEach((item) => {
|
||||||
if (item.id === v.id) {
|
if (item.id === v.id) {
|
||||||
keys.forEach((key) => (item[key] = v[key]));
|
keys.forEach((k) => {
|
||||||
|
item[k] =
|
||||||
|
typeof v[k] === "number"
|
||||||
|
? Number(v[k].toFixed(3))
|
||||||
|
: v[k];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
activeObjects.value = [...activeObjects.value];
|
activeObjects.value = [...activeObjects.value];
|
||||||
@@ -271,7 +286,6 @@
|
|||||||
} else {
|
} else {
|
||||||
arrs.push(e.target);
|
arrs.push(e.target);
|
||||||
}
|
}
|
||||||
console.log(e.target);
|
|
||||||
updateActiveObjects(arrs, ["angle"]);
|
updateActiveObjects(arrs, ["angle"]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -44,16 +44,17 @@
|
|||||||
:key="index"
|
:key="index"
|
||||||
class="image-item"
|
class="image-item"
|
||||||
@click="handleImageClick(item)"
|
@click="handleImageClick(item)"
|
||||||
|
@dblclick="handleImageDoubleClick(item)"
|
||||||
>
|
>
|
||||||
<div class="image-wrapper">
|
<div class="image-wrapper">
|
||||||
<img
|
<img
|
||||||
:src="item.url"
|
:src="item.url"
|
||||||
:alt="item.name || '图片'"
|
:alt="item.name"
|
||||||
@error="handleImageError"
|
@error="handleImageError"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
/>
|
/>
|
||||||
<div class="image-overlay">
|
<div class="image-overlay">
|
||||||
<span class="image-name">{{ item.name || "未命名" }}</span>
|
<span class="image-name">{{ item.name }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="image-select" v-show="selectList.includes(item.url)">
|
<!-- <div class="image-select" v-show="selectList.includes(item.url)">
|
||||||
@@ -169,7 +170,11 @@ const handleImageClick = (item) => {
|
|||||||
selectList.value.push(item.url)
|
selectList.value.push(item.url)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
// 处理图片双击
|
||||||
|
const handleImageDoubleClick = (item) => {
|
||||||
|
selectList.value = [item.url];
|
||||||
|
confirm();
|
||||||
|
}
|
||||||
// 处理图片加载错误
|
// 处理图片加载错误
|
||||||
const handleImageError = (event) => {
|
const handleImageError = (event) => {
|
||||||
event.target.src =
|
event.target.src =
|
||||||
|
|||||||
@@ -26,16 +26,17 @@
|
|||||||
:key="index"
|
:key="index"
|
||||||
class="image-item"
|
class="image-item"
|
||||||
@click="handleImageClick(item)"
|
@click="handleImageClick(item)"
|
||||||
|
@dblclick="handleImageDoubleClick(item)"
|
||||||
>
|
>
|
||||||
<div class="image-wrapper">
|
<div class="image-wrapper">
|
||||||
<img
|
<img
|
||||||
v-lazy="item.url"
|
v-lazy="item.url"
|
||||||
:alt="item.name || '图片'"
|
:alt="item.name"
|
||||||
@error="handleImageError"
|
@error="handleImageError"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
/>
|
/>
|
||||||
<div class="image-overlay">
|
<div class="image-overlay">
|
||||||
<span class="image-name">{{ item.name || '未命名' }}</span>
|
<span class="image-name">{{ item.name }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<img class="selected-icon image-select" src="@/assets/images/icon/selected.png" v-show="selectList.includes(item.url)">
|
<img class="selected-icon image-select" src="@/assets/images/icon/selected.png" v-show="selectList.includes(item.url)">
|
||||||
@@ -48,7 +49,6 @@
|
|||||||
<!-- 加载状态 -->
|
<!-- 加载状态 -->
|
||||||
<div v-if="loading && list.length > 0" class="loading-state">
|
<div v-if="loading && list.length > 0" class="loading-state">
|
||||||
<div class="loading-spinner"></div>
|
<div class="loading-spinner"></div>
|
||||||
<p>加载中...</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 空状态 -->
|
<!-- 空状态 -->
|
||||||
@@ -279,6 +279,14 @@ const handleImageClick = item => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理图片双击
|
||||||
|
const handleImageDoubleClick = item => {
|
||||||
|
selectList.value = [item.url]
|
||||||
|
confirm()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 处理分类切换
|
// 处理分类切换
|
||||||
const handleChangeCategory = category => {
|
const handleChangeCategory = category => {
|
||||||
// console.log('handleChangeCategory',category)
|
// console.log('handleChangeCategory',category)
|
||||||
@@ -307,6 +315,7 @@ const confirm = () => {
|
|||||||
emitData = selectList.value
|
emitData = selectList.value
|
||||||
}
|
}
|
||||||
emits('select', emitData)
|
emits('select', emitData)
|
||||||
|
selectList.value = []
|
||||||
showPanel.value = false
|
showPanel.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user