|
@@ -10,11 +10,13 @@
|
|
<t-icon name="save" @click="save(SaveType.Save)" /></t-badge
|
|
<t-icon name="save" @click="save(SaveType.Save)" /></t-badge
|
|
></a>
|
|
></a>
|
|
</t-tooltip>
|
|
</t-tooltip>
|
|
- <t-tooltip content="保存为模板" placement="bottom">
|
|
|
|
|
|
+ <t-tooltip content="保存为我的组件" placement="bottom">
|
|
<a><t-icon name="layers" @click="save(SaveType.Save, true)" /></a>
|
|
<a><t-icon name="layers" @click="save(SaveType.Save, true)" /></a>
|
|
</t-tooltip>
|
|
</t-tooltip>
|
|
<t-tooltip content="格式化" placement="bottom">
|
|
<t-tooltip content="格式化" placement="bottom">
|
|
- <a>
|
|
|
|
|
|
+ <a @click="oneFormat" @dblclick="alwaysFormat" :style="{
|
|
|
|
+ color:(one||always)?' #1677ff':''
|
|
|
|
+ }">
|
|
<svg
|
|
<svg
|
|
width="1em"
|
|
width="1em"
|
|
height="1em"
|
|
height="1em"
|
|
@@ -38,7 +40,7 @@
|
|
</a>
|
|
</a>
|
|
</t-tooltip>
|
|
</t-tooltip>
|
|
<t-tooltip content="清除格式" placement="bottom">
|
|
<t-tooltip content="清除格式" placement="bottom">
|
|
- <a>
|
|
|
|
|
|
+ <a @click="clearFormat">
|
|
<svg
|
|
<svg
|
|
width="1em"
|
|
width="1em"
|
|
height="1em"
|
|
height="1em"
|
|
@@ -104,7 +106,7 @@
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
import { Meta2d, Options, Pen } from '@meta2d/core';
|
|
import { Meta2d, Options, Pen } from '@meta2d/core';
|
|
-import { onMounted, onUnmounted, watch } from 'vue';
|
|
|
|
|
|
+import { onMounted, onUnmounted, watch,ref } from 'vue';
|
|
import { registerBasicDiagram } from '@/services/register';
|
|
import { registerBasicDiagram } from '@/services/register';
|
|
import { useRouter, useRoute } from 'vue-router';
|
|
import { useRouter, useRoute } from 'vue-router';
|
|
import { useUser } from '@/services/user';
|
|
import { useUser } from '@/services/user';
|
|
@@ -112,6 +114,7 @@ import { getLe5le2d } from '@/services/api';
|
|
import { useDot } from '@/services/common';
|
|
import { useDot } from '@/services/common';
|
|
import { save, newFile } from './Header.vue';
|
|
import { save, newFile } from './Header.vue';
|
|
import { useSelection, SelectionMode } from '@/services/selections';
|
|
import { useSelection, SelectionMode } from '@/services/selections';
|
|
|
|
+import {defaultFormat} from '@/services/defaults'
|
|
|
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
const route = useRoute();
|
|
const route = useRoute();
|
|
@@ -127,6 +130,7 @@ const meta2dOptions: Options = {
|
|
y: 32,
|
|
y: 32,
|
|
width: 1920,
|
|
width: 1920,
|
|
height: 1080,
|
|
height: 1080,
|
|
|
|
+ defaultFormat:{...defaultFormat}
|
|
};
|
|
};
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
meta2d = new Meta2d('meta2d', meta2dOptions);
|
|
meta2d = new Meta2d('meta2d', meta2dOptions);
|
|
@@ -136,6 +140,7 @@ onMounted(() => {
|
|
meta2d.on('active', active);
|
|
meta2d.on('active', active);
|
|
// @ts-ignore
|
|
// @ts-ignore
|
|
meta2d.on('inactive', inactive);
|
|
meta2d.on('inactive', inactive);
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
|
|
const watcher = watch(
|
|
const watcher = watch(
|
|
@@ -187,6 +192,12 @@ const active = (oldPens: Pen[]) => {
|
|
checkPropType(pens);
|
|
checkPropType(pens);
|
|
selections.pens = oldPens;
|
|
selections.pens = oldPens;
|
|
}, 10);
|
|
}, 10);
|
|
|
|
+
|
|
|
|
+ //格式刷处理
|
|
|
|
+ if (one.value||always.value) {
|
|
|
|
+ meta2d.formatPainter();
|
|
|
|
+ one.value = false;
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -205,6 +216,32 @@ const checkPropType = (pens: Pen[]) => {
|
|
selections.mode = SelectionMode.File;
|
|
selections.mode = SelectionMode.File;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+
|
|
|
|
+const one = ref(false);
|
|
|
|
+const always = ref(false);
|
|
|
|
+
|
|
|
|
+const oneFormat = () => {
|
|
|
|
+ if (one.value) {
|
|
|
|
+ one.value = false
|
|
|
|
+ } else {
|
|
|
|
+ one.value = true;
|
|
|
|
+ meta2d.setFormatPainter();
|
|
|
|
+ }
|
|
|
|
+ if (always.value) {
|
|
|
|
+ always.value = false;
|
|
|
|
+ one.value = false
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const alwaysFormat = () => {
|
|
|
|
+ always.value = true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const clearFormat = () => {
|
|
|
|
+ always.value = false;
|
|
|
|
+ one.value = false
|
|
|
|
+ meta2d.clearFormatPainter();
|
|
|
|
+}
|
|
</script>
|
|
</script>
|
|
<style lang="postcss" scoped>
|
|
<style lang="postcss" scoped>
|
|
.meta2d {
|
|
.meta2d {
|