@ -356,6 +356,7 @@ const emailError = ref('');
|
||||
const phoneError = ref('');
|
||||
const showDeleteConfirm = ref('');
|
||||
const isLogsLoaded = ref(false);
|
||||
const apiUrl = import.meta.env.VITE_API_BASE_URL // 动态获取API基础URL
|
||||
|
||||
// 统一错误处理函数
|
||||
const handleError = (error, message = '操作失败') => {
|
||||
@ -557,7 +558,7 @@ onMounted(() => {
|
||||
// 获取用户数据
|
||||
const fetchUsers = async () => {
|
||||
try {
|
||||
const response = await axios.get('http://localhost:5000/personnel/users', {
|
||||
const response = await axios.get(`${apiUrl}/personnel/users`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${userInfo.token}`
|
||||
}
|
||||
@ -589,7 +590,7 @@ const fetchUsers = async () => {
|
||||
// 获取日志数据
|
||||
const fetchLogs = async () => {
|
||||
try {
|
||||
const response = await axios.get(`http://localhost:5000/personnel/logs`, {
|
||||
const response = await axios.get(`${apiUrl}/personnel/logs`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${userInfo.token}`
|
||||
}
|
||||
@ -650,7 +651,7 @@ const handleAddUser = async () => {
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await axios.post('http://localhost:5000/personnel/users', requestData, {
|
||||
const response = await axios.post(`${apiUrl}/personnel/users`, requestData, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${userInfo.token}`
|
||||
}
|
||||
@ -737,7 +738,7 @@ const handleEditUser = async () => {
|
||||
|
||||
try {
|
||||
const response = await axios.put(
|
||||
`http://localhost:5000/personnel/users/${editingUser.value.username}`,
|
||||
`${apiUrl}/personnel/users/${editingUser.value.username}`,
|
||||
payload,
|
||||
{
|
||||
headers: {
|
||||
@ -779,7 +780,7 @@ const deleteUser = async (username) => {
|
||||
if (!confirm(`确定要删除用户 ${username} 吗?此操作不可撤销。`)) return;
|
||||
|
||||
try {
|
||||
const response = await axios.delete(`http://localhost:5000/personnel/users/${username}`, {
|
||||
const response = await axios.delete(`${apiUrl}/personnel/users/${username}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${userInfo.token}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user