mirror of
https://github.com/songquanpeng/message-pusher.git
synced 2025-09-27 04:26:31 +08:00
chore: update channel table ui
This commit is contained in:
@@ -1,5 +1,12 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Button, Form, Label, Pagination, Table } from 'semantic-ui-react';
|
import {
|
||||||
|
Button,
|
||||||
|
Form,
|
||||||
|
Label,
|
||||||
|
Pagination,
|
||||||
|
Popup,
|
||||||
|
Table,
|
||||||
|
} from 'semantic-ui-react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { API, showError, showSuccess, testChannel } from '../helpers';
|
import { API, showError, showSuccess, testChannel } from '../helpers';
|
||||||
|
|
||||||
@@ -246,24 +253,21 @@ const ChannelsTable = () => {
|
|||||||
<Table.Cell>
|
<Table.Cell>
|
||||||
<div>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
size={'small'}
|
positive
|
||||||
negative
|
|
||||||
onClick={() => {
|
|
||||||
manageChannel(channel.id, 'delete', idx).then();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
删除
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
size={'small'}
|
size={'small'}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
testChannel(user.username, user.token, channel.name).then();
|
testChannel(
|
||||||
|
user.username,
|
||||||
|
user.token,
|
||||||
|
channel.name
|
||||||
|
).then();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
测试
|
测试
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
size={'small'}
|
size={'small'}
|
||||||
|
color={'yellow'}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
manageChannel(
|
manageChannel(
|
||||||
channel.id,
|
channel.id,
|
||||||
@@ -281,6 +285,26 @@ const ChannelsTable = () => {
|
|||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</Button>
|
</Button>
|
||||||
|
<Popup
|
||||||
|
trigger={
|
||||||
|
<Button size='small' negative>
|
||||||
|
删除
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
on='click'
|
||||||
|
flowing
|
||||||
|
hoverable
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
size={'small'}
|
||||||
|
negative
|
||||||
|
onClick={() => {
|
||||||
|
manageChannel(channel.id, 'delete', idx).then();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
删除通道 {channel.name}
|
||||||
|
</Button>
|
||||||
|
</Popup>
|
||||||
</div>
|
</div>
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
|
@@ -1,5 +1,13 @@
|
|||||||
import React, { useEffect, useRef, useState } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import { Button, Form, Label, Modal, Pagination, Table } from 'semantic-ui-react';
|
import {
|
||||||
|
Button,
|
||||||
|
Form,
|
||||||
|
Label,
|
||||||
|
Modal,
|
||||||
|
Pagination,
|
||||||
|
Popup,
|
||||||
|
Table,
|
||||||
|
} from 'semantic-ui-react';
|
||||||
import { API, openPage, showError, showSuccess, showWarning } from '../helpers';
|
import { API, openPage, showError, showSuccess, showWarning } from '../helpers';
|
||||||
|
|
||||||
import { ITEMS_PER_PAGE } from '../constants';
|
import { ITEMS_PER_PAGE } from '../constants';
|
||||||
@@ -55,7 +63,7 @@ const MessagesTable = () => {
|
|||||||
title: '消息标题',
|
title: '消息标题',
|
||||||
description: '消息描述',
|
description: '消息描述',
|
||||||
content: '消息内容',
|
content: '消息内容',
|
||||||
link: ''
|
link: '',
|
||||||
}); // Message to be viewed
|
}); // Message to be viewed
|
||||||
const [viewModalOpen, setViewModalOpen] = useState(false);
|
const [viewModalOpen, setViewModalOpen] = useState(false);
|
||||||
|
|
||||||
@@ -210,12 +218,11 @@ const MessagesTable = () => {
|
|||||||
|
|
||||||
const insertNewMessage = (message) => {
|
const insertNewMessage = (message) => {
|
||||||
console.log(messages);
|
console.log(messages);
|
||||||
setMessages(messages => {
|
setMessages((messages) => {
|
||||||
let newMessages = [message];
|
let newMessages = [message];
|
||||||
newMessages.push(...messages);
|
newMessages.push(...messages);
|
||||||
return newMessages;
|
return newMessages;
|
||||||
}
|
});
|
||||||
);
|
|
||||||
setActivePage(1);
|
setActivePage(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -353,16 +360,28 @@ const MessagesTable = () => {
|
|||||||
>
|
>
|
||||||
重发
|
重发
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
|
||||||
size={'small'}
|
<Popup
|
||||||
negative
|
trigger={
|
||||||
loading={loading}
|
<Button size='small' negative>
|
||||||
onClick={() => {
|
删除
|
||||||
deleteMessage(message.id, idx).then();
|
</Button>
|
||||||
}}
|
}
|
||||||
|
on='click'
|
||||||
|
flowing
|
||||||
|
hoverable
|
||||||
>
|
>
|
||||||
删除
|
<Button
|
||||||
</Button>
|
size={'small'}
|
||||||
|
negative
|
||||||
|
loading={loading}
|
||||||
|
onClick={() => {
|
||||||
|
deleteMessage(message.id, idx).then();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
删除消息 #{message.id}
|
||||||
|
</Button>
|
||||||
|
</Popup>
|
||||||
</div>
|
</div>
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
@@ -417,7 +436,15 @@ const MessagesTable = () => {
|
|||||||
) : (
|
) : (
|
||||||
''
|
''
|
||||||
)}
|
)}
|
||||||
{message.content ? <div dangerouslySetInnerHTML={{ __html: marked.parse(message.content) }}></div> : ''}
|
{message.content ? (
|
||||||
|
<div
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: marked.parse(message.content),
|
||||||
|
}}
|
||||||
|
></div>
|
||||||
|
) : (
|
||||||
|
''
|
||||||
|
)}
|
||||||
</Modal.Content>
|
</Modal.Content>
|
||||||
<Modal.Actions>
|
<Modal.Actions>
|
||||||
<Button
|
<Button
|
||||||
|
Reference in New Issue
Block a user