From 3af1fac0d9d03ef0d4cd5ad05f0430f6f4a03c3f Mon Sep 17 00:00:00 2001 From: mac Date: Fri, 22 Nov 2024 15:29:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B8=81=E7=A7=8D=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/index.ts | 28 ++++- src/pages/chat/group-list/index.tsx | 4 +- src/pages/coin/default-list.tsx | 180 ++++++++++++++++++++++++++++ src/pages/coin/token-list.tsx | 180 ++++++++++++++++++++++++++++ src/pages/login/index.tsx | 2 +- src/route/routes.ts | 28 +++++ 6 files changed, 418 insertions(+), 4 deletions(-) create mode 100644 src/pages/coin/default-list.tsx create mode 100644 src/pages/coin/token-list.tsx diff --git a/src/api/index.ts b/src/api/index.ts index 983d9c1..aa6b769 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -72,5 +72,31 @@ export default { }, get_lotteryList(params) { return $axios.post('/admin/lotteryList', params) - } + }, + // coin 推荐 + get_buzzTokens(params) { + return $axios.post('/admin/getBuzzSymbol', params) + }, + create_buzzTokens(params) { + return $axios.post('/admin/newBuzzSymbol', params) + }, + update_buzzTokens(params) { + return $axios.post('/admin/updBuzzSymbol', params) + }, + delete_buzzTokens(params) { + return $axios.post('/admin/delBuzzSymbol', params) + }, + // coin 默认 + get_buzzDefaultTokens(params) { + return $axios.post('/admin/getBuzzSymbolCreate', params) + }, + create_buzzDefaultTokens(params) { + return $axios.post('/admin/newBuzzSymbolCreate', params) + }, + update_buzzDefaultTokens(params) { + return $axios.post('/admin/updBuzzSymbolCreate', params) + }, + delete_buzzDefaultTokens(params) { + return $axios.post('/admin/delBuzzSymbolCreate', params) + }, } diff --git a/src/pages/chat/group-list/index.tsx b/src/pages/chat/group-list/index.tsx index 52f29b4..ccdd41c 100644 --- a/src/pages/chat/group-list/index.tsx +++ b/src/pages/chat/group-list/index.tsx @@ -350,7 +350,7 @@ const ChatGroupList = () => { /> } - { + {visible && { setVisible(false) form.resetFields() }}> @@ -438,7 +438,7 @@ const ChatGroupList = () => { - + } ) } diff --git a/src/pages/coin/default-list.tsx b/src/pages/coin/default-list.tsx new file mode 100644 index 0000000..c9fb4c9 --- /dev/null +++ b/src/pages/coin/default-list.tsx @@ -0,0 +1,180 @@ +import api from "@/api" +import MyTable from "@/components/MyTable" +import { Button, Drawer, Form, Input, notification, Popconfirm } from "antd" +import React, { useRef, useState } from "react" + +const chaindNames = { + 1: 'Ethereum Mainnet', + 56: 'BNB Smart Chain Mainnet', + 42161: 'Arbitrum One', + 10: 'OP Mainnet', + 97: 'BSC Testnet', + 11155111: 'Ethereum Sepolia', + 11155420: 'Optimism Sepolia Testnet Archival', + 421614: 'Arbitrum Sepolia Testnet Archival', +} + +const TokenList = () => { + + const [visible, setVisible] = useState(false) + const operateType = useRef('' as 'c' | 'u') + const [form] = Form.useForm() + const tableRef = useRef(null) + const currentItem = useRef({} as any) + + const columns = [ + { + title: '地址', + dataIndex: 'address', + width: 300 + }, + { + title: '币种名称', + dataIndex: 'name', + width: 200 + }, + { + title: '币种符号', + dataIndex: 'symbol', + width: 200 + }, + { + title: 'chainId', + dataIndex: 'chain_id', + width: 200, + render: (id) =>
{id} ({chaindNames[id]})
+ }, + { + title: '精度', + dataIndex: 'decimals', + }, + { + title: '操作', + dataIndex: '', + fixed: 'right', + width: 150, + render: (row) => ( +
+
{ + operateType.current = 'u'; + form.setFieldsValue(row) + currentItem.current = row + setVisible(true) + }}>修改
+ delToken(row)}> +
删除
+
+
+ ) + }, + ] + + const delToken = async (item) => { + try { + const res: any = await api.delete_buzzDefaultTokens({ id: item.id }) + if (res.code === 0) { + notification.success({ + message: '删除成功' + }); + tableRef.current.update() + } + } catch (error) { + + } + } + + const changeToken = async (values) => { + let params = { ...values } + Object.keys(params).map(key => { + params[key] = typeof params[key] == 'string' ? params[key].trim() : params[key] + }) + const res: any = await api.update_buzzDefaultTokens({ + ...params, + chain_id: Number(params.chain_id), + id: currentItem.current.id + }) + if (res.code === 0) { + tableRef.current.update() + notification.success({ + message: '修改成功' + }) + } + } + + const createToken = async (values) => { + let params = { ...values } + Object.keys(params).map(key => { + params[key] = params[key].trim() + }) + const res: any = await api.create_buzzDefaultTokens({ + ...params, + chain_id: Number(params.chain_id) + }) + if (res.code === 0) { + tableRef.current.update() + notification.success({ + message: '创建成功' + }) + } + } + + const onFinish = (values) => { + close() + if (operateType.current === 'c') { + createToken(values) + } else { + changeToken(values) + } + } + + const close = () => { + setVisible(false) + form.resetFields() + } + + return ( + <> + + + + } + apiFun={api.get_buzzDefaultTokens} + columns={columns} + rowKey="id" + /> + {visible && ( + +
+ + + + + + + + + + + + + + + + + + +
+
+ ) + } + + ) +} + +export default TokenList \ No newline at end of file diff --git a/src/pages/coin/token-list.tsx b/src/pages/coin/token-list.tsx new file mode 100644 index 0000000..820d6b1 --- /dev/null +++ b/src/pages/coin/token-list.tsx @@ -0,0 +1,180 @@ +import api from "@/api" +import MyTable from "@/components/MyTable" +import { Button, Drawer, Form, Input, notification, Popconfirm } from "antd" +import React, { useRef, useState } from "react" + +const chaindNames = { + 1: 'Ethereum Mainnet', + 56: 'BNB Smart Chain Mainnet', + 42161: 'Arbitrum One', + 10: 'OP Mainnet', + 97: 'BSC Testnet', + 11155111: 'Ethereum Sepolia', + 11155420: 'Optimism Sepolia Testnet Archival', + 421614: 'Arbitrum Sepolia Testnet Archival', +} + +const TokenList = () => { + + const [visible, setVisible] = useState(false) + const operateType = useRef('' as 'c' | 'u') + const [form] = Form.useForm() + const tableRef = useRef(null) + const currentItem = useRef({} as any) + + const columns = [ + { + title: '地址', + dataIndex: 'address', + width: 300 + }, + { + title: '币种名称', + dataIndex: 'name', + width: 200 + }, + { + title: '币种符号', + dataIndex: 'symbol', + width: 200 + }, + { + title: 'chainId', + dataIndex: 'chain_id', + width: 200, + render: (id) =>
{id} ({chaindNames[id]})
+ }, + { + title: '精度', + dataIndex: 'decimals', + }, + { + title: '操作', + dataIndex: '', + fixed: 'right', + width: 150, + render: (row) => ( +
+
{ + operateType.current = 'u'; + form.setFieldsValue(row) + currentItem.current = row + setVisible(true) + }}>修改
+ delToken(row)}> +
删除
+
+
+ ) + }, + ] + + const delToken = async (item) => { + try { + const res: any = await api.delete_buzzTokens({ id: item.id }) + if (res.code === 0) { + notification.success({ + message: '删除成功' + }); + tableRef.current.update() + } + } catch (error) { + + } + } + + const changeToken = async (values) => { + let params = { ...values } + Object.keys(params).map(key => { + params[key] = typeof params[key] == 'string' ? params[key].trim() : params[key] + }) + const res: any = await api.update_buzzTokens({ + ...params, + chain_id: Number(params.chain_id), + id: currentItem.current.id + }) + if (res.code === 0) { + tableRef.current.update() + notification.success({ + message: '修改成功' + }) + } + } + + const createToken = async (values) => { + let params = { ...values } + Object.keys(params).map(key => { + params[key] = params[key].trim() + }) + const res: any = await api.create_buzzTokens({ + ...params, + chain_id: Number(params.chain_id) + }) + if (res.code === 0) { + tableRef.current.update() + notification.success({ + message: '创建成功' + }) + } + } + + const onFinish = (values) => { + close() + if (operateType.current === 'c') { + createToken(values) + } else { + changeToken(values) + } + } + + const close = () => { + setVisible(false) + form.resetFields() + } + + return ( + <> + + + + } + apiFun={api.get_buzzTokens} + columns={columns} + rowKey="id" + /> + {visible && ( + +
+ + + + + + + + + + + + + + + + + + +
+
+ ) + } + + ) +} + +export default TokenList \ No newline at end of file diff --git a/src/pages/login/index.tsx b/src/pages/login/index.tsx index 766ff23..fdd8313 100644 --- a/src/pages/login/index.tsx +++ b/src/pages/login/index.tsx @@ -87,7 +87,7 @@ const LoginForm: FC = ({ />
- React Antd Admin + BuzzUp Admin
{FormView} diff --git a/src/route/routes.ts b/src/route/routes.ts index 2263471..1734dcb 100644 --- a/src/route/routes.ts +++ b/src/route/routes.ts @@ -9,6 +9,8 @@ import WalletVersion from "@/pages/walletVersion" import ChatUserList from "@/pages/chat/user-list" import ChatGroupList from "@/pages/chat/group-list" import GroupMember from "@/pages/chat/group-member" +import TokenList from "@/pages/coin/token-list" +import DefaultList from "@/pages/coin/default-list" const routes = [ { @@ -56,6 +58,32 @@ const routes = [ } ] }, + { + path: '/coin', + name: '币种管理', + exact: true, + type: 'subMenu', + key: 'coin', + icon: SolutionOutlined, + routes: [ + { + path: '/token-list', + name: '推荐币种', + exact: true, + key: 'token-list', + component: TokenList, + routes: [] + }, + { + path: '/default-list', + name: '默认币种', + exact: true, + key: 'default-list', + component: DefaultList, + routes: [] + }, + ] + }, { path: '/swiper', name: 'DAPP',