fix: 修复了一堆API错误,并顺手添加了OSS API

This commit is contained in:
2025-12-19 19:12:13 +08:00
parent 7d16d0d9e7
commit d2e64a70d2
13 changed files with 42 additions and 27 deletions

View File

@@ -11,9 +11,9 @@ import {
DrawerTitle,
} from "@/components/ui/drawer"
import { useState } from "react";
import { AdminApi } from "@/lib/api";
import { toast } from "sonner";
import { ApiError } from "next/dist/server/api-utils";
import { AdminAPI } from "@/lib/api/client";
interface CreateUserEditorProps {
children: React.ReactNode;
@@ -26,7 +26,7 @@ export function CreateUserEditor({ children, onRefresh }: CreateUserEditorProps)
event.preventDefault();
const formData = new FormData(event.currentTarget);
try {
await AdminApi.user.create({
await AdminAPI.createUser({
username: formData.get("username")?.toString() || null,
nickname: formData.get("nickname")?.toString() || null,
email: formData.get("email")?.toString() || null,

View File

@@ -17,7 +17,6 @@ import { Label } from "@/components/ui/label"
import { useUser } from "@/hooks/admin/user/use-user";
import { User } from "@/lib/types/user";
import { Skeleton } from "@/components/ui/skeleton";
import { AdminApi } from "@/lib/api";
import { toast } from "sonner";
import {
Alert,
@@ -27,6 +26,7 @@ import {
import { AlertCircle } from "lucide-react";
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "@/components/ui/alert-dialog";
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
import { AdminAPI } from "@/lib/api/client";
export function UserInfoEditor({
onClose,
@@ -50,7 +50,7 @@ export function UserInfoEditor({
}) => {
try {
// setSaveLoading(true);
const res = await AdminApi.user.update(userId, user);
const res = await AdminAPI.updateUser(userId, user);
if (res) {
toast.success("保存成功");
onUserUpdate(res);
@@ -69,7 +69,7 @@ export function UserInfoEditor({
const handleRemove = async (userId: string) => {
try {
// setRemoveLoading(true);
await AdminApi.user.remove(userId, true);
await AdminAPI.removeUser(userId, true);
toast.success("注销成功");
onUserSoftDelete(userId);
onClose();
@@ -85,7 +85,7 @@ export function UserInfoEditor({
const handleSetPassword = async (userId: string, password: string) => {
try {
// setSetPasswordLoading(true);
await AdminApi.user.setPassword(userId, password);
await AdminAPI.setUserPassword(userId, password);
toast.success("密码修改成功");
setPasswordDialogOpen(false);
} catch (error) {