From b8ba2a3bc5ca3d6e7b40ac15a83ff0eb63b8fcda Mon Sep 17 00:00:00 2001 From: no99 <17663930442@163.com> Date: Wed, 2 Jul 2025 16:27:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E7=99=BB=E9=99=86=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E6=B5=8F=E8=A7=88=E5=99=A8=E9=93=BE=E6=8E=A5=E6=8B=BC=E4=B8=8A?= =?UTF-8?q?machineId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/login-hxl.vue | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/views/login-hxl.vue b/src/views/login-hxl.vue index e071543..1a4bdd0 100644 --- a/src/views/login-hxl.vue +++ b/src/views/login-hxl.vue @@ -68,7 +68,7 @@ import { ref, onMounted } from "vue"; import axios from "axios"; import API from "@/util/http"; import { useRouter } from "vue-router"; - +import { ElMessage, ElMessageBox } from "element-plus"; const router = useRouter(); const firstAnimating = ref(false); const isAnimating = ref(false); @@ -85,12 +85,28 @@ const userInfo = ref({ password: "123456", }); +const getQueryVariable = (variable) => { + const href = window.location.href; + const query = href.split("?")[1]; + console.log("query", query); + const vars = query.split("&"); + for (let i = 0; i < vars.length; i++) { + const pair = vars[i].split("="); + if (pair[0] === variable) { + return pair[1]; + } + } + return ""; +}; + const login = async function () { + const machineId = getQueryVariable("machineId"); + console.log(machineId); try { const result = await axios.post(`http://18.143.76.3:10704/admin/login`, { account: userInfo.value.username, password: userInfo.value.password, - machineId: "23131233213", + machineId: machineId, }); // const result = await API({ // url: "/admin/login", @@ -102,13 +118,14 @@ const login = async function () { // }); console.log("请求成功", result); - - router.push({ - name: "workspace", - query: { - machineId: result.data.data.machineId, - }, - }); + if (result.data.code == 200) { + ElMessage.success('登录成功'); + router.push({ + name: "workspace", + }); + } else { + ElMessage.error(result.data.msg); + } } catch (error) { console.log("请求失败", error); }