feat(admin): migrate admin UI to Vue3
This commit is contained in:
17
admin-frontend/src/api/admin.js
Normal file
17
admin-frontend/src/api/admin.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { api } from './client'
|
||||
|
||||
export async function updateAdminUsername(newUsername) {
|
||||
const { data } = await api.put('/admin/username', { new_username: newUsername })
|
||||
return data
|
||||
}
|
||||
|
||||
export async function updateAdminPassword(newPassword) {
|
||||
const { data } = await api.put('/admin/password', { new_password: newPassword })
|
||||
return data
|
||||
}
|
||||
|
||||
export async function logout() {
|
||||
const { data } = await api.post('/logout')
|
||||
return data
|
||||
}
|
||||
|
||||
27
admin-frontend/src/api/announcements.js
Normal file
27
admin-frontend/src/api/announcements.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { api } from './client'
|
||||
|
||||
export async function fetchAnnouncements() {
|
||||
const { data } = await api.get('/announcements')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function createAnnouncement(payload) {
|
||||
const { data } = await api.post('/announcements', payload)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function activateAnnouncement(id) {
|
||||
const { data } = await api.post(`/announcements/${id}/activate`)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function deactivateAnnouncement(id) {
|
||||
const { data } = await api.post(`/announcements/${id}/deactivate`)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function deleteAnnouncement(id) {
|
||||
const { data } = await api.delete(`/announcements/${id}`)
|
||||
return data
|
||||
}
|
||||
|
||||
30
admin-frontend/src/api/client.js
Normal file
30
admin-frontend/src/api/client.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import axios from 'axios'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
export const api = axios.create({
|
||||
baseURL: '/yuyx/api',
|
||||
timeout: 30_000,
|
||||
withCredentials: true,
|
||||
})
|
||||
|
||||
api.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error) => {
|
||||
const status = error?.response?.status
|
||||
const payload = error?.response?.data
|
||||
const message = payload?.error || payload?.message || error?.message || '请求失败'
|
||||
|
||||
if (status === 403) {
|
||||
ElMessage.error(message || '需要管理员权限')
|
||||
} else if (status) {
|
||||
ElMessage.error(message)
|
||||
} else if (error?.code === 'ECONNABORTED') {
|
||||
ElMessage.error('请求超时')
|
||||
} else {
|
||||
ElMessage.error(message)
|
||||
}
|
||||
|
||||
return Promise.reject(error)
|
||||
},
|
||||
)
|
||||
|
||||
27
admin-frontend/src/api/email.js
Normal file
27
admin-frontend/src/api/email.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { api } from './client'
|
||||
|
||||
export async function fetchEmailSettings() {
|
||||
const { data } = await api.get('/email/settings')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function updateEmailSettings(payload) {
|
||||
const { data } = await api.post('/email/settings', payload)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function fetchEmailStats() {
|
||||
const { data } = await api.get('/email/stats')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function fetchEmailLogs(params) {
|
||||
const { data } = await api.get('/email/logs', { params })
|
||||
return data
|
||||
}
|
||||
|
||||
export async function cleanupEmailLogs(days) {
|
||||
const { data } = await api.post('/email/logs/cleanup', { days })
|
||||
return data
|
||||
}
|
||||
|
||||
22
admin-frontend/src/api/feedbacks.js
Normal file
22
admin-frontend/src/api/feedbacks.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { api } from './client'
|
||||
|
||||
export async function fetchFeedbacks(status = '') {
|
||||
const { data } = await api.get('/feedbacks', { params: status ? { status } : {} })
|
||||
return data
|
||||
}
|
||||
|
||||
export async function replyFeedback(feedbackId, reply) {
|
||||
const { data } = await api.post(`/feedbacks/${feedbackId}/reply`, { reply })
|
||||
return data
|
||||
}
|
||||
|
||||
export async function closeFeedback(feedbackId) {
|
||||
const { data } = await api.post(`/feedbacks/${feedbackId}/close`)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function deleteFeedback(feedbackId) {
|
||||
const { data } = await api.delete(`/feedbacks/${feedbackId}`)
|
||||
return data
|
||||
}
|
||||
|
||||
17
admin-frontend/src/api/passwordResets.js
Normal file
17
admin-frontend/src/api/passwordResets.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { api } from './client'
|
||||
|
||||
export async function fetchPasswordResets() {
|
||||
const { data } = await api.get('/password_resets')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function approvePasswordReset(requestId) {
|
||||
const { data } = await api.post(`/password_resets/${requestId}/approve`)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function rejectPasswordReset(requestId) {
|
||||
const { data } = await api.post(`/password_resets/${requestId}/reject`)
|
||||
return data
|
||||
}
|
||||
|
||||
17
admin-frontend/src/api/proxy.js
Normal file
17
admin-frontend/src/api/proxy.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { api } from './client'
|
||||
|
||||
export async function fetchProxyConfig() {
|
||||
const { data } = await api.get('/proxy/config')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function updateProxyConfig(payload) {
|
||||
const { data } = await api.post('/proxy/config', payload)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function testProxy(payload) {
|
||||
const { data } = await api.post('/proxy/test', payload)
|
||||
return data
|
||||
}
|
||||
|
||||
32
admin-frontend/src/api/smtp.js
Normal file
32
admin-frontend/src/api/smtp.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import { api } from './client'
|
||||
|
||||
export async function fetchSmtpConfigs() {
|
||||
const { data } = await api.get('/smtp/configs')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function createSmtpConfig(payload) {
|
||||
const { data } = await api.post('/smtp/configs', payload)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function updateSmtpConfig(configId, payload) {
|
||||
const { data } = await api.put(`/smtp/configs/${configId}`, payload)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function deleteSmtpConfig(configId) {
|
||||
const { data } = await api.delete(`/smtp/configs/${configId}`)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function testSmtpConfig(configId, email) {
|
||||
const { data } = await api.post(`/smtp/configs/${configId}/test`, { email })
|
||||
return data
|
||||
}
|
||||
|
||||
export async function setPrimarySmtpConfig(configId) {
|
||||
const { data } = await api.post(`/smtp/configs/${configId}/primary`)
|
||||
return data
|
||||
}
|
||||
|
||||
7
admin-frontend/src/api/stats.js
Normal file
7
admin-frontend/src/api/stats.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import { api } from './client'
|
||||
|
||||
export async function fetchSystemStats() {
|
||||
const { data } = await api.get('/stats')
|
||||
return data
|
||||
}
|
||||
|
||||
17
admin-frontend/src/api/system.js
Normal file
17
admin-frontend/src/api/system.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { api } from './client'
|
||||
|
||||
export async function fetchSystemConfig() {
|
||||
const { data } = await api.get('/system/config')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function updateSystemConfig(payload) {
|
||||
const { data } = await api.post('/system/config', payload)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function executeScheduleNow() {
|
||||
const { data } = await api.post('/schedule/execute', {})
|
||||
return data
|
||||
}
|
||||
|
||||
32
admin-frontend/src/api/tasks.js
Normal file
32
admin-frontend/src/api/tasks.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import { api } from './client'
|
||||
|
||||
export async function fetchServerInfo() {
|
||||
const { data } = await api.get('/server/info')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function fetchDockerStats() {
|
||||
const { data } = await api.get('/docker_stats')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function fetchTaskStats() {
|
||||
const { data } = await api.get('/task/stats')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function fetchRunningTasks() {
|
||||
const { data } = await api.get('/task/running')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function fetchTaskLogs(params) {
|
||||
const { data } = await api.get('/task/logs', { params })
|
||||
return data
|
||||
}
|
||||
|
||||
export async function clearOldTaskLogs(days) {
|
||||
const { data } = await api.post('/task/logs/clear', { days })
|
||||
return data
|
||||
}
|
||||
|
||||
42
admin-frontend/src/api/users.js
Normal file
42
admin-frontend/src/api/users.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import { api } from './client'
|
||||
|
||||
export async function fetchAllUsers() {
|
||||
const { data } = await api.get('/users')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function fetchPendingUsers() {
|
||||
const { data } = await api.get('/users/pending')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function approveUser(userId) {
|
||||
const { data } = await api.post(`/users/${userId}/approve`)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function rejectUser(userId) {
|
||||
const { data } = await api.post(`/users/${userId}/reject`)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function deleteUser(userId) {
|
||||
const { data } = await api.delete(`/users/${userId}`)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function setUserVip(userId, days) {
|
||||
const { data } = await api.post(`/users/${userId}/vip`, { days })
|
||||
return data
|
||||
}
|
||||
|
||||
export async function removeUserVip(userId) {
|
||||
const { data } = await api.delete(`/users/${userId}/vip`)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function adminResetUserPassword(userId, newPassword) {
|
||||
const { data } = await api.post(`/users/${userId}/reset_password`, { new_password: newPassword })
|
||||
return data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user