mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-07 20:33:01 +08:00
feat: support mobile platfrom
This commit is contained in:
parent
5e36b7d7ec
commit
1716ecb0f4
@ -24,7 +24,7 @@ export default function GroupManager() {
|
|||||||
<Grid.Row gutter={20}>
|
<Grid.Row gutter={20}>
|
||||||
{ Object.keys(subs).map(
|
{ Object.keys(subs).map(
|
||||||
(groupNumber: string) => (
|
(groupNumber: string) => (
|
||||||
<Grid.Col span={6} key={groupNumber}>
|
<Grid.Col xs={24} sm={12} md={8} lg={6} key={groupNumber} style={{ margin: '1em 0' }}>
|
||||||
<Card
|
<Card
|
||||||
title={subs[groupNumber].name}
|
title={subs[groupNumber].name}
|
||||||
actions={[
|
actions={[
|
||||||
|
@ -36,45 +36,45 @@ export default function SubscribeManager() {
|
|||||||
render: (col: string, record: SubscribeConfig) => (
|
render: (col: string, record: SubscribeConfig) => (
|
||||||
<span>{platformConf[record.platformName].name}</span>
|
<span>{platformConf[record.platformName].name}</span>
|
||||||
),
|
),
|
||||||
|
width: '7em',
|
||||||
},
|
},
|
||||||
{ title: '帐号名称', dataIndex: 'targetName' },
|
{ title: '帐号名称', dataIndex: 'targetName', width: '10em' },
|
||||||
{ title: '订阅帐号', dataIndex: 'target' },
|
{ title: '订阅帐号', dataIndex: 'target', width: '10em' },
|
||||||
{
|
{
|
||||||
title: '订阅分类',
|
title: '订阅分类',
|
||||||
dataIndex: 'cats',
|
dataIndex: 'cats',
|
||||||
|
ellipsis: true,
|
||||||
render: (col: string[], record: SubscribeConfig) => (
|
render: (col: string[], record: SubscribeConfig) => (
|
||||||
<span>
|
<Space wrap>
|
||||||
<Space>
|
{
|
||||||
{
|
record.cats.map((catNumber: number) => (
|
||||||
record.cats.map((catNumber: number) => (
|
<Tag>{platformConf[record.platformName].categories[catNumber]}</Tag>
|
||||||
<Tag>{platformConf[record.platformName].categories[catNumber]}</Tag>
|
))
|
||||||
))
|
}
|
||||||
}
|
</Space>
|
||||||
</Space>
|
|
||||||
</span>
|
|
||||||
),
|
),
|
||||||
|
width: '20em',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '订阅标签',
|
title: '订阅标签',
|
||||||
dataIndex: 'tags',
|
dataIndex: 'tags',
|
||||||
render: (col: string[], record: SubscribeConfig) => (
|
render: (col: string[], record: SubscribeConfig) => (
|
||||||
<span>
|
<Space wrap>
|
||||||
<Space>
|
{
|
||||||
{
|
record.tags.length === 0 ? <Tag color="green">全部标签</Tag>
|
||||||
record.tags.length === 0 ? <Tag color="green">全部标签</Tag>
|
: record.tags.map((tag: string) => (
|
||||||
: record.tags.map((tag: string) => (
|
<Tag color="blue">{tag}</Tag>
|
||||||
<Tag color="blue">{tag}</Tag>
|
))
|
||||||
))
|
}
|
||||||
}
|
</Space>
|
||||||
</Space>
|
|
||||||
</span>
|
|
||||||
),
|
),
|
||||||
|
width: '20em',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
dataIndex: 'op',
|
dataIndex: 'op',
|
||||||
render: (_: null, record: SubscribeConfig) => (
|
render: (_: null, record: SubscribeConfig) => (
|
||||||
<Space>
|
<Space size="small">
|
||||||
<Button type="text" onClick={handleEdit(record)}>编辑</Button>
|
<Button type="text" onClick={handleEdit(record)}>编辑</Button>
|
||||||
<Button type="text" status="success" onClick={() => Message.error('懒得写了')}>复制</Button>
|
<Button type="text" status="success" onClick={() => Message.error('懒得写了')}>复制</Button>
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
@ -91,6 +91,7 @@ export default function SubscribeManager() {
|
|||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
|
width: '16em',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -107,6 +108,7 @@ export default function SubscribeManager() {
|
|||||||
data={subs[groupNumber].subscribes}
|
data={subs[groupNumber].subscribes}
|
||||||
rowKey={(record: SubscribeConfig) => `${record.platformName}-${record.target}`}
|
rowKey={(record: SubscribeConfig) => `${record.platformName}-${record.target}`}
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
|
scroll={{ x: true }}
|
||||||
/>
|
/>
|
||||||
<SubscribeModal
|
<SubscribeModal
|
||||||
visible={showModal}
|
visible={showModal}
|
||||||
|
@ -9,6 +9,7 @@ import { selectPlatformConf } from '../globalConf/globalConfSlice';
|
|||||||
import { CategoryConfig, SubscribeConfig } from '../../utils/type';
|
import { CategoryConfig, SubscribeConfig } from '../../utils/type';
|
||||||
import getTargetName from '../targetName/targetNameReq';
|
import getTargetName from '../targetName/targetNameReq';
|
||||||
import { useUpdateSubMutation, useNewSubMutation } from './subscribeConfigSlice';
|
import { useUpdateSubMutation, useNewSubMutation } from './subscribeConfigSlice';
|
||||||
|
import useWindowDimensions from '../../utils/hooks';
|
||||||
|
|
||||||
function SubscribeTag({
|
function SubscribeTag({
|
||||||
value, onChange, disabled,
|
value, onChange, disabled,
|
||||||
@ -68,6 +69,7 @@ function SubscribeModal({
|
|||||||
const [updateSub] = useUpdateSubMutation();
|
const [updateSub] = useUpdateSubMutation();
|
||||||
const [newSub] = useNewSubMutation();
|
const [newSub] = useNewSubMutation();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
const { width } = useWindowDimensions();
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
form.validate().then((value: SubscribeConfig) => {
|
form.validate().then((value: SubscribeConfig) => {
|
||||||
@ -147,9 +149,11 @@ function SubscribeModal({
|
|||||||
onCancel={() => setVisible(false)}
|
onCancel={() => setVisible(false)}
|
||||||
confirmLoading={confirmLoading}
|
confirmLoading={confirmLoading}
|
||||||
onOk={onSubmit}
|
onOk={onSubmit}
|
||||||
|
style={{ maxWidth: '90vw' }}
|
||||||
>
|
>
|
||||||
<Form
|
<Form
|
||||||
form={form}
|
form={form}
|
||||||
|
layout={width > 520 ? 'horizontal' : 'vertical'}
|
||||||
>
|
>
|
||||||
<Form.Item label="平台" field="platformName">
|
<Form.Item label="平台" field="platformName">
|
||||||
<Select placeholder="平台" onChange={handlePlatformSelected}>
|
<Select placeholder="平台" onChange={handlePlatformSelected}>
|
||||||
|
@ -89,7 +89,10 @@ export default function Home() {
|
|||||||
</span>
|
</span>
|
||||||
</Layout.Header>
|
</Layout.Header>
|
||||||
<Layout className="layout-collapse-demo">
|
<Layout className="layout-collapse-demo">
|
||||||
<Layout.Sider>
|
<Layout.Sider
|
||||||
|
collapsible
|
||||||
|
breakpoint="lg"
|
||||||
|
>
|
||||||
<Menu
|
<Menu
|
||||||
defaultSelectedKeys={[selectedTab]}
|
defaultSelectedKeys={[selectedTab]}
|
||||||
onClickMenuItem={(key) => { handleTabSelect(key); }}
|
onClickMenuItem={(key) => { handleTabSelect(key); }}
|
||||||
@ -104,10 +107,10 @@ export default function Home() {
|
|||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
</Menu>
|
</Menu>
|
||||||
</Layout.Sider>
|
</Layout.Sider>
|
||||||
<Layout.Content style={{ padding: '0 24px' }}>
|
<Layout.Content style={{ padding: '0 1em' }}>
|
||||||
<Layout style={{ height: '100%' }}>
|
<Layout style={{ height: '100%' }}>
|
||||||
{ breadcrumbContent }
|
{ breadcrumbContent }
|
||||||
<Layout.Content style={{ margin: '10px', padding: '40px' }}>
|
<Layout.Content style={{ margin: '0.5em', padding: '2em' }}>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</Layout.Content>
|
</Layout.Content>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
24
admin-frontend/src/utils/hooks.ts
Normal file
24
admin-frontend/src/utils/hooks.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { useState, useEffect } from 'react';
|
||||||
|
|
||||||
|
function getWindowDimensions() {
|
||||||
|
const { innerWidth: width, innerHeight: height } = window;
|
||||||
|
return {
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function useWindowDimensions() {
|
||||||
|
const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions());
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
function handleResize() {
|
||||||
|
setWindowDimensions(getWindowDimensions());
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('resize', handleResize);
|
||||||
|
return () => window.removeEventListener('resize', handleResize);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return windowDimensions;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user