feat: 佣金提现和备注功能
This commit is contained in:
@@ -6,6 +6,7 @@ import useGlobalStore from '@/config/use-global';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { Button } from '@workspace/airo-ui/components/button';
|
||||
import { cn } from '@workspace/airo-ui/lib/utils';
|
||||
import { isBrowser } from '@workspace/airo-ui/utils';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
||||
import { toast } from 'sonner';
|
||||
@@ -15,7 +16,7 @@ const CopyShortenedLink = ({ className }: { className?: string }) => {
|
||||
const { user } = useGlobalStore();
|
||||
|
||||
// 构建长链接,使用用户的唯一标识符作为查询键
|
||||
const target = `${location?.origin}/?invite=${user?.refer_code}`;
|
||||
const target = isBrowser ? `${location?.origin}/?invite=${user?.refer_code}` : '';
|
||||
const queryKey = ['short-url', user?.refer_code];
|
||||
|
||||
const { data: shortUrl } = useQuery({
|
||||
@@ -35,10 +36,9 @@ const CopyShortenedLink = ({ className }: { className?: string }) => {
|
||||
|
||||
// 关键步骤:解析 JSON 数据并返回
|
||||
const json = await response.json();
|
||||
console.log('CopyShortened link', json);
|
||||
return json.link ?? null;
|
||||
},
|
||||
enabled: !!user?.refer_code, // 默认不自动执行
|
||||
enabled: !!(user?.refer_code && target), // 默认不自动执行
|
||||
staleTime: Infinity, // 数据永不过期,除非手动失效
|
||||
});
|
||||
// 渲染组件
|
||||
|
||||
@@ -340,12 +340,12 @@ const TabContent: React.FC<TabContentProps> = ({
|
||||
|
||||
// 使用 useMemo 优化数据处理性能
|
||||
const yearlyPlans: PlanProps[] = useMemo(
|
||||
() => (subscribeData || []).map((item) => processPlanData(item, true)),
|
||||
() => subscribeData?.map((item) => processPlanData(item, true)),
|
||||
[subscribeData],
|
||||
);
|
||||
|
||||
const monthlyPlans: PlanProps[] = useMemo(
|
||||
() => (subscribeData || []).map((item) => processPlanData(item, false)),
|
||||
() => subscribeData?.map((item) => processPlanData(item, false)),
|
||||
[subscribeData],
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user