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

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

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

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

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

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

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

Loading…
Cancel
Save