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 ( +
+ {/* {api} */} +
+ {/* { setInputKey(v.target.value) }}> */} + { setInputKey(v.target.value) }} className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg outline-none focus:ring-blue-500 focus:ring focus:border-blue-500 block w-full p-2.5"> + +
+
+
+
+
+
Available
+
+
+ {list.filter((v)=>{return v[2] - new Date().getTime() >= 0}).length} +
+
+
+
+
+
Expired
+
+
+ {list.filter((v)=>{return v[2] - new Date().getTime() < 0}).length} +
+
+
+
+
+
Banned
+
+
0
+
+
+
+ {list.map((v, key)=>( +
+
#{v[0]}
+
+ {v[2] - new Date().getTime() >= 0 && +
+
+
Available
+
+ } + {v[2] - new Date().getTime() < 0 && +
+
+
Expired
+
+ } +
{v[1]}
+
+
Expiry Date{dayjs(v[2]).format('YYYY-MM-DD HH:mm:ss')}
+
Level{v[3]}
+ {/*
+
+
Available
+
*/} +
+ ))} +
+
+ ) +}