- - - - - - - - - + + +
+
+
+ + + +
+
用户账号
+
+
+ +
+
- +
+
+
+ + + +
+
用户密码
+
+
+ +
+
- +
+
+
+ + + +
+
确认密码
+
+
+ +
+
+
+ +
+
+
+ + + +
+
姓名
+
+
+ +
+
+
+ + +
+
+
+ + + +
+
班级
+
+
+ +
+
+
+ + +
+
+
+ + + +
+
学号
+
+
+ +
+
+
+ +
+
+
+ + + +
+
手机号
+
+
+ +
+
- +
+
+
+ + + +
+
验证码
+
+
+
+ +
+ +
+
+
+
+
+ + 注册 - + 返回到登录页 @@ -78,77 +156,87 @@
-->
- - + +
-
+
- +
用户名
- +
- - + +
+
+
+ + + +
+
学号
+
+
+ +
+
- - + +
+
+
+ + + +
+
密码
+
+
+ +
+
- -
- -
- + +
+
+
+ + + +
+
验证码
+
+
+
+ +
+ +
+
+ + - 登录 - 去注册 + 登录 + 去注册 @@ -161,11 +249,12 @@ 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 47f2ecd..75b9269 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 @@ + + + + + diff --git a/src/views/designRoute/components/wenBenYu.vue b/src/views/designRoute/components/wenBenYu.vue index 59dde09..80d423b 100644 --- a/src/views/designRoute/components/wenBenYu.vue +++ b/src/views/designRoute/components/wenBenYu.vue @@ -6,12 +6,31 @@
W
t
T
-