From f1b356f7fc81d2092241853f0f7085c05158f5bf Mon Sep 17 00:00:00 2001 From: ChenQiuYu Date: Sun, 27 Apr 2025 09:42:25 +0800 Subject: [PATCH] dev --- src/views/Login.vue | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/views/Login.vue b/src/views/Login.vue index 84001ef..aa929c2 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -2,7 +2,7 @@ import {onMounted, onUnmounted, ref} from 'vue' import {post} from '@/utils/request.ts' import {useRouter} from "vue-router"; -import {ElMessage} from "element-plus"; +import {type Action, ElMessage, ElMessageBox} from "element-plus"; import Mask from "@/components/common/Mask.vue"; import Auth from "@/components/manger/Auth.vue"; import {apiConfig} from "@/assets/config/apiConfig"; @@ -12,18 +12,20 @@ import {useWsStore} from "@/stores/wsStore.ts"; const username = ref('') const password = ref('') const router = useRouter(); -interface NetWorkType{ + +interface NetWorkType { ip: string, mac: string, } -const netWork=ref({ + +const netWork = ref({ ip: "192.168.1.1", mac: "00-00-00-00-00" }) const handleLogin = () => { - if(netWork.value.mac=="00-00-00-00-00"){ + if (netWork.value.mac == "00-00-00-00-00") { //提示 获取本地IP地址失败,将使用默认IP地址 ElMessage({ message: "获取本地IP地址失败,将使用默认IP地址", @@ -35,13 +37,14 @@ const handleLogin = () => { } - - post(apiConfig.ManagerLogin, {username: username.value, password: password.value}).then((token: any) => { localStorage.setItem('token', token) - //签到,如果 签到成功,则直接调用success,如果失败,调用error - + post('signUp/signUp',{mac:netWork.value.mac,ip:netWork.value.ip},{catch_error: true}).then((res: any) => { + success() + }).catch(()=>{ + error() + }) }) } @@ -57,18 +60,21 @@ const success = () => { }) } const error = () => { - ElMessage({ - message: "签到失败,我们将已非签到模式启动系统", - type: 'warning', - duration: 1000, - onClose: () => { + ElMessageBox.alert('签到失败,我们将已非签到模式启动系统', '签到提示', { + // if you want to disable its autofocus + // autofocus: false, + confirmButtonText: '确定', + callback: (action: Action) => { router.push("/home/index") - } + }, }) } const wsStore = useWsStore(); const reciceMessage = (response: Response) => { - console.log(response) + netWork.value = { + ip: response.Data[0].IPAddress, + mac: response.Data[0].MACAddress + } } const getNetwork = () => { let data: any = {}