偏移X
@@ -105,10 +105,10 @@
const convertDotNotationToBracket = (str) =>
str.replace(/(?:^|\.)(\d+)(?=\.|$)/g, "[#$1]").replace(/\[#/g, "[");
- const activeId = ref("1");
+ const activeToken = ref("1");
const list = ref([
{
- id: "1",
+ token: "1",
ifSingle: false,
level2Type: "Pattern",
designType: "Library",
@@ -133,7 +133,7 @@
},
},
{
- id: "2",
+ token: "2",
ifSingle: false,
level2Type: "Pattern",
designType: "Library",
@@ -163,42 +163,35 @@
const oldList = ref(deepCopy(list.value));
const pingpuRef = ref(null);
const updateCanvas = (arr) => {
+ console.log(arr);
oldList.value = deepCopy(list.value);
arr.forEach((item) => {
- list.value.forEach((v) => {
+ const obj = list.value.find((v) => v.token === item.token);
+ if (item.action === ACTIONS.UPDATE) {
if (item.action === ACTIONS.UPDATE) {
- if (v.id === item.id) {
- if (item.action === ACTIONS.UPDATE) {
- try {
- const key = item.key;
- const str = /^\[/.test(item.key)
- ? "v" + key
- : "v." + key;
- eval(`${str} = item.value`);
- } catch (error) {
- console.error(error);
- }
- }
+ try {
+ const key = item.key;
+ const str = /^\[/.test(item.key)
+ ? "obj" + key
+ : "obj." + key;
+ eval(`${str} = item.value`);
+ } catch (error) {
+ console.error(error);
}
- } else if (item.action === ACTIONS.SELECT) {
- activeId.value = item.id;
}
- });
+ } else if (item.action === ACTIONS.SELECT) {
+ activeToken.value = item.token;
+ }
});
};
- const onSelect = (id) => {
- activeId.value = id;
- pingpuRef.value.updataList([
- {
- id: id,
- action: ACTIONS.SELECT,
- },
- ]);
+ const onSelect = (token) => {
+ activeToken.value = token;
+ pingpuRef.value.updataList([{ token, action: ACTIONS.SELECT }]);
};
- const onMove = (id, id2) => {
- const obj1 = list.value.find((v) => v.id === id);
- const obj2 = list.value.find((v) => v.id === id2);
+ const onMove = (token1, token2) => {
+ const obj1 = list.value.find((v) => v.token === token1);
+ const obj2 = list.value.find((v) => v.token === token2);
const index1 = list.value.indexOf(obj1);
const index2 = list.value.indexOf(obj2);
if (index1 < index2) {
@@ -206,26 +199,16 @@
} else {
list.value.splice(index1, 0, list.value.splice(index2, 1)[0]);
}
- const ids = list.value.map((v) => v.id);
- pingpuRef.value.updataList([
- {
- action: ACTIONS.SORT,
- ids,
- },
- ]);
+ const tokens = list.value.map((v) => v.token);
+ pingpuRef.value.updataList([{ action: ACTIONS.SORT, tokens }]);
};
- const onDelete = (id) => {
- list.value = list.value.filter((v) => v.id !== id);
- pingpuRef.value.updataList([
- {
- id: id,
- action: ACTIONS.DELETE,
- },
- ]);
+ const onDelete = (token) => {
+ list.value = list.value.filter((v) => v.token !== token);
+ pingpuRef.value.updataList([{ token, action: ACTIONS.DELETE }]);
};
const onAdd = () => {
const obj = {
- id: Date.now().toString(),
+ token: Date.now().toString(),
ifSingle: false,
level2Type: "Pattern",
designType: "Library",
@@ -250,12 +233,7 @@
},
};
list.value.push(obj);
- pingpuRef.value.updataList([
- {
- action: ACTIONS.ADD,
- data: obj,
- },
- ]);
+ pingpuRef.value.updataList([{ action: ACTIONS.ADD, data: obj }]);
};
watch(
() => list.value,
@@ -266,20 +244,20 @@
const updateList = () => {
const changeList = [];
oldList.value.forEach((oldItem) => {
- const newItem = list.value.find((v) => v.id === oldItem.id);
+ const newItem = list.value.find((v) => v.token === oldItem.token);
if (newItem) {
const arr = findDiffProps(oldItem, newItem);
arr.forEach((item) => {
changeList.push({
...item,
- id: oldItem.id,
+ token: oldItem.token,
action: ACTIONS.UPDATE,
key: convertDotNotationToBracket(item.key),
});
});
} else {
changeList.push({
- id: oldItem.id,
+ token: oldItem.token,
action: ACTIONS.DELETE,
});
}
diff --git a/src/component/Canvas/OverallCanvas/index.vue b/src/component/Canvas/OverallCanvas/index.vue
index a73ec8a5..93242d6e 100644
--- a/src/component/Canvas/OverallCanvas/index.vue
+++ b/src/component/Canvas/OverallCanvas/index.vue
@@ -1,5 +1,5 @@
-
+
diff --git a/src/component/Detail/detailRight/overallSetting/tools/AngleTool.vue b/src/component/Detail/detailRight/overallSetting/tools/AngleTool.vue
index c024a38e..1c6ae025 100644
--- a/src/component/Detail/detailRight/overallSetting/tools/AngleTool.vue
+++ b/src/component/Detail/detailRight/overallSetting/tools/AngleTool.vue
@@ -1,38 +1,73 @@
-