Compare commits

..

No commits in common. '18a5adc925410316a7f976a04a7f572d3d9d9766' and '0300220d28c477b03e92f97b1825c6539a467b41' have entirely different histories.

  1. BIN
      src/assets/images/chengxv.png
  2. 2
      src/store/modules/setting.ts
  3. 14
      src/store/modules/user.ts
  4. 11
      src/utils/setToken.ts
  5. 123
      src/views/designRoute/index.vue
  6. 132
      src/views/program/index.vue

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 KiB

@ -46,7 +46,7 @@ const settingStore = defineStore("settingStore", {
}
},
calculateTemperature() {
this.qw <= 0 ? this.qw=1 : this.qw;
this.qw >= 0 ? this.qw=1 : this.qw;
const a = (100000 * this.zl * this.srmj) / this.jrgl;
let time = 0;
let currentTemp = this.qw;

@ -1,14 +0,0 @@
import { defineStore } from "pinia";
import { getToken } from "@/utils/auth";
const userStore = defineStore("userStore", {
state: () => ({
token: getToken(),
userInfo: {},
}),
actions: {
async logIn(){
}
},
});
export default userStore;

@ -1,11 +0,0 @@
const TOKEN_KEY:string = "token";
const setToken = (token: string): void => {
localStorage.setItem(TOKEN_KEY, token);
};
const getToken = () => localStorage.getItem(TOKEN_KEY) || "";
const removeToken = () => localStorage.removeItem(TOKEN_KEY);
export default {
setToken,
getToken,
removeToken,
};

@ -35,7 +35,7 @@
<script setup>
import { Graph, Shape } from "@antv/x6";
import { onMounted, ref } from "vue";
import { onMounted,ref } from "vue";
import { History } from "@antv/x6-plugin-history";
import wenduZK from "./components/wenduZK.vue";
import shiduZK from "./components/shiduZK.vue";
@ -68,7 +68,7 @@ import wenduValueSetting from "./components/wenduValueSetting.vue";
import shiduValueSetting from "./components/shiduValueSetting.vue";
import setzijie from "./components/setzijie.vue";
import { ElMessage } from "element-plus";
import tipView from "@/assets/images/guanxitu.png";
import tipView from '@/assets/images/guanxitu.png';
let graph = null;
//
@ -164,13 +164,9 @@ onMounted(() => {
zIndex: 0,
});
},
validateConnection({ sourceCell, targetCell }) {
//
if (sourceCell && targetCell && sourceCell.id === targetCell.id) {
return false;
}
return true;
}
validateConnection({ targetMagnet }) {
return !!targetMagnet; //
},
},
highlighting: {
magnetAdsorbed: {
@ -278,7 +274,6 @@ onMounted(() => {
//
graph.addNode({
shape: "custom-vue-node-wenduValueSetting",
id: "1",
width: 40,
height: 40,
x: 30,
@ -292,7 +287,6 @@ onMounted(() => {
// 湿
graph.addNode({
shape: "custom-vue-node-shiduValueSetting",
id: "2",
width: 40,
height: 40,
x: 30,
@ -306,7 +300,6 @@ onMounted(() => {
//
graph.addNode({
shape: "custom-vue-node",
id: "3",
width: 120,
height: 100,
x: 120,
@ -326,7 +319,6 @@ onMounted(() => {
// 1
graph.addNode({
shape: "custom-vue-node-wenBenYu",
id:'32',
width: 210,
height: 300,
x: 320,
@ -347,7 +339,6 @@ onMounted(() => {
// 湿
graph.addNode({
shape: "custom-vue-node-sd",
id: "4",
width: 110,
height: 84,
x: 120,
@ -366,7 +357,6 @@ onMounted(() => {
// 2
graph.addNode({
shape: "custom-vue-node-wenBenYu2",
id:'33',
width: 210,
height: 300,
x: 400,
@ -385,7 +375,6 @@ onMounted(() => {
// I
graph.addNode({
shape: "custom-vue-node-I",
id: "5",
width: 40,
height: 40,
x: 50,
@ -401,7 +390,6 @@ onMounted(() => {
// number101
graph.addNode({
shape: "custom-vue-node-number10",
id: "6",
width: 40,
height: 40,
x: 150,
@ -414,7 +402,6 @@ onMounted(() => {
// number102
graph.addNode({
shape: "custom-vue-node-number10",
id: "7",
width: 40,
height: 40,
x: 150,
@ -427,7 +414,6 @@ onMounted(() => {
// 1
graph.addNode({
shape: "custom-vue-node-sanjiao",
id: "8",
width: 40,
height: 40,
x: 230,
@ -444,7 +430,6 @@ onMounted(() => {
// 2
graph.addNode({
shape: "custom-vue-node-sanjiao",
id: "9",
width: 40,
height: 40,
x: 230,
@ -461,7 +446,6 @@ onMounted(() => {
// 湿
graph.addNode({
shape: "custom-vue-node-shiduNumber",
id: "10",
width: 40,
height: 40,
x: 630,
@ -475,7 +459,6 @@ onMounted(() => {
//
graph.addNode({
shape: "custom-vue-node-wenduNumber",
id: "11",
width: 40,
height: 40,
x: 600,
@ -488,7 +471,6 @@ onMounted(() => {
//
graph.addNode({
shape: "custom-vue-node-Wenduji",
id: "12",
width: 40,
height: 40,
x: 620,
@ -502,7 +484,6 @@ onMounted(() => {
//
graph.addNode({
shape: "custom-vue-node-zhuanhuanqi",
id: "13",
width: 40,
height: 40,
x: 670,
@ -519,7 +500,6 @@ onMounted(() => {
// 2
graph.addNode({
shape: "custom-vue-node-number2",
id: "14",
width: 20,
height: 30,
x: 600,
@ -532,7 +512,6 @@ onMounted(() => {
//
graph.addNode({
shape: "custom-vue-node-wendu",
id: "15",
width: 60,
height: 20,
x: 750,
@ -545,7 +524,6 @@ onMounted(() => {
// 2
graph.addNode({
shape: "custom-vue-node-zhuanhuanqi",
id: "16",
width: 40,
height: 40,
x: 700,
@ -562,7 +540,6 @@ onMounted(() => {
// 22
graph.addNode({
shape: "custom-vue-node-number2",
id: "17",
width: 20,
height: 30,
x: 650,
@ -575,7 +552,6 @@ onMounted(() => {
//
graph.addNode({
shape: "custom-vue-node-wenduYibiao",
id: "18",
width: 40,
height: 40,
x: 759,
@ -588,7 +564,6 @@ onMounted(() => {
// RH
graph.addNode({
shape: "custom-vue-node-RH",
id: "19",
width: 50,
height: 20,
x: 800,
@ -601,7 +576,6 @@ onMounted(() => {
//
graph.addNode({
shape: "custom-vue-node-dianchizu",
id: "20",
width: 40,
height: 70,
x: 880,
@ -622,7 +596,6 @@ onMounted(() => {
// 湿
graph.addNode({
shape: "custom-vue-node-shidu",
id: "21",
width: 60,
height: 20,
x: 750,
@ -635,7 +608,6 @@ onMounted(() => {
//
graph.addNode({
shape: "custom-vue-node-du",
id: "22",
width: 25,
height: 20,
x: 759,
@ -648,7 +620,6 @@ onMounted(() => {
//
graph.addNode({
shape: "custom-vue-node-booleanCopm",
id: "23",
width: 40,
height: 40,
x: 1300,
@ -661,7 +632,6 @@ onMounted(() => {
//
graph.addNode({
shape: "custom-vue-node-swatchComp",
id: "24",
width: 20,
height: 20,
x: 1350,
@ -674,7 +644,6 @@ onMounted(() => {
// IP
graph.addNode({
shape: "custom-vue-node-fuwiqiIP",
id: "25",
width: 40,
height: 40,
x: 950,
@ -687,7 +656,6 @@ onMounted(() => {
//
graph.addNode({
shape: "custom-vue-node-fuwuqiProt",
id: "26",
width: 40,
height: 40,
x: 950,
@ -700,7 +668,6 @@ onMounted(() => {
// TCP
graph.addNode({
shape: "custom-vue-node-openTCP",
id: "27",
width: 40,
height: 40,
x: 1050,
@ -718,7 +685,6 @@ onMounted(() => {
// TCP
graph.addNode({
shape: "custom-vue-node-setTCP",
id: "28",
width: 40,
height: 40,
x: 1150,
@ -738,7 +704,6 @@ onMounted(() => {
// TCP
graph.addNode({
shape: "custom-vue-node-setzijie",
id: "29",
width: 40,
height: 40,
x: 1300,
@ -751,7 +716,6 @@ onMounted(() => {
// TCP
graph.addNode({
shape: "custom-vue-node-TCP",
id: "30",
width: 40,
height: 40,
x: 1250,
@ -768,7 +732,6 @@ onMounted(() => {
//
graph.addNode({
shape: "custom-vue-node-errorComp",
id: "31",
width: 40,
height: 40,
x: 1400,
@ -793,28 +756,6 @@ onMounted(() => {
graph.canRedo();
graph.canUndo();
});
graph.on("edge:connected", ({ edge }) => {
const data = {
type: "add",
edge: edge.toJSON(), // toJSON port
};
saveToLocalStorage(data);
})
// 线
graph.on("edge:removed", ({ edge }) => {
const data = {
type: "remove",
id: edge.id,
};
saveToLocalStorage(data);
});
setTimeout(() => {
restoreGraph()
}, 1000);
graph.on('edge:added', ({ edge }) => {
console.log('新增连线数据:', edge.toJSON());
})
// const nodes = graph.getNodes();
// console.log(nodes);
// const data = graph.toJSON();
@ -831,8 +772,7 @@ const onRedo = () => {
graph.redo();
};
const onSave = () => {
if (standardData.length !== formatEdges().length)
return ElMessage.error("请完善数据");
if(standardData.length !== formatEdges().length) return ElMessage.error("请完善数据");
validateRelationships(standardData, formatEdges());
ElMessage.success("保存成功");
// const data = graph.toJSON();
@ -1059,11 +999,9 @@ function validateRelationships(correctAnswers, userRelationships) {
for (const relation of userRelationships) {
const key = `${relation.source}-${relation.target}`;
if (!correctSet.has(key)) {
console.log(graph.getEdges(relation.id));
graph.getEdges(relation.id)[0].color = "red";
ElMessage.error(
`错误的关系: source=${relation.source}, target=${relation.target}`
);
console.log( graph.getEdges(relation.id));
graph.getEdges(relation.id)[0].color = "red";
ElMessage.error(`错误的关系: source=${relation.source}, target=${relation.target}`);
throw new Error(
`错误的关系: source=${relation.source}, target=${relation.target}`
);
@ -1072,47 +1010,12 @@ function validateRelationships(correctAnswers, userRelationships) {
return true; //
}
const falg = false;
const falg = (false);
const preview = ref(null);
const onTip = () => {
preview.value.$el.children[0].click();
preview.value.$el.children[0].click()
console.log(preview.value);
};
function restoreGraph() {
const operations = loadFromLocalStorage();
//
operations
.filter(op => op.type === 'add' && op.node)
.forEach(op => graph.addNode(op.node));
// 线
operations
.filter(op => op.type === 'add' && op.edge)
.forEach(op => {
const edgeData = op.edge;
// port port ID
if (!edgeData.source.port) edgeData.source.port = "70";
if (!edgeData.target.port) edgeData.target.port = "70";
graph.addEdge(edgeData);
});
}
const SESSION_KEY = 'graph_operations1';
function saveToLocalStorage(data) {
const operations = JSON.parse(localStorage.getItem(SESSION_KEY)) || [];
operations.push(data);
localStorage.setItem(SESSION_KEY, JSON.stringify(operations));
}
function loadFromLocalStorage() {
return JSON.parse(localStorage.getItem(SESSION_KEY)) || [];
}
function clearLocalStorage() {
localStorage.removeItem(SESSION_KEY);
}
</script>
@ -1128,5 +1031,7 @@ function clearLocalStorage() {
height: 753px !important;
}
.tip-view {
}
</style>

@ -42,24 +42,7 @@
<div class="setting">
<el-button @click="onUndo">撤回</el-button>
<el-button @click="onRedo">恢复</el-button>
<el-button @click="clearLocalStorage">清除缓存</el-button>
<el-button @click="onSave">运行</el-button>
<el-button @click="onTip">提示</el-button>
</div>
<div class="tip-view">
<el-image
style="width: 0; height: 0"
:src="tipView"
:zoom-rate="1.2"
:max-scale="7"
:min-scale="0.2"
:preview-src-list="[tipView]"
show-progress
:initial-index="4"
fit="cover"
ref="preview"
/>
<!-- <img src="../../assets/images/guanxitu.png" alt=""> -->
</div>
</template>
@ -79,8 +62,6 @@ import { register, getTeleport } from "@antv/x6-vue-shape";
import settingStore from "@/store/modules/setting";
import Yibiao from "./components/yibiao.vue";
import { ElMessage } from "element-plus";
import tipView from "@/assets/images/chengxv.png";
const useSettingStore = settingStore();
// console.log(useSettingStore.qw);
@ -90,7 +71,6 @@ const falg = ref(false);
let graph: any = null;
const nodeName = ref("");
const csedNode = ref(null);
const operations = [];
onMounted(() => {
preWork();
@ -219,23 +199,11 @@ onMounted(() => {
// },
// ]);
});
graph.on("node:added", ({ node }) => {
const data = {
type: "add",
node: node.toJSON(),
};
operations.push(data);
saveToLocalStorage(data);
});
graph.on("node:removed", ({ node }) => {
const data = {
type: "remove",
id: node.id,
};
operations.push(data);
saveToLocalStorage(data);
graph.on("node:mouseenter", ({ cell }: any) => {
// console.log(cell);
if (cell.shape === "deom") return;
if (cell.label.includes(":")) return;
cell.label = cell.label + ":";
});
// #region stencil
const stencil = new Stencil({
@ -401,8 +369,8 @@ onMounted(() => {
shape: "yibiao",
width: 350,
height: 300,
x: 1050,
y: 350,
x: 1100,
y: 300,
});
// #endregion
@ -1022,8 +990,6 @@ onMounted(() => {
],
"group1"
);
restoreGraph();
// clearLocalStorage()
});
//
const drawerVisible = ref(false);
@ -1042,14 +1008,13 @@ const saveNodeData = () => {
// console.log(nodeName.value);
if (node) {
// node.setAttrs({
// text: selectedNodeData.value.label,
// // body: {
// // width: selectedNodeData.value.width,
// // height: selectedNodeData.value.height,
// // },
// });
node.setAttrs({
label: selectedNodeData.value.label,
// body: {
// width: selectedNodeData.value.width,
// height: selectedNodeData.value.height,
// },
});
node.label = selectedNodeData.value.label;
}
drawerVisible.value = false;
@ -1140,42 +1105,8 @@ const onRedo = () => {
};
const sdsz = ref(null);
const onSave = () => {
// console.log(graph.toJSON());
graph.toJSON().cells.forEach((item: any) => {
console.log(item);
switch (item.shape) {
case "custom-text":
useSettingStore.setValue(parseInt(item.attrs.text.text),item.name, );
break;
case "custom-text-zl":
useSettingStore.setValue(parseInt(item.attrs.text.text),item.name, );
break;
case "custom-text-srmj":
useSettingStore.setValue(parseInt(item.attrs.text.text),item.name, );
break;
case "custom-text-jrgl":
useSettingStore.setValue(parseInt(item.attrs.text.text),item.name, );
break;
case "custom-text-prot":
useSettingStore.setValue(parseInt(item.attrs.text.text),item.name, );
break;
case "custom-text-cssd":
useSettingStore.setValue(parseInt(item.attrs.text.text),item.name, );
break;
}
});
// return;
clearLocalStorage();
const data = graph.toJSON().cells.map((item: any) => {
return {
node: item,
type: "add",
};
});
console.log(data);
console.log(graph.getNodes());
localStorage.setItem(SESSION_KEY, JSON.stringify(data));
if (
!hasExactNames(graph.getNodes(), [
"custom-text",
@ -1234,39 +1165,6 @@ watch(
}
}
);
const SESSION_KEY = "graph_operations";
function saveToLocalStorage(data) {
const operations = JSON.parse(localStorage.getItem(SESSION_KEY)) || [];
operations.push(data);
localStorage.setItem(SESSION_KEY, JSON.stringify(operations));
}
function loadFromLocalStorage() {
return JSON.parse(localStorage.getItem(SESSION_KEY)) || [];
}
function clearLocalStorage() {
localStorage.removeItem(SESSION_KEY);
}
//
function restoreGraph() {
const operations = loadFromLocalStorage();
operations.forEach((op) => {
if (op.type === "add") {
graph.addNode(op.node);
} else if (op.type === "remove") {
const node = graph.getCellById(op.id);
if (node) graph.removeCell(node);
}
});
}
const preview = ref();
const onTip = () => {
preview.value.$el.children[0].click();
console.log(preview.value);
};
</script>
<style scoped>

Loading…
Cancel
Save