diff --git a/src/pages/admin/userlist.tsx b/src/pages/admin/userlist.tsx new file mode 100644 index 0000000..8a9813f --- /dev/null +++ b/src/pages/admin/userlist.tsx @@ -0,0 +1,105 @@ +// import { Input } from "@chakra-ui/react"; +import axios from "axios"; +import dayjs from "dayjs"; +import { useEffect, useState } from "react" + +export default function Userlist() { + const api = import.meta.env.VITE_API + const [inputKey, setInputKey] = useState('') + const [list, setList] = useState([]) + + useEffect(()=>{ + axios.get(api+'/get_user_list') + .then(response => { + const jsonData = response.data; + setList(jsonData.items.reverse()) + }) + .catch(error => { + console.error('请求出错:', error); + }); + },[]) + + const submit = () => { + console.log('+ submit'); + setInputKey('') + axios.post(api+'/add', {key: inputKey}, { + headers: { + 'Content-Type': 'application/json', // 可能需要根据实际情况设置 Content-Type + }, + }) + .then(response => { + // 在这里处理成功的响应 + console.log('POST 请求成功:', response.data); + }) + .catch(error => { + // 处理请求出错 + console.error('POST 请求出错:', error); + }); + } + + return ( +