From fd92dc315dfd66eb3327e4623ef62f83963b9548 Mon Sep 17 00:00:00 2001 From: NiuZiYuan Date: Sun, 27 Apr 2025 09:08:17 +0800 Subject: [PATCH] dev --- src/views/Login.vue | 59 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/src/views/Login.vue b/src/views/Login.vue index 6cbd564..84001ef 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -11,28 +11,64 @@ import {useWsStore} from "@/stores/wsStore.ts"; const username = ref('') const password = ref('') -const rememberMe = ref(false) const router = useRouter(); +interface NetWorkType{ + ip: string, + mac: string, +} +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"){ + //提示 获取本地IP地址失败,将使用默认IP地址 + ElMessage({ + message: "获取本地IP地址失败,将使用默认IP地址", + type: 'warning', + duration: 1000, + onClose: () => { + } + }) + } + + + + post(apiConfig.ManagerLogin, {username: username.value, password: password.value}).then((token: any) => { localStorage.setItem('token', token) - getNetwork() - // ElMessage({ - // message: "登录成功,即将为您跳转到首页", - // type: 'success', - // duration: 1000, - // onClose: () => { - // router.push("/home/index") - // } - // }) + //签到,如果 签到成功,则直接调用success,如果失败,调用error }) } + + +const success = () => { + ElMessage({ + message: "登录成功,即将为您跳转到首页", + type: 'success', + duration: 1000, + onClose: () => { + router.push("/home/index") + } + }) +} +const error = () => { + ElMessage({ + message: "签到失败,我们将已非签到模式启动系统", + type: 'warning', + duration: 1000, + onClose: () => { + router.push("/home/index") + } + }) +} const wsStore = useWsStore(); const reciceMessage = (response: Response) => { - post(apiConfig.signUp, {mac:response.Data[0].MACAddress,ip:response.Data[0].IPAddress}) + console.log(response) } const getNetwork = () => { let data: any = {} @@ -46,6 +82,7 @@ const getNetwork = () => { onMounted(async () => { wsStore.setMessageCallback(reciceMessage) + getNetwork() }); onUnmounted(() => { wsStore.removeAllMessageCallback()