增加通过认证码绑定设备和管理账户的功能,需要开启私有设备配置

增加登录用户鉴权
This commit is contained in:
玄凤科技
2025-02-17 15:53:48 +08:00
parent 325312327c
commit aa2d323951
14 changed files with 1052 additions and 274 deletions
+6 -14
View File
@@ -19,7 +19,7 @@
<script setup>
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { API_BASE_URL } from '../config/api';
import apiClient from '../utils/api';
const router = useRouter();
const username = ref('');
@@ -34,24 +34,16 @@ const handleLogin = async () => {
isLoading.value = true;
try {
const response = await fetch(`${API_BASE_URL}/api/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
username: username.value,
password: password.value
})
const response = await apiClient.post('/api/login', {
username: username.value,
password: password.value
});
const data = await response.json();
const data = response.data;
if (data.success) {
// 存储token和登录状态
localStorage.setItem('token', data.token);
localStorage.setItem('session_id', data.session_id);
localStorage.setItem('isLoggedIn', 'true');
// 使用路由导航到panel页面
router.push('/panel');
} else {
alert(data.message || '登录失败');