Skip to content

Commit

Permalink
chore: add aifadian
Browse files Browse the repository at this point in the history
  • Loading branch information
YuzeTT committed Nov 22, 2023
1 parent 08f1744 commit 27c0d7b
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"antd-img-crop": "^4.17.0",
"axios": "^1.6.1",
"cropperjs": "^1.6.1",
"crypto-js": "^4.2.0",
"dayjs": "^1.11.10",
"detect-browser": "^5.3.0",
"downloadjs": "^1.4.7",
Expand All @@ -35,6 +36,7 @@
},
"devDependencies": {
"@iconify-json/ri": "^1.1.12",
"@types/crypto-js": "^4.2.1",
"@types/react": "^18.2.37",
"@types/react-copy-to-clipboard": "^5.0.7",
"@types/react-dom": "^18.2.15",
Expand Down
14 changes: 14 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions src/pages/admin/aifadian.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import axios from "axios"
import md5 from 'crypto-js/md5'
import dayjs from "dayjs"
import { useEffect, useState } from "react"

export default function Test() {
const user_id = import.meta.env.VITE_AFD_USER_ID
const token = import.meta.env.VITE_AFD_TOKEN
const ts = Math.floor(new Date().getTime() / 1000)
const params = {
page: 1
}

const [list, setList] = useState<any[]>([])

const sign = md5(`${token}params${JSON.stringify(params)}ts${ts}user_id${user_id}`)

useEffect(()=>{
axios.get('https://afdian.net/api/open/query-sponsor', {params:{'user_id': user_id, 'params': JSON.stringify(params), 'ts': ts, 'sign': sign}})
.then(response => {
// 处理响应
console.log(response.data);
if(response.data.ec === 200){
setList(response.data.data.list)
}
})
.catch(error => {
// 处理错误
console.error('Error:', error);
});
},[])
return (
<div>
<div className=''>
{list.map((v)=>(
<div className='card rounded-md divide-y'>
<div className='flex items-center p-2'>
<div className="i-ri-time-line mr-1 op50" />
<div className='text-sm op50'>{dayjs(v.last_pay_time*1000).format('YYYY-MM-DD HH:mm:ss')}</div>
</div>
<div className='p-2'>
<div>{v.user.name}</div>
</div>
</div>
))}
</div>
<pre>
{JSON.stringify(list, null, 2)}
</pre>
</div>
)
}

0 comments on commit 27c0d7b

Please sign in to comment.