diff --git a/src/assets/images/chengxv.png b/src/assets/images/chengxv.png
new file mode 100644
index 0000000..03cf3f2
Binary files /dev/null and b/src/assets/images/chengxv.png differ
diff --git a/src/store/modules/setting.ts b/src/store/modules/setting.ts
index bd44b28..f86ce30 100644
--- a/src/store/modules/setting.ts
+++ b/src/store/modules/setting.ts
@@ -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;
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
new file mode 100644
index 0000000..b1e6a68
--- /dev/null
+++ b/src/store/modules/user.ts
@@ -0,0 +1,14 @@
+import { defineStore } from "pinia";
+import { getToken } from "@/utils/auth";
+const userStore = defineStore("userStore", {
+ state: () => ({
+ token: getToken(),
+ userInfo: {},
+ }),
+ actions: {
+ async logIn(){
+
+ }
+ },
+});
+export default userStore;
diff --git a/src/utils/setToken.ts b/src/utils/setToken.ts
new file mode 100644
index 0000000..569c0a5
--- /dev/null
+++ b/src/utils/setToken.ts
@@ -0,0 +1,11 @@
+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,
+};
diff --git a/src/views/designRoute/index.vue b/src/views/designRoute/index.vue
index b58a403..2e67c55 100644
--- a/src/views/designRoute/index.vue
+++ b/src/views/designRoute/index.vue
@@ -35,7 +35,7 @@
@@ -1031,7 +1128,5 @@ const onTip = () => {
height: 753px !important;
}
.tip-view {
-
-
}
diff --git a/src/views/program/index.vue b/src/views/program/index.vue
index 22b2740..71d8994 100644
--- a/src/views/program/index.vue
+++ b/src/views/program/index.vue
@@ -42,7 +42,24 @@
撤回
恢复
+ 清除缓存
运行
+ 提示
+
+
+
+
@@ -62,6 +79,8 @@ 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);
@@ -71,6 +90,7 @@ const falg = ref(false);
let graph: any = null;
const nodeName = ref("");
const csedNode = ref(null);
+const operations = [];
onMounted(() => {
preWork();
@@ -199,11 +219,23 @@ onMounted(() => {
// },
// ]);
});
- graph.on("node:mouseenter", ({ cell }: any) => {
- // console.log(cell);
- if (cell.shape === "deom") return;
- if (cell.label.includes(":")) return;
- cell.label = cell.label + ":";
+
+ 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);
});
// #region 初始化 stencil
const stencil = new Stencil({
@@ -369,8 +401,8 @@ onMounted(() => {
shape: "yibiao",
width: 350,
height: 300,
- x: 1100,
- y: 300,
+ x: 1050,
+ y: 350,
});
// #endregion
@@ -990,6 +1022,8 @@ onMounted(() => {
],
"group1"
);
+ restoreGraph();
+ // clearLocalStorage()
});
// 控制抽屉显示
const drawerVisible = ref(false);
@@ -1008,13 +1042,14 @@ const saveNodeData = () => {
// console.log(nodeName.value);
if (node) {
- node.setAttrs({
- label: selectedNodeData.value.label,
- // body: {
- // width: selectedNodeData.value.width,
- // height: selectedNodeData.value.height,
- // },
- });
+ // node.setAttrs({
+
+ // text: selectedNodeData.value.label,
+ // // body: {
+ // // width: selectedNodeData.value.width,
+ // // height: selectedNodeData.value.height,
+ // // },
+ // });
node.label = selectedNodeData.value.label;
}
drawerVisible.value = false;
@@ -1105,8 +1140,42 @@ const onRedo = () => {
};
const sdsz = ref(null);
const onSave = () => {
- console.log(graph.getNodes());
+ // 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);
+ localStorage.setItem(SESSION_KEY, JSON.stringify(data));
if (
!hasExactNames(graph.getNodes(), [
"custom-text",
@@ -1165,6 +1234,39 @@ 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);
+};