This commit is contained in:
ChenQiuYu 2025-04-27 09:42:25 +08:00
parent fd92dc315d
commit f1b356f7fc
1 changed files with 21 additions and 15 deletions

View File

@ -2,7 +2,7 @@
import {onMounted, onUnmounted, ref} from 'vue' import {onMounted, onUnmounted, ref} from 'vue'
import {post} from '@/utils/request.ts' import {post} from '@/utils/request.ts'
import {useRouter} from "vue-router"; 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 Mask from "@/components/common/Mask.vue";
import Auth from "@/components/manger/Auth.vue"; import Auth from "@/components/manger/Auth.vue";
import {apiConfig} from "@/assets/config/apiConfig"; import {apiConfig} from "@/assets/config/apiConfig";
@ -12,18 +12,20 @@ import {useWsStore} from "@/stores/wsStore.ts";
const username = ref('') const username = ref('')
const password = ref('') const password = ref('')
const router = useRouter(); const router = useRouter();
interface NetWorkType{
interface NetWorkType {
ip: string, ip: string,
mac: string, mac: string,
} }
const netWork=ref<NetWorkType>({
const netWork = ref<NetWorkType>({
ip: "192.168.1.1", ip: "192.168.1.1",
mac: "00-00-00-00-00" mac: "00-00-00-00-00"
}) })
const handleLogin = () => { const handleLogin = () => {
if(netWork.value.mac=="00-00-00-00-00"){ if (netWork.value.mac == "00-00-00-00-00") {
// IP使IP // IP使IP
ElMessage({ ElMessage({
message: "获取本地IP地址失败将使用默认IP地址", message: "获取本地IP地址失败将使用默认IP地址",
@ -35,13 +37,14 @@ const handleLogin = () => {
} }
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)
// success,error // 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 = () => { const error = () => {
ElMessage({ ElMessageBox.alert('签到失败,我们将已非签到模式启动系统', '签到提示', {
message: "签到失败,我们将已非签到模式启动系统", // if you want to disable its autofocus
type: 'warning', // autofocus: false,
duration: 1000, confirmButtonText: '确定',
onClose: () => { callback: (action: Action) => {
router.push("/home/index") router.push("/home/index")
} },
}) })
} }
const wsStore = useWsStore(); const wsStore = useWsStore();
const reciceMessage = (response: Response) => { const reciceMessage = (response: Response) => {
console.log(response) netWork.value = {
ip: response.Data[0].IPAddress,
mac: response.Data[0].MACAddress
}
} }
const getNetwork = () => { const getNetwork = () => {
let data: any = {} let data: any = {}