Browse Source

添加币种管理

main
mac 2 days ago
parent
commit
3af1fac0d9
  1. 28
      src/api/index.ts
  2. 4
      src/pages/chat/group-list/index.tsx
  3. 180
      src/pages/coin/default-list.tsx
  4. 180
      src/pages/coin/token-list.tsx
  5. 2
      src/pages/login/index.tsx
  6. 28
      src/route/routes.ts

28
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)
},
}

4
src/pages/chat/group-list/index.tsx

@ -350,7 +350,7 @@ const ChatGroupList = () => {
/>
</Modal >}
<Drawer title="新建群组" width={450} visible={visible} onClose={() => {
{visible && <Drawer title={groupOperate.current === 'c' ? "新建群组" : "群聊设置"} width={450} visible={visible} onClose={() => {
setVisible(false)
form.resetFields()
}}>
@ -438,7 +438,7 @@ const ChatGroupList = () => {
</div>
</Form.Item>
</Form>
</Drawer>
</Drawer>}
</>
)
}

180
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) => <div>{id} ({chaindNames[id]})</div>
},
{
title: '精度',
dataIndex: 'decimals',
},
{
title: '操作',
dataIndex: '',
fixed: 'right',
width: 150,
render: (row) => (
<div style={{ display: 'flex' }}>
<div style={{ fontSize: 12, color: '#1890ff', marginLeft: 15, textWrap: 'nowrap', cursor: 'pointer' }} onClick={() => {
operateType.current = 'u';
form.setFieldsValue(row)
currentItem.current = row
setVisible(true)
}}></div>
<Popconfirm title="确认删除?" onConfirm={() => delToken(row)}>
<div style={{ fontSize: 12, color: '#1890ff', marginLeft: 15, textWrap: 'nowrap', cursor: 'pointer' }}></div>
</Popconfirm>
</div>
)
},
]
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 (
<>
<MyTable
ref={tableRef}
header={
<div style={{ display: 'flex', justifyContent: 'flex-end', marginBottom: 15 }}>
<Button type="primary" onClick={() => {
operateType.current = 'c'
setVisible(true)
}}></Button>
</div>
}
apiFun={api.get_buzzDefaultTokens}
columns={columns}
rowKey="id"
/>
{visible && (
<Drawer visible={visible} onClose={close} width={500} title={operateType.current === 'c' ? '创建币种' : '修改币种'}>
<Form layout="vertical" form={form} onFinish={onFinish}>
<Form.Item label="chainID" name="chain_id" rules={[{ required: true, message: '请输入' }]}>
<Input />
</Form.Item>
<Form.Item label="币种地址" name="address" rules={[{ required: true, message: '请输入' }]}>
<Input />
</Form.Item>
<Form.Item label="币种名称" name="name" rules={[{ required: true, message: '请输入' }]}>
<Input />
</Form.Item>
<Form.Item label="币种符号" name="symbol" rules={[{ required: true, message: '请输入' }]}>
<Input />
</Form.Item>
<Form.Item label="币种精度" name="decimals" rules={[{ required: true, message: '请输入' }]}>
<Input />
</Form.Item>
<Form.Item >
<Button type="primary" htmlType="submit"></Button>
</Form.Item>
</Form>
</Drawer>
)
}
</>
)
}
export default TokenList

180
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) => <div>{id} ({chaindNames[id]})</div>
},
{
title: '精度',
dataIndex: 'decimals',
},
{
title: '操作',
dataIndex: '',
fixed: 'right',
width: 150,
render: (row) => (
<div style={{ display: 'flex' }}>
<div style={{ fontSize: 12, color: '#1890ff', marginLeft: 15, textWrap: 'nowrap', cursor: 'pointer' }} onClick={() => {
operateType.current = 'u';
form.setFieldsValue(row)
currentItem.current = row
setVisible(true)
}}></div>
<Popconfirm title="确认删除?" onConfirm={() => delToken(row)}>
<div style={{ fontSize: 12, color: '#1890ff', marginLeft: 15, textWrap: 'nowrap', cursor: 'pointer' }}></div>
</Popconfirm>
</div>
)
},
]
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 (
<>
<MyTable
ref={tableRef}
header={
<div style={{ display: 'flex', justifyContent: 'flex-end', marginBottom: 15 }}>
<Button type="primary" onClick={() => {
operateType.current = 'c'
setVisible(true)
}}></Button>
</div>
}
apiFun={api.get_buzzTokens}
columns={columns}
rowKey="id"
/>
{visible && (
<Drawer visible={visible} onClose={close} width={500} title={operateType.current === 'c' ? '创建币种' : '修改币种'}>
<Form layout="vertical" form={form} onFinish={onFinish}>
<Form.Item label="chainID" name="chain_id" rules={[{ required: true, message: '请输入' }]}>
<Input />
</Form.Item>
<Form.Item label="币种地址" name="address" rules={[{ required: true, message: '请输入' }]}>
<Input />
</Form.Item>
<Form.Item label="币种名称" name="name" rules={[{ required: true, message: '请输入' }]}>
<Input />
</Form.Item>
<Form.Item label="币种符号" name="symbol" rules={[{ required: true, message: '请输入' }]}>
<Input />
</Form.Item>
<Form.Item label="币种精度" name="decimals" rules={[{ required: true, message: '请输入' }]}>
<Input />
</Form.Item>
<Form.Item >
<Button type="primary" htmlType="submit"></Button>
</Form.Item>
</Form>
</Drawer>
)
}
</>
)
}
export default TokenList

2
src/pages/login/index.tsx

@ -87,7 +87,7 @@ const LoginForm: FC<Props> = ({
/>
<div className="logo-box">
<img alt="" className="logo" src={Logo} />
<span className="logo-name">React Antd Admin</span>
<span className="logo-name">BuzzUp Admin</span>
</div>
{FormView}
</div>

28
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',

Loading…
Cancel
Save