|
|
@@ -7,38 +7,38 @@
|
|
|
<el-row class="size-row">
|
|
|
<el-col :span="11">
|
|
|
<el-input
|
|
|
- v-model="canvasWidth"
|
|
|
- :value="Math.round(canvasWidth * 100) / 100"
|
|
|
- @change="changeTemplateWidth"
|
|
|
- oninput="value=value.replace(/[^\d.]/g,'')"
|
|
|
+ v-model="canvasWidth"
|
|
|
+ :value="pageSizeWidth"
|
|
|
+ @change="changeTemplateWidth"
|
|
|
+ oninput="value=value.replace(/[^\d.]/g,'')"
|
|
|
>
|
|
|
<template #prepend>{{ t("style.w") }}</template>
|
|
|
</el-input>
|
|
|
</el-col>
|
|
|
<el-col :span="2" class="fixed-ratio">
|
|
|
<el-tooltip
|
|
|
- effect="dark"
|
|
|
- placement="top"
|
|
|
- :content="t('style.unlockAspectRatio')"
|
|
|
- v-if="isFixed"
|
|
|
+ effect="dark"
|
|
|
+ placement="top"
|
|
|
+ :content="t('style.unlockAspectRatio')"
|
|
|
+ v-if="isFixed"
|
|
|
>
|
|
|
- <IconLock class="icon-btn" @click="changeFixedRatio(false)" />
|
|
|
+ <IconLock class="icon-btn" @click="changeFixedRatio(false)"/>
|
|
|
</el-tooltip>
|
|
|
<el-tooltip
|
|
|
- effect="dark"
|
|
|
- placement="top"
|
|
|
- :content="t('style.lockAspectRatio')"
|
|
|
- v-else
|
|
|
+ effect="dark"
|
|
|
+ placement="top"
|
|
|
+ :content="t('style.lockAspectRatio')"
|
|
|
+ v-else
|
|
|
>
|
|
|
- <IconUnlock class="icon-btn" @click="changeFixedRatio(true)" />
|
|
|
+ <IconUnlock class="icon-btn" @click="changeFixedRatio(true)"/>
|
|
|
</el-tooltip>
|
|
|
</el-col>
|
|
|
<el-col :span="11">
|
|
|
<el-input
|
|
|
- v-model="canvasHeight"
|
|
|
- :value="Math.round(canvasHeight * 100) / 100"
|
|
|
- @change="changeTemplateHeight"
|
|
|
- oninput="value=value.replace(/[^\d.]/g,'')"
|
|
|
+ v-model="canvasHeight"
|
|
|
+ :value="pageSizeHeight"
|
|
|
+ @change="changeTemplateHeight"
|
|
|
+ oninput="value=value.replace(/[^\d.]/g,'')"
|
|
|
>
|
|
|
<template #prepend>{{ t("style.h") }}</template>
|
|
|
</el-input>
|
|
|
@@ -49,54 +49,54 @@
|
|
|
<el-row>
|
|
|
<el-col :span="11">
|
|
|
<el-input
|
|
|
- v-model="clip"
|
|
|
- @change="changeTemplateClip"
|
|
|
- oninput="value=value.replace(/[^\d]/g,'')"
|
|
|
- :disabled="unitMode === 1"
|
|
|
+ v-model="clip"
|
|
|
+ @change="changeTemplateClip"
|
|
|
+ oninput="value=value.replace(/[^\d]/g,'')"
|
|
|
+ :disabled="unitMode === 1"
|
|
|
>
|
|
|
<template #prepend>
|
|
|
<el-tooltip
|
|
|
- placement="top"
|
|
|
- :hide-after="0"
|
|
|
- :content="t('style.bleedingLine')"
|
|
|
+ placement="top"
|
|
|
+ :hide-after="0"
|
|
|
+ :content="t('style.bleedingLine')"
|
|
|
>
|
|
|
- <IconCuttingOne />
|
|
|
+ <IconCuttingOne/>
|
|
|
</el-tooltip>
|
|
|
</template>
|
|
|
</el-input>
|
|
|
</el-col>
|
|
|
<el-col :span="2" class="fixed-ratio">
|
|
|
<el-tooltip
|
|
|
- effect="dark"
|
|
|
- placement="top"
|
|
|
- :content="t('style.fillet')"
|
|
|
- v-if="isRound"
|
|
|
+ effect="dark"
|
|
|
+ placement="top"
|
|
|
+ :content="t('style.fillet')"
|
|
|
+ v-if="isRound"
|
|
|
>
|
|
|
- <IconRound class="icon-btn" @click="changeWorkRound(false)" />
|
|
|
+ <IconRound class="icon-btn" @click="changeWorkRound(false)"/>
|
|
|
</el-tooltip>
|
|
|
<el-tooltip
|
|
|
- effect="dark"
|
|
|
- placement="top"
|
|
|
- :content="t('style.rightAngle')"
|
|
|
- v-else
|
|
|
+ effect="dark"
|
|
|
+ placement="top"
|
|
|
+ :content="t('style.rightAngle')"
|
|
|
+ v-else
|
|
|
>
|
|
|
- <IconRightAngle class="icon-btn" @click="changeWorkRound(true)" />
|
|
|
+ <IconRightAngle class="icon-btn" @click="changeWorkRound(true)"/>
|
|
|
</el-tooltip>
|
|
|
</el-col>
|
|
|
<el-col :span="11">
|
|
|
<el-input
|
|
|
- v-model="safe"
|
|
|
- @change="changeTemplateSafe"
|
|
|
- oninput="value=value.replace(/[^\d]/g,'')"
|
|
|
- :disabled="unitMode === 1"
|
|
|
+ v-model="safe"
|
|
|
+ @change="changeTemplateSafe"
|
|
|
+ oninput="value=value.replace(/[^\d]/g,'')"
|
|
|
+ :disabled="unitMode === 1"
|
|
|
>
|
|
|
<template #prepend>
|
|
|
<el-tooltip
|
|
|
- placement="top"
|
|
|
- :hide-after="0"
|
|
|
- :content="t('style.safetyLine')"
|
|
|
+ placement="top"
|
|
|
+ :hide-after="0"
|
|
|
+ :content="t('style.safetyLine')"
|
|
|
>
|
|
|
- <IconShield />
|
|
|
+ <IconShield/>
|
|
|
</el-tooltip>
|
|
|
</template>
|
|
|
</el-input>
|
|
|
@@ -109,46 +109,46 @@
|
|
|
<el-select v-model="unitMode" @change="changeUnitMode">
|
|
|
<template #prefix>
|
|
|
<el-tooltip
|
|
|
- placement="top"
|
|
|
- :hide-after="0"
|
|
|
- :content="t('style.unit')"
|
|
|
+ placement="top"
|
|
|
+ :hide-after="0"
|
|
|
+ :content="t('style.unit')"
|
|
|
>
|
|
|
- <IconRuler />
|
|
|
+ <IconRuler/>
|
|
|
</el-tooltip>
|
|
|
</template>
|
|
|
<el-option
|
|
|
- v-for="item in DesignUnitMode"
|
|
|
- :key="item.id"
|
|
|
- :label="item.name"
|
|
|
- :value="item.id"
|
|
|
+ v-for="item in DesignUnitMode"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
></el-option>
|
|
|
</el-select>
|
|
|
</el-col>
|
|
|
<el-col :span="2"></el-col>
|
|
|
-<!-- <el-col :span="11">-->
|
|
|
-<!-- <el-select v-model="sizeMode">-->
|
|
|
-<!-- <template #prefix>-->
|
|
|
-<!-- <el-tooltip-->
|
|
|
-<!-- placement="top"-->
|
|
|
-<!-- :hide-after="0"-->
|
|
|
-<!-- :content="t('style.template')"-->
|
|
|
-<!-- >-->
|
|
|
-<!-- <IconIdCard />-->
|
|
|
-<!-- </el-tooltip>-->
|
|
|
-<!-- </template>-->
|
|
|
-<!-- <el-option-->
|
|
|
-<!-- v-for="item in DesignSizeMode"-->
|
|
|
-<!-- :key="item.id"-->
|
|
|
-<!-- :label="item.name"-->
|
|
|
-<!-- :value="item.id"-->
|
|
|
-<!-- :disabled="item.disabled"-->
|
|
|
-<!-- ></el-option>-->
|
|
|
-<!-- </el-select>-->
|
|
|
-<!-- </el-col>-->
|
|
|
+ <!-- <el-col :span="11">-->
|
|
|
+ <!-- <el-select v-model="sizeMode">-->
|
|
|
+ <!-- <template #prefix>-->
|
|
|
+ <!-- <el-tooltip-->
|
|
|
+ <!-- placement="top"-->
|
|
|
+ <!-- :hide-after="0"-->
|
|
|
+ <!-- :content="t('style.template')"-->
|
|
|
+ <!-- >-->
|
|
|
+ <!-- <IconIdCard />-->
|
|
|
+ <!-- </el-tooltip>-->
|
|
|
+ <!-- </template>-->
|
|
|
+ <!-- <el-option-->
|
|
|
+ <!-- v-for="item in DesignSizeMode"-->
|
|
|
+ <!-- :key="item.id"-->
|
|
|
+ <!-- :label="item.name"-->
|
|
|
+ <!-- :value="item.id"-->
|
|
|
+ <!-- :disabled="item.disabled"-->
|
|
|
+ <!-- ></el-option>-->
|
|
|
+ <!-- </el-select>-->
|
|
|
+ <!-- </el-col>-->
|
|
|
</el-row>
|
|
|
</div>
|
|
|
|
|
|
- <el-divider style="margin: 12px 0" />
|
|
|
+ <el-divider style="margin: 12px 0"/>
|
|
|
|
|
|
<div class="title">
|
|
|
<b>{{ t("style.canvasFill") }}</b>
|
|
|
@@ -156,13 +156,13 @@
|
|
|
<div class="row">
|
|
|
<el-button class="full-row" @click="changeAllBackgroud">{{ t("style.applyCanvasToAll") }}</el-button>
|
|
|
</div>
|
|
|
- <Backgrounds />
|
|
|
+ <Backgrounds/>
|
|
|
|
|
|
- <el-divider style="margin: 12px 0" />
|
|
|
+ <el-divider style="margin: 12px 0"/>
|
|
|
|
|
|
- <Watermark />
|
|
|
+ <Watermark/>
|
|
|
|
|
|
- <el-divider style="margin: 12px 0" />
|
|
|
+ <el-divider style="margin: 12px 0"/>
|
|
|
|
|
|
<div class="title">
|
|
|
<b>{{ t("style.canvasMask") }}</b>
|
|
|
@@ -178,13 +178,13 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { Rect } from "fabric";
|
|
|
-import { storeToRefs } from "pinia";
|
|
|
-import { ElMessage } from "element-plus";
|
|
|
-import { ref, watch, onMounted, computed } from "vue";
|
|
|
-import { mm2px, px2mm } from "@/utils/image";
|
|
|
+import {Rect} from "fabric";
|
|
|
+import {storeToRefs} from "pinia";
|
|
|
+import {ElMessage} from "element-plus";
|
|
|
+import {ref, watch, onMounted, computed} from "vue";
|
|
|
+import {mm2px, px2mm} from "@/utils/image";
|
|
|
import useI18n from "@/hooks/useI18n";
|
|
|
-import { useFabricStore, useMainStore, useTemplatesStore } from "@/store";
|
|
|
+import {useFabricStore, useMainStore, useTemplatesStore} from "@/store";
|
|
|
import {
|
|
|
WorkSpaceClipType,
|
|
|
WorkSpaceDrawType,
|
|
|
@@ -202,16 +202,23 @@ import Watermark from "./Watermark/index.vue";
|
|
|
import useHistorySnapshot from "@/hooks/useHistorySnapshot";
|
|
|
import useCanvasScale from '@/hooks/useCanvasScale'
|
|
|
|
|
|
-const { t } = useI18n();
|
|
|
+const {t} = useI18n();
|
|
|
|
|
|
const mainStore = useMainStore();
|
|
|
const templatesStore = useTemplatesStore();
|
|
|
const fabricStore = useFabricStore();
|
|
|
-const { addHistorySnapshot } = useHistorySnapshot();
|
|
|
-const { sizeMode, unitMode } = storeToRefs(mainStore);
|
|
|
-const { currentTemplate } = storeToRefs(templatesStore);
|
|
|
-const { clip, safe, zoom, opacity } = storeToRefs(fabricStore);
|
|
|
-const { setCanvasSize, resetCanvas } = useCanvasScale()
|
|
|
+const {addHistorySnapshot} = useHistorySnapshot();
|
|
|
+const {sizeMode, unitMode} = storeToRefs(mainStore);
|
|
|
+const {currentTemplate} = storeToRefs(templatesStore);
|
|
|
+const {clip, safe, zoom, opacity} = storeToRefs(fabricStore);
|
|
|
+const {setCanvasSize, resetCanvas} = useCanvasScale()
|
|
|
+
|
|
|
+const pageSizeWidth = computed(() => {
|
|
|
+ return Math.round(templateWidth.value * 100) / 100
|
|
|
+})
|
|
|
+const pageSizeHeight = computed(() => {
|
|
|
+ return Math.round(templateHeight.value * 100) / 100
|
|
|
+})
|
|
|
|
|
|
const templateWidth = computed(() => {
|
|
|
// const [ canvas ] = useCanvas()
|
|
|
@@ -244,23 +251,23 @@ const gridColorRecent = ref<[string[]]>([[]]);
|
|
|
// 获取画布尺寸
|
|
|
const getCanvasSize = () => {
|
|
|
let width =
|
|
|
- unitMode.value === 0 ? mm2px(canvasWidth.value) : canvasWidth.value;
|
|
|
+ unitMode.value === 0 ? mm2px(canvasWidth.value) : canvasWidth.value;
|
|
|
let height =
|
|
|
- unitMode.value === 0 ? mm2px(canvasHeight.value) : canvasHeight.value;
|
|
|
+ unitMode.value === 0 ? mm2px(canvasHeight.value) : canvasHeight.value;
|
|
|
width = width * zoom.value;
|
|
|
height = height * zoom.value;
|
|
|
- return { width, height };
|
|
|
+ return {width, height};
|
|
|
};
|
|
|
|
|
|
// 修改画布宽度
|
|
|
const changeTemplateWidth = () => {
|
|
|
const [canvas] = useCanvas();
|
|
|
const workSpaceDraw = canvas
|
|
|
- .getObjects()
|
|
|
- .filter((item) => item.id === WorkSpaceDrawType)[0];
|
|
|
+ .getObjects()
|
|
|
+ .filter((item) => item.id === WorkSpaceDrawType)[0];
|
|
|
if (!workSpaceDraw) return;
|
|
|
const ratio = currentTemplate.value.height / currentTemplate.value.width;
|
|
|
- let { width, height } = getCanvasSize();
|
|
|
+ let {width, height} = getCanvasSize();
|
|
|
if (width / zoom.value < mm2px(MinSize)) {
|
|
|
ElMessage({
|
|
|
message: t("style.minimumSizeLimit") + MinSize,
|
|
|
@@ -276,7 +283,7 @@ const changeTemplateWidth = () => {
|
|
|
width = mm2px(MaxSize) * zoom.value;
|
|
|
}
|
|
|
height = isFixed.value ? width * ratio : height;
|
|
|
- workSpaceDraw.set({ width: width / zoom.value, height: height / zoom.value });
|
|
|
+ workSpaceDraw.set({width: width / zoom.value, height: height / zoom.value});
|
|
|
templatesStore.setSize(width, height, zoom.value);
|
|
|
sizeMode.value = 2;
|
|
|
canvas.renderAll();
|
|
|
@@ -288,11 +295,11 @@ const changeTemplateWidth = () => {
|
|
|
const changeTemplateHeight = () => {
|
|
|
const [canvas] = useCanvas();
|
|
|
const workSpaceDraw = canvas
|
|
|
- .getObjects()
|
|
|
- .filter((item) => item.id === WorkSpaceDrawType)[0];
|
|
|
+ .getObjects()
|
|
|
+ .filter((item) => item.id === WorkSpaceDrawType)[0];
|
|
|
if (!workSpaceDraw) return;
|
|
|
const ratio = currentTemplate.value.height / currentTemplate.value.width;
|
|
|
- let { width, height } = getCanvasSize();
|
|
|
+ let {width, height} = getCanvasSize();
|
|
|
if (height / zoom.value < mm2px(MinSize)) {
|
|
|
ElMessage({
|
|
|
message: t("style.minimumSizeLimit") + MinSize,
|
|
|
@@ -308,7 +315,7 @@ const changeTemplateHeight = () => {
|
|
|
height = mm2px(MaxSize) * zoom.value;
|
|
|
}
|
|
|
width = isFixed.value ? height / ratio : width;
|
|
|
- workSpaceDraw.set({ width: width / zoom.value, height: height / zoom.value });
|
|
|
+ workSpaceDraw.set({width: width / zoom.value, height: height / zoom.value});
|
|
|
templatesStore.setSize(width, height, zoom.value);
|
|
|
sizeMode.value = 2;
|
|
|
canvas.renderAll();
|
|
|
@@ -337,15 +344,15 @@ const changeFixedRatio = (fixedStatus: boolean) => {
|
|
|
const changeWorkRound = (roundStatus: boolean) => {
|
|
|
const [canvas] = useCanvas();
|
|
|
const workSpaceclip = canvas
|
|
|
- .getObjects()
|
|
|
- .filter(
|
|
|
- (item) => WorkSpaceClipType === item.id && item.isType("Rect")
|
|
|
- )[0] as Rect;
|
|
|
+ .getObjects()
|
|
|
+ .filter(
|
|
|
+ (item) => WorkSpaceClipType === item.id && item.isType("Rect")
|
|
|
+ )[0] as Rect;
|
|
|
let rx = 0,
|
|
|
- ry = 0;
|
|
|
+ ry = 0;
|
|
|
isRound.value = roundStatus;
|
|
|
if (isRound.value) rx = ry = 10;
|
|
|
- workSpaceclip.set({ rx, ry });
|
|
|
+ workSpaceclip.set({rx, ry});
|
|
|
canvas.renderAll();
|
|
|
};
|
|
|
|
|
|
@@ -372,10 +379,10 @@ const changeAllBackgroud = () => {
|
|
|
templatesStore.templates.forEach((item) => {
|
|
|
item.workSpace = currentTemplate.value.workSpace;
|
|
|
const currentWorkSpace = currentTemplate.value.objects.filter(
|
|
|
- (ele) => ele.id === WorkSpaceDrawType
|
|
|
+ (ele) => ele.id === WorkSpaceDrawType
|
|
|
)[0];
|
|
|
item.objects = item.objects.map((ele) =>
|
|
|
- ele.id === WorkSpaceDrawType ? currentWorkSpace : ele
|
|
|
+ ele.id === WorkSpaceDrawType ? currentWorkSpace : ele
|
|
|
) as any;
|
|
|
});
|
|
|
};
|
|
|
@@ -388,19 +395,19 @@ onMounted(() => {
|
|
|
|
|
|
// 保存缓存最近添加的网格
|
|
|
watch(
|
|
|
- gridColorRecent,
|
|
|
- () => {
|
|
|
- const recentGridCache = JSON.stringify(gridColorRecent.value);
|
|
|
- localStorage.setItem(RECENT_GRIDS, recentGridCache);
|
|
|
- },
|
|
|
- { deep: true }
|
|
|
+ gridColorRecent,
|
|
|
+ () => {
|
|
|
+ const recentGridCache = JSON.stringify(gridColorRecent.value);
|
|
|
+ localStorage.setItem(RECENT_GRIDS, recentGridCache);
|
|
|
+ },
|
|
|
+ {deep: true}
|
|
|
);
|
|
|
|
|
|
const changeMaskOpacity = () => {
|
|
|
const [canvas] = useCanvas();
|
|
|
const workMask = canvas
|
|
|
- .getObjects()
|
|
|
- .filter((ele) => ele.id === WorkSpaceMaskType)[0];
|
|
|
+ .getObjects()
|
|
|
+ .filter((ele) => ele.id === WorkSpaceMaskType)[0];
|
|
|
if (!workMask) return;
|
|
|
workMask.set("opacity", opacity.value);
|
|
|
canvas.renderAll();
|
|
|
@@ -411,15 +418,18 @@ const changeMaskOpacity = () => {
|
|
|
.icon-btn {
|
|
|
cursor: pointer;
|
|
|
}
|
|
|
+
|
|
|
.canvas-design-panel {
|
|
|
user-select: none;
|
|
|
}
|
|
|
+
|
|
|
.row {
|
|
|
width: 100%;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
margin-bottom: 10px;
|
|
|
}
|
|
|
+
|
|
|
.title {
|
|
|
margin-bottom: 10px;
|
|
|
}
|
|
|
@@ -430,6 +440,7 @@ const changeMaskOpacity = () => {
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
}
|
|
|
+
|
|
|
.slider-name {
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
@@ -438,6 +449,7 @@ const changeMaskOpacity = () => {
|
|
|
.mb-10 {
|
|
|
margin-bottom: 10px;
|
|
|
}
|
|
|
+
|
|
|
.full-row {
|
|
|
flex: 1;
|
|
|
width: 100%;
|
|
|
@@ -446,6 +458,7 @@ const changeMaskOpacity = () => {
|
|
|
.full-group {
|
|
|
display: flex;
|
|
|
flex: 1;
|
|
|
+
|
|
|
.el-button {
|
|
|
width: 50%;
|
|
|
}
|
|
|
@@ -454,9 +467,11 @@ const changeMaskOpacity = () => {
|
|
|
.full-ratio {
|
|
|
display: flex;
|
|
|
flex: 1;
|
|
|
+
|
|
|
.el-radio-button {
|
|
|
width: 50%;
|
|
|
}
|
|
|
+
|
|
|
.el-radio-button__inner {
|
|
|
width: 100%;
|
|
|
}
|
|
|
@@ -491,6 +506,7 @@ const changeMaskOpacity = () => {
|
|
|
.theme-list {
|
|
|
@include flex-grid-layout();
|
|
|
}
|
|
|
+
|
|
|
.theme-item {
|
|
|
@include flex-grid-layout-children(2, 48%);
|
|
|
|
|
|
@@ -512,9 +528,11 @@ const changeMaskOpacity = () => {
|
|
|
.text {
|
|
|
font-size: 16px;
|
|
|
}
|
|
|
+
|
|
|
.colors {
|
|
|
display: flex;
|
|
|
}
|
|
|
+
|
|
|
.color-block {
|
|
|
margin-top: 8px;
|
|
|
width: 12px;
|
|
|
@@ -535,6 +553,7 @@ const changeMaskOpacity = () => {
|
|
|
display: none;
|
|
|
background-color: rgba($color: #000, $alpha: 0.25);
|
|
|
}
|
|
|
+
|
|
|
.btn {
|
|
|
width: 72px;
|
|
|
padding: 5px 0;
|
|
|
@@ -569,12 +588,15 @@ const changeMaskOpacity = () => {
|
|
|
:deep(.el-input .el-input-group__prepend) {
|
|
|
padding: 0 5px;
|
|
|
}
|
|
|
+
|
|
|
:deep(.el-input .el-input-group__append) {
|
|
|
padding: 0 5px;
|
|
|
}
|
|
|
+
|
|
|
:deep(.full-ratio .el-radio-button__inner) {
|
|
|
width: 100%;
|
|
|
}
|
|
|
+
|
|
|
:deep(.size-row .el-input-group__prepend) {
|
|
|
min-width: 24px;
|
|
|
}
|