This commit is contained in:
牛子源 2025-04-27 09:08:17 +08:00
parent 9bddab3122
commit fd92dc315d
1 changed files with 48 additions and 11 deletions

View File

@ -11,28 +11,64 @@ import {useWsStore} from "@/stores/wsStore.ts";
const username = ref('') const username = ref('')
const password = ref('') const password = ref('')
const rememberMe = ref(false)
const router = useRouter(); const router = useRouter();
interface NetWorkType{
ip: string,
mac: string,
}
const netWork=ref<NetWorkType>({
ip: "192.168.1.1",
mac: "00-00-00-00-00"
})
const handleLogin = () => { 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) => { post(apiConfig.ManagerLogin, {username: username.value, password: password.value}).then((token: any) => {
localStorage.setItem('token', token) localStorage.setItem('token', token)
getNetwork()
// ElMessage({ // success,error
// message: "",
// type: 'success',
// duration: 1000,
// onClose: () => {
// router.push("/home/index")
// }
// })
}) })
} }
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 wsStore = useWsStore();
const reciceMessage = (response: Response) => { const reciceMessage = (response: Response) => {
post(apiConfig.signUp, {mac:response.Data[0].MACAddress,ip:response.Data[0].IPAddress}) console.log(response)
} }
const getNetwork = () => { const getNetwork = () => {
let data: any = {} let data: any = {}
@ -46,6 +82,7 @@ const getNetwork = () => {
onMounted(async () => { onMounted(async () => {
wsStore.setMessageCallback(reciceMessage) wsStore.setMessageCallback(reciceMessage)
getNetwork()
}); });
onUnmounted(() => { onUnmounted(() => {
wsStore.removeAllMessageCallback() wsStore.removeAllMessageCallback()