feat: 邀请码管理面板增加复制邀请链接功能

并调整邀请码删除功能,从文本按钮改为图标按钮
pull/81/head
moonrailgun 3 years ago
parent 60339fda39
commit 7e7d1a28ca

@ -176,6 +176,7 @@
"kb8185132": "Or", "kb8185132": "Or",
"kbcb00ae5": "There is no further description for this plugin", "kbcb00ae5": "There is no further description for this plugin",
"kbcf55e47": "User Service", "kbcf55e47": "User Service",
"kbef193d": "Invitation link copied to clipboard",
"kbef5b92e": "Copy Link", "kbef5b92e": "Copy Link",
"kc14b2ea3": "Back", "kc14b2ea3": "Back",
"kc1afdd08": "Don't worry, you can make changes anytime after this", "kc1afdd08": "Don't worry, you can make changes anytime after this",
@ -232,6 +233,7 @@
"kf1eac01c": "Failed to load group information", "kf1eac01c": "Failed to load group information",
"kf22210a": "Loading plugin list", "kf22210a": "Loading plugin list",
"kf3fa6059": "You can use the complete <1>nickname#identifier</1> to add friends", "kf3fa6059": "You can use the complete <1>nickname#identifier</1> to add friends",
"kf4567a1": "Copy the invitation link",
"kf48ae58": "Group information not found", "kf48ae58": "Group information not found",
"kf5861d84": "No friend requests have been sent yet", "kf5861d84": "No friend requests have been sent yet",
"kf5d66247": "Panel Name", "kf5d66247": "Panel Name",

@ -176,6 +176,7 @@
"kb8185132": "或", "kb8185132": "或",
"kbcb00ae5": "该插件没有更多描述", "kbcb00ae5": "该插件没有更多描述",
"kbcf55e47": "用户服务", "kbcf55e47": "用户服务",
"kbef193d": "邀请链接已复制到剪切板",
"kbef5b92e": "复制链接", "kbef5b92e": "复制链接",
"kc14b2ea3": "返回", "kc14b2ea3": "返回",
"kc1afdd08": "不要担心, 在此之后你可以随时进行变更", "kc1afdd08": "不要担心, 在此之后你可以随时进行变更",
@ -232,6 +233,7 @@
"kf1eac01c": "群组信息加载失败", "kf1eac01c": "群组信息加载失败",
"kf22210a": "正在加载插件列表", "kf22210a": "正在加载插件列表",
"kf3fa6059": "您可以使用完整的 <1>用户昵称#标识</1> 来添加好友", "kf3fa6059": "您可以使用完整的 <1>用户昵称#标识</1> 来添加好友",
"kf4567a1": "复制邀请链接",
"kf48ae58": "找不到群组信息", "kf48ae58": "找不到群组信息",
"kf5861d84": "暂无已发送的好友请求", "kf5861d84": "暂无已发送的好友请求",
"kf5d66247": "面板名", "kf5d66247": "面板名",

@ -1,4 +1,5 @@
import { InviteCodeExpiredAt } from '@/components/InviteCodeExpiredAt'; import { InviteCodeExpiredAt } from '@/components/InviteCodeExpiredAt';
import { generateInviteCodeUrl } from '@/utils/url-helper';
import { Menu, Typography, Dropdown } from 'antd'; import { Menu, Typography, Dropdown } from 'antd';
import React, { useState } from 'react'; import React, { useState } from 'react';
import { import {
@ -49,7 +50,7 @@ export const CreateInviteCode: React.FC<CreateInviteCodeProps> = React.memo(
level={4} level={4}
copyable={true} copyable={true}
> >
{`${location.origin}/invite/${createdInvite.code}`} {generateInviteCodeUrl(createdInvite.code)}
</Typography.Title> </Typography.Title>
<p className="text-gray-500 text-sm"> <p className="text-gray-500 text-sm">
<InviteCodeExpiredAt invite={createdInvite} /> <InviteCodeExpiredAt invite={createdInvite} />

@ -7,13 +7,17 @@ import {
formatFullTime, formatFullTime,
deleteGroupInvite, deleteGroupInvite,
useAsyncRefresh, useAsyncRefresh,
showToasts,
} from 'tailchat-shared'; } from 'tailchat-shared';
import { Button, Table, Tooltip } from 'antd'; import { Button, Space, Table, Tooltip } from 'antd';
import type { ColumnType } from 'antd/lib/table'; import type { ColumnType } from 'antd/lib/table';
import { UserName } from '@/components/UserName'; import { UserName } from '@/components/UserName';
import { openModal, openReconfirmModalP } from '@/components/Modal'; import { openModal, openReconfirmModalP } from '@/components/Modal';
import { CreateGroupInvite } from '../CreateGroupInvite'; import { CreateGroupInvite } from '../CreateGroupInvite';
import { LoadingOnFirst } from '@/components/LoadingOnFirst'; import { LoadingOnFirst } from '@/components/LoadingOnFirst';
import { IconBtn } from '@/components/IconBtn';
import copy from 'copy-to-clipboard';
import { generateInviteCodeUrl } from '@/utils/url-helper';
export const GroupInvite: React.FC<{ export const GroupInvite: React.FC<{
groupId: string; groupId: string;
@ -36,6 +40,11 @@ export const GroupInvite: React.FC<{
); );
}, [groupId, refresh]); }, [groupId, refresh]);
const handleCopyInviteCode = useCallback((inviteCode: string) => {
copy(generateInviteCodeUrl(inviteCode));
showToasts(t('邀请链接已复制到剪切板'), 'success');
}, []);
const handleDeleteInvite = useCallback( const handleDeleteInvite = useCallback(
async (inviteId: string) => { async (inviteId: string) => {
if (await openReconfirmModalP()) { if (await openReconfirmModalP()) {
@ -84,22 +93,28 @@ export const GroupInvite: React.FC<{
{ {
title: t('操作'), title: t('操作'),
dataIndex: '_id', dataIndex: '_id',
render: (id: string) => { render: (id: string, record) => {
return ( return (
<div> <Space>
<Button <IconBtn
type="primary" title={t('复制邀请链接')}
shape="square"
icon="mdi:content-copy"
onClick={() => handleCopyInviteCode(record.code)}
/>
<IconBtn
title={t('删除')}
shape="square"
icon="mdi:delete-outline"
danger={true} danger={true}
onClick={() => handleDeleteInvite(id)} onClick={() => handleDeleteInvite(id)}
> />
{t('删除')} </Space>
</Button>
</div>
); );
}, },
}, },
], ],
[handleDeleteInvite] [handleCopyInviteCode, handleDeleteInvite]
); );
return ( return (

@ -20,3 +20,11 @@ export function appendUrlSearch(obj: Record<string, string>): string {
...obj, ...obj,
}); });
} }
/**
*
* @param inviteCode
*/
export function generateInviteCodeUrl(inviteCode: string) {
return `${location.origin}/invite/${inviteCode}`;
}

Loading…
Cancel
Save