mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-05-09 18:27:56 +08:00
unfinish
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import axios from "axios";
|
||||
import { GlobalConf, TokenResp, SubscribeResp, TargetNameResp, CreateSubscribeReq } from "../utils/type";
|
||||
import { GlobalConf, TokenResp, SubscribeResp, TargetNameResp, SubscribeConfig } from "../utils/type";
|
||||
import { baseUrl } from './utils';
|
||||
|
||||
export async function getGlobalConf(): Promise<GlobalConf> {
|
||||
@@ -22,7 +22,7 @@ export async function getTargetName(platformName: string, target: string): Promi
|
||||
return res.data;
|
||||
}
|
||||
|
||||
export async function addSubscribe(groupNumber: string, req: CreateSubscribeReq) {
|
||||
export async function addSubscribe(groupNumber: string, req: SubscribeConfig) {
|
||||
const res = await axios.post(`${baseUrl}subs`, req, {params: {groupNumber}})
|
||||
return res.data;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { ReactElement, useContext, useEffect, useState } from "react";
|
||||
import React, { FC, ReactElement, ReactNode, useContext, useEffect, useState } from "react";
|
||||
import { LoginContext, GlobalConfContext } from "../utils/context";
|
||||
import { Layout, Menu, Empty, Collapse, Card, Tag, Row, Col, Form, Tooltip, Button, Modal, Select,
|
||||
Input, Popconfirm} from 'antd';
|
||||
Input, Popconfirm, message } from 'antd';
|
||||
import { SubscribeConfig, SubscribeResp, PlatformConfig, CategoryConfig } from '../utils/type';
|
||||
import { SettingOutlined, BugOutlined, DeleteOutlined, CopyOutlined } from '@ant-design/icons';
|
||||
import { getSubscribe, getTargetName, addSubscribe, delSubscribe } from '../api/config';
|
||||
@@ -74,7 +74,9 @@ function ConfigPage(prop: ConfigPageProp) {
|
||||
onConfirm={handleDelete(groupNumber, config.platformName, config.target || 'default')}>
|
||||
<Tooltip title="删除" ><DeleteOutlined /></Tooltip>
|
||||
</Popconfirm>,
|
||||
<Tooltip title="添加到其他群"><CopyOutlined /></Tooltip>
|
||||
<TargetGroupSelection config={config} groups={configData}>
|
||||
<Tooltip title="添加到其他群"><CopyOutlined /></Tooltip>
|
||||
</TargetGroupSelection>
|
||||
]}>
|
||||
<Form labelCol={{ span: 6 }}>
|
||||
<Form.Item label="订阅类型">
|
||||
@@ -119,6 +121,43 @@ function ConfigPage(prop: ConfigPageProp) {
|
||||
}
|
||||
}
|
||||
|
||||
interface TargetGroupSelectionProp {
|
||||
config: SubscribeConfig,
|
||||
groups: SubscribeResp
|
||||
children: ReactNode
|
||||
}
|
||||
function TargetGroupSelection({ config, groups, children }: TargetGroupSelectionProp) {
|
||||
let [ selectedGroups, setSelectGroups ] = useState<Array<string>>([]);
|
||||
const submitCopy = () => {
|
||||
let promise = null
|
||||
for (let selectGroup of selectedGroups) {
|
||||
if (! promise) {
|
||||
promise = addSubscribe(selectGroup, config)
|
||||
} else {
|
||||
promise = promise.then(() => addSubscribe(selectGroup, config))
|
||||
}
|
||||
}
|
||||
if (promise) {
|
||||
promise.then(() => message.success("复制订阅成功"))
|
||||
}
|
||||
return promise;
|
||||
}
|
||||
return <>
|
||||
<Popconfirm title={
|
||||
<Select mode="multiple" onChange={(value: Array<string>) => setSelectGroups(value)}>
|
||||
{
|
||||
Object.keys(groups).map((groupNumber) =>
|
||||
<Select.Option value={groupNumber} key={groupNumber}>
|
||||
{`${groupNumber} - ${groups[groupNumber].name}`}
|
||||
</Select.Option>)
|
||||
}
|
||||
</Select>
|
||||
} onConfirm={submitCopy} >
|
||||
{ children }
|
||||
</Popconfirm>
|
||||
</>
|
||||
}
|
||||
|
||||
interface InputTagCustomProp {
|
||||
value?: Array<string>,
|
||||
onChange?: (value: Array<string>) => void,
|
||||
|
||||
@@ -19,7 +19,7 @@ export type LoginContextType = {
|
||||
|
||||
export interface SubscribeConfig {
|
||||
platformName: string
|
||||
target?: string
|
||||
target: string
|
||||
targetName: string
|
||||
cats: Array<number>
|
||||
tags: Array<string>
|
||||
@@ -66,11 +66,3 @@ export interface SubscribeResp {
|
||||
export interface TargetNameResp {
|
||||
targetName: string
|
||||
}
|
||||
|
||||
export interface CreateSubscribeReq {
|
||||
platformName: string,
|
||||
targetName: string,
|
||||
target: string,
|
||||
categories: Array<string>,
|
||||
tags: Array<string>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user