fix: issues

This commit is contained in:
2025-12-20 14:11:44 +08:00
parent 88d42470c4
commit 8e95dada82
17 changed files with 95 additions and 87 deletions

View File

@@ -2,7 +2,7 @@ import axios from 'axios';
// Create a base axios instance
export const apiClient = axios.create({
baseURL: import.meta.env.VITE_API_BASE_URL || '/v1',
baseURL: import.meta.env.VITE_API_BASE_URL || '',
timeout: 10000,
headers: {
'Content-Type': 'application/json',

View File

@@ -2,6 +2,6 @@ import httpClient from './httpClient';
export const authService = {
login(username, password) {
return httpClient.post('/admin/auth', { username, password });
return httpClient.post('/auth', { username, password });
},
};

View File

@@ -4,7 +4,7 @@ import axios from 'axios';
// Create axios instance with default config
const httpClient = axios.create({
baseURL: '/v1',
baseURL: '/admin/v1',
timeout: 10000,
headers: {
'Content-Type': 'application/json',

View File

@@ -2,30 +2,30 @@ import httpClient from './httpClient';
export const mediaService = {
getMedias({ page = 1, limit = 10 } = {}) {
return httpClient.get('/admin/medias', {
return httpClient.get('/medias', {
params: { page, limit }
});
},
createMedia(mediaInfo) {
return httpClient.post('/admin/medias', mediaInfo);
return httpClient.post('/medias', mediaInfo);
},
preUploadedCheck(md5, ext, mime) {
return httpClient.get(`/admin/uploads/pre-uploaded-check/${md5}.${ext}`, {
return httpClient.get(`/uploads/pre-uploaded-check/${md5}.${ext}`, {
params: { mime }
});
},
uploadedSuccess(data) {
return httpClient.post('/admin/uploads/post-uploaded-action', data);
return httpClient.post('/uploads/post-uploaded-action', data);
},
getMediaPreviewUrl(id) {
const token = localStorage.getItem('__token');
return `${httpClient.defaults.baseURL}/admin/medias/${id}?token=${token}`;
return `${httpClient.defaults.baseURL}/medias/${id}?token=${token}`;
},
delete(id) {
return httpClient.delete(`/admin/medias/${id}`);
return httpClient.delete(`/medias/${id}`);
},
};

View File

@@ -2,7 +2,7 @@ import httpClient from './httpClient';
export const orderService = {
get({ page = 1, limit = 10, keyword = '' } = {}) {
return httpClient.get('/admin/orders', {
return httpClient.get('/orders', {
params: {
page,
limit,
@@ -11,6 +11,6 @@ export const orderService = {
});
},
refund(id) {
return httpClient.post(`/admin/orders/${id}/refund`);
return httpClient.post(`/orders/${id}/refund`);
}
}

View File

@@ -2,7 +2,7 @@ import httpClient from './httpClient';
export const postService = {
getPosts({ page = 1, limit = 10, keyword = '' } = {}) {
return httpClient.get('/admin/posts', {
return httpClient.get('/posts', {
params: {
page,
limit,
@@ -11,19 +11,19 @@ export const postService = {
});
},
getPost(id) {
return httpClient.get(`/admin/posts/${id}`);
return httpClient.get(`/posts/${id}`);
},
createPost(post) {
return httpClient.post('/admin/posts', post);
return httpClient.post('/posts', post);
},
updatePost(id, post) {
return httpClient.put(`/admin/posts/${id}`, post);
return httpClient.put(`/posts/${id}`, post);
},
deletePost(id) {
return httpClient.delete(`/admin/posts/${id}`);
return httpClient.delete(`/posts/${id}`);
},
sendTo(id, userId) {
return httpClient.post(`/admin/posts/${id}/send-to/${userId}`);
return httpClient.post(`/posts/${id}/send-to/${userId}`);
},
}

View File

@@ -2,6 +2,6 @@ import httpClient from './httpClient';
export const statisticsService = {
get() {
return httpClient.get('/admin/statistics');
return httpClient.get('/statistics');
},
}

View File

@@ -2,7 +2,7 @@ import httpClient from './httpClient';
export const userService = {
getUsers({ page = 1, limit = 10, keyword = '' } = {}) {
return httpClient.get('/admin/users', {
return httpClient.get('/users', {
params: {
page,
limit,
@@ -11,24 +11,24 @@ export const userService = {
});
},
searchUser(id) {
return httpClient.get(`/admin/users/${id}`);
return httpClient.get(`/users/${id}`);
},
userBalance(id, balance) {
return httpClient.post(`/admin/users/${id}/balance`, {
return httpClient.post(`/users/${id}/balance`, {
balance
});
},
getUser(id) {
return httpClient.get(`/admin/users/${id}`);
return httpClient.get(`/users/${id}`);
},
deleteUser(id) {
return httpClient.delete(`/admin/users/${id}`);
return httpClient.delete(`/users/${id}`);
},
getUserById(id) {
return httpClient.get(`/admin/users/${id}`);
return httpClient.get(`/users/${id}`);
},
getUserArticles(userId, page, limit) {
return httpClient.get(`/admin/users/${userId}/articles`, {
return httpClient.get(`/users/${userId}/articles`, {
params: {
page,
limit,

View File

@@ -27,11 +27,11 @@ export default defineConfig({
},
server: {
host: '0.0.0.0',
allowedHosts: ['mp.jdwan.com'],
allowedHosts: ['mp.jdwan.com'],
port: 3000,
open: true,
proxy: {
'/v1': 'http://localhost:8088',
'/admin/v1': 'http://localhost:8088',
}
}
});