diff --git a/src/store/modules/setting.ts b/src/store/modules/setting.ts
index 4bf063d..b9a545d 100644
--- a/src/store/modules/setting.ts
+++ b/src/store/modules/setting.ts
@@ -28,7 +28,7 @@ const settingStore = defineStore("settingStore", {
isRunning: false,
isRunCode: Boolean(localStorage.getItem("isRunCode")) || false,
shiyanData: [],
- activeStepIndex:Number(localStorage.getItem('activeStepIndex')) || 0
+ activeStepIndex:Number(localStorage.getItem('activeStepIndex')) || 1
};
},
actions: {
diff --git a/src/views/compiler/index.vue b/src/views/compiler/index.vue
index 3f1ff66..659cc1e 100644
--- a/src/views/compiler/index.vue
+++ b/src/views/compiler/index.vue
@@ -1,15 +1,17 @@
-
-
-
- oisafkahsdkjfhasdf sdfhkjsahfdlkjas \n /n sldhfkajshfd salkdhflkasf asfasdf
-
+
- 保存
- 返回
+ 保存
+ 返回
+ 复制答案
@@ -20,18 +22,60 @@ import { setStepEvent } from "@/utils/setStep";
import { formatDate } from "@/utils";
import settingStore from "@/store/modules/setting";
import { useRouter } from "vue-router";
-const router = useRouter()
+import { ElMessage } from "element-plus";
+const code = ref();
+const router = useRouter();
const useSettingStore = settingStore();
-const isShowStrring = Boolean(localStorage.getItem('falg')) || false
+const isShowStrring = Boolean(localStorage.getItem("falg")) || false;
const saveCode = () => {
- useSettingStore.setValue(true, 'isRunCode');
- localStorage.setItem('isRunCode','true')
- setStepEvent(8,formatDate(new Date()))
- useSettingStore.activeStepIndex = 9
+ if(!validateJavaCode(answer, code.value.innerText)){
+ ElMessage({
+ message: "代码编写错误",
+ type: "warning",
+ })
+ }
+ useSettingStore.setValue(true, "isRunCode");
+ localStorage.setItem("isRunCode", "true");
+ setStepEvent(8, formatDate(new Date()));
+ useSettingStore.activeStepIndex = 9;
- router.push('/program')
+ router.push("/program");
+};
+function normalizeCode(code) {
+ return code.replace(/\s+/g, ""); // 去除所有空白字符(包括换行)
}
+
+function validateJavaCode(answer, userCode) {
+ return normalizeCode(answer) === normalizeCode(userCode);
+}
+// 标准答案
+const answer = `@RequestMapping(value = "/convert", produces = "application/json; charset=utf-8")
+public String convert() throws IOException {
+ while (true) {
+ String tcp = TcpUtils.tcp();
+ if (tcp != null) {
+ System.out.println("获取到的tcp数据:" + tcp);
+ Date date = new Date();
+ String temperature = StrUtil.subBetween(tcp, "温度:", "℃");
+ String humidity = StrUtil.subBetween(tcp, "湿度:", "%RH");
+ String formatTime = DateUtil.formatTime(date);
+ Decs da = new Decs();
+ da.setId(count);
+ da.setTemperature(temperature);
+ da.setHumidity(humidity);
+ da.setTime(formatTime);
+ dataList.add(da);
+ count++;
+ }
+ }
+}
+`;
+const copyCode = () => {
+ navigator.clipboard.writeText(answer).then(() => {
+ ElMessage.success("复制成功");
+ });
+};
diff --git a/src/views/largeDataScreen/home.vue b/src/views/largeDataScreen/home.vue
index 92addad..afaa758 100644
--- a/src/views/largeDataScreen/home.vue
+++ b/src/views/largeDataScreen/home.vue
@@ -226,7 +226,7 @@
打开
-
+
@@ -780,7 +780,7 @@ const router = useRouter();
const useSettingStore = settingStore();
const isShowIdea = ref
(false);
console.log(route);
-onActivated(() => {
+onMounted(() => {
if (route.query.idea) {
isShowIdea.value = true;
installationStep.value = 10;