diff --git a/package.json b/package.json
index c7275f2..e0d6e59 100644
--- a/package.json
+++ b/package.json
@@ -19,10 +19,12 @@
"@antv/x6-plugin-transform": "^2.1.8",
"@antv/x6-vue-shape": "^2.1.2",
"@element-plus/icons-vue": "^2.3.1",
+ "@highlightjs/vue-plugin": "^2.1.0",
"@kjgl77/datav-vue3": "^1.7.3",
"axios": "^1.7.2",
"echarts": "^5.6.0",
"element-plus": "^2.9.5",
+ "highlight.js": "^11.11.1",
"insert-css": "^2.0.0",
"lib-flexible": "^0.3.2",
"pinia": "^2.1.7",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 11ad3e4..d641ff1 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -38,6 +38,9 @@ importers:
'@element-plus/icons-vue':
specifier: ^2.3.1
version: 2.3.1(vue@3.4.29(typescript@5.2.2))
+ '@highlightjs/vue-plugin':
+ specifier: ^2.1.0
+ version: 2.1.0(highlight.js@11.11.1)(vue@3.4.29(typescript@5.2.2))
'@kjgl77/datav-vue3':
specifier: ^1.7.3
version: 1.7.3(vue@3.4.29(typescript@5.2.2))
@@ -50,6 +53,9 @@ importers:
element-plus:
specifier: ^2.9.5
version: 2.9.5(vue@3.4.29(typescript@5.2.2))
+ highlight.js:
+ specifier: ^11.11.1
+ version: 11.11.1
insert-css:
specifier: ^2.0.0
version: 2.0.0
@@ -344,6 +350,12 @@ packages:
'@floating-ui/utils@0.2.9':
resolution: {integrity: sha512-MDWhGtE+eHw5JW7lq4qhc5yRLS11ERl1c7Z6Xd0a58DozHES6EnNNwUWbMiG4J9Cgj053Bhk8zvlhFYKVhULwg==}
+ '@highlightjs/vue-plugin@2.1.0':
+ resolution: {integrity: sha512-E+bmk4ncca+hBEYRV2a+1aIzIV0VSY/e5ArjpuSN9IO7wBJrzUE2u4ESCwrbQD7sAy+jWQjkV5qCCWgc+pu7CQ==}
+ peerDependencies:
+ highlight.js: ^11.0.1
+ vue: ^3
+
'@jiaminghi/bezier-curve@0.0.9':
resolution: {integrity: sha512-u9xJPOEl6Dri2E9FfmJoGxYQY7vYJkURNX04Vj64tdi535tPrpkuf9Sm0lNr3QTKdHQh0DdNRsaa62FLQNQEEw==}
@@ -772,6 +784,10 @@ packages:
resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==}
hasBin: true
+ highlight.js@11.11.1:
+ resolution: {integrity: sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w==}
+ engines: {node: '>=12.0.0'}
+
htmlparser2@8.0.2:
resolution: {integrity: sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==}
@@ -1362,6 +1378,11 @@ snapshots:
'@floating-ui/utils@0.2.9': {}
+ '@highlightjs/vue-plugin@2.1.0(highlight.js@11.11.1)(vue@3.4.29(typescript@5.2.2))':
+ dependencies:
+ highlight.js: 11.11.1
+ vue: 3.4.29(typescript@5.2.2)
+
'@jiaminghi/bezier-curve@0.0.9':
dependencies:
'@babel/runtime': 7.24.7
@@ -1847,6 +1868,8 @@ snapshots:
he@1.2.0: {}
+ highlight.js@11.11.1: {}
+
htmlparser2@8.0.2:
dependencies:
domelementtype: 2.3.0
diff --git a/src/api/index.ts b/src/api/index.ts
index 3879b01..9b23e72 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1,14 +1,38 @@
-import request from '@/utils/request'
+import request from "@/utils/request";
export const login = (data: any) => {
- return request({
- url: '/sys/login',
- method: 'post',
- data
- })
-}
+ return request({
+ url: "/sys/login",
+ method: "post",
+ data,
+ });
+};
export const getCode = (time: any) => {
- return request({
- url: '/sys/randomImage/' + time,
- })
- }
\ No newline at end of file
+ return request({
+ url: "/sys/randomImage/" + time,
+ });
+};
+// 获取用户信息
+export const getUserInfo = () => {
+ return request({
+ url: "/sys/user/getUserInfo",
+ method: "get",
+ });
+};
+
+// 实验步骤
+export const setStep = (params: any) => {
+ return request({
+ url: "/experimentrecords/xnExperimentRecords/check",
+ method: "get",
+ params
+ })
+}
+// 获取步骤id
+export const getStepId = () => {
+ return request({
+ url: "/experimentrecords/xnExperimentRecords/getProcedureList",
+ method: "get",
+
+ })
+}
\ No newline at end of file
diff --git a/src/assets/images/idea.png b/src/assets/images/idea.png
new file mode 100644
index 0000000..c6b88c6
Binary files /dev/null and b/src/assets/images/idea.png differ
diff --git a/src/main.ts b/src/main.ts
index e979875..21fcf3a 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -7,7 +7,14 @@ import 'element-plus/dist/index.css'; // 引入 Element Plus 的样式文件
import '@/utils/rem.js'
import DataVVue3 from '@kjgl77/datav-vue3'
import pinia from '@/store/index'
+//引入依赖和语言
+import 'highlight.js/styles/stackoverflow-light.css'
+// import hljs from "highlight.js/lib/core";
+// import hljsVuePlugin from "@highlightjs/vue-plugin";
+// import java from "highlight.js/lib/languages/java";
const app = createApp(App)
+// hljs.registerLanguage("java", java);
+// app.use(hljsVuePlugin);
app.use(ElementPlus)
app.use(pinia)
app.use(DataVVue3)
diff --git a/src/permissions.ts b/src/permissions.ts
index 3bc2aa0..fa9a430 100644
--- a/src/permissions.ts
+++ b/src/permissions.ts
@@ -14,10 +14,19 @@ router.beforeEach((to: any, from: any, next: any) => {
} else {
const token = getToken();
if (token) {
- next();
+ console.log(store.userInfo);
+
+ if (store.userInfo) {
+ next();
+ } else {
+ store.getUserInfo().then(() => {
+ next();
+ });
+ }
+ // next();
} else {
next("/login");
}
}
});
-export default router;
\ No newline at end of file
+export default router;
diff --git a/src/router/index.ts b/src/router/index.ts
index 8d73740..73e7f74 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -19,7 +19,12 @@ const routerList: any = [
path: "program",
name: "Program",
component: () => import("@/views/program/index.vue"),
- }
+ },
+ {
+ path: "compiler",
+ name: "Compiler",
+ component: () => import("@/views/compiler/index.vue"),
+ },
],
},
{
diff --git a/src/store/modules/setting.ts b/src/store/modules/setting.ts
index f86ce30..74494ec 100644
--- a/src/store/modules/setting.ts
+++ b/src/store/modules/setting.ts
@@ -16,6 +16,11 @@ const settingStore = defineStore("settingStore", {
sdsz: 0, // 湿度数值
falg: false,
timer: null,
+ experimentPreservation: false, // 是否设计好实验
+ saveRoute: false, // 是否保存路由
+ stepIds: null,
+ wenduCode: null,
+ shiduCode:null
};
},
actions: {
@@ -27,7 +32,7 @@ const settingStore = defineStore("settingStore", {
this.qw = value;
},
- setValue(value: number, name: string) {
+ setValue(value: number | boolean, name: string) {
this[name] = value;
},
openHeating() {
@@ -46,7 +51,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;
@@ -61,6 +66,40 @@ const settingStore = defineStore("settingStore", {
clearInterval(interval);
}
+ time += 1; // 每秒增加 1s
+ }, 1000);
+ },
+ simulateHeatingAndHumidifying() {
+ // 计算时间常数
+ const a = (100000 * this.zl * this.srmj) / this.jrgl;
+ const b = (10000 * this.jsmj) / this.jsgl;
+
+ let time = 0;
+ let currentTemp = this.qw;
+ let currentHumidity = this.cssd;
+
+ const interval = setInterval(() => {
+ // 计算温度
+ currentTemp = (1 - Math.exp(-time / a)) * 100 + this.qw;
+ if (currentTemp > 100) currentTemp = 100;
+
+ // 计算湿度
+ currentHumidity = (1 - Math.exp(-time / b)) * 100 + this.cssd;
+ if (currentHumidity > 100) currentHumidity = 100;
+
+ console.log(
+ `时间: ${time}s, 温度: ${currentTemp.toFixed(
+ 2
+ )}°C, 湿度: ${currentHumidity}%RH`
+ );
+ this.qw = currentTemp >= 100 ? 100 : currentTemp;
+ this.cssd = currentHumidity >= 100 ? 100 : Number(currentHumidity.toFixed(2));
+ // 停止加热 & 加湿
+ if (currentTemp >= 100 && currentHumidity >= 100) {
+ console.log("温度和湿度均达到上限,停止模拟!");
+ clearInterval(interval);
+ }
+
time += 1; // 每秒增加 1s
}, 1000);
},
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index a2c0c45..6b37de5 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -1,30 +1,37 @@
import { defineStore } from "pinia";
-import { getToken,setToken } from "@/utils/auth";
-import { login } from "@/api";
+import { getToken, setToken } from "@/utils/auth";
+import { login, getUserInfo } from "@/api";
import { ElMessage } from "element-plus";
const userStore = defineStore("userStore", {
state: () => ({
token: getToken(),
- userInfo: {},
+ userInfo: null,
}),
actions: {
async logIn(form: any) {
console.log(form);
const res: any = await login(form);
// if(res.code === 500) return ElMessage.error(res.msg)
- if(res.code !== 200) {
- ElMessage.error(res.msg)
- return false
+ if (res.code !== 200) {
+ ElMessage.error(res.msg);
+ return false;
}
this.token = res.result.token;
this.userInfo = res.result.userInfo;
setToken(this.token);
console.log(res);
- return true
+ return true;
},
clearStatus() {
this.token = "";
- this.userInfo = {};
+ this.userInfo = null;
+ },
+ async getUserInfo() {
+ const res:any = await getUserInfo();
+ this.userInfo = res.result.userInfo;
+ console.log(res);
+
+ // this.userInfo = res.result;
},
},
});
diff --git a/src/utils/index.ts b/src/utils/index.ts
new file mode 100644
index 0000000..8c8eebe
--- /dev/null
+++ b/src/utils/index.ts
@@ -0,0 +1,12 @@
+// 格式化时间 年月日时分秒
+export function formatDate(date: any) {
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, "0");
+ const day = String(date.getDate()).padStart(2, "0");
+ const hours = String(date.getHours()).padStart(2, "0");
+ const minutes = String(date.getMinutes()).padStart(2, "0");
+ const seconds = String(date.getSeconds()).padStart(2, "0");
+ console.log(`${year}-${month}-${day} ${hours}:${minutes}:${seconds}`);
+
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+}
\ No newline at end of file
diff --git a/src/utils/setStep.ts b/src/utils/setStep.ts
new file mode 100644
index 0000000..14b1391
--- /dev/null
+++ b/src/utils/setStep.ts
@@ -0,0 +1,16 @@
+import { setStep, getStepId } from "../api/index";
+import settingStore from "../store/modules/setting";
+import pinia from "@/store";
+const useStore = settingStore(pinia);
+export const setStepEvent = async (step: number, controlsSt: string) => {
+ let id: any = null;
+ if (!useStore.stepIds) {
+ const data: any = await getStepId();
+ useStore.stepIds = data.result.map((item: any) => item.id);
+ id = useStore.stepIds[step - 1];
+ // return id;
+ await setStep({ id, controlsSt });
+ } else {
+ await setStep({ id: useStore.stepIds[step - 1], controlsSt });
+ }
+};
diff --git a/src/views/compiler/index.vue b/src/views/compiler/index.vue
new file mode 100644
index 0000000..d88adbf
--- /dev/null
+++ b/src/views/compiler/index.vue
@@ -0,0 +1,77 @@
+
+