Skip to content

Let's use AI to Earn!

youhua

bulaienaofutuojiesenzhangfbf2264d18c0
diff --git a/src/app/i18n/locales/zh-CN/publish.json b/src/app/i18n/locales/zh-CN/publish.json
index 7e13707c..b6ec7b82 100644
--- a/src/app/i18n/locales/zh-CN/publish.json
+++ b/src/app/i18n/locales/zh-CN/publish.json
@@ -101,7 +101,7 @@
"tiktok": {
"creatorInfo": "创作者信息",
"privacy": {
- "title": "谁可以观看此视频",
+ "title": "谁可以观看",
"placeholder": "请选择隐私级别",
"public": "公开",
"friends": "朋友",
@@ -114,7 +114,7 @@
"stitch": "拼接"
},
"commercial": {
- "title": "披露视频内容",
+ "title": "披露视频",
"toggle": "开启以披露此视频推广商品或服务以换取价值。",
"yourBrand": "您的品牌 - 您正在推广自己或自己的业务。此内容将被分类为品牌有机内容。",
"brandedContent": "品牌内容 - 您正在推广另一个品牌或第三方。此内容将被分类为品牌内容。"
diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/plats/TikTokParams.example.tsx b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/TikTokParams.example.tsx
new file mode 100644
index 00000000..b7391336
--- /dev/null
+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/TikTokParams.example.tsx
@@ -0,0 +1,98 @@
+import React from 'react';
+import TikTokParams from './TikTokParams';
+import { PubItem } from '@/components/PublishDialog/publishDialog.type';
+
+// 示例:如何使用 TikTokParams 组件
+const TikTokParamsExample = () => {
+ // 模拟 TikTok 账户数据
+ const mockPubItem: PubItem = {
+ account: {
+ id: 'tiktok-account-1',
+ account: '68a83465c85b7303d5e4b76e', // TikTok 账户 ID
+ type: 'tiktok',
+ name: 'TikTok Account',
+ avatar: 'https://example.com/avatar.jpg',
+ status: 'active',
+ platform: 'tiktok',
+ },
+ params: {
+ des: '这是一个测试视频描述',
+ title: '测试视频标题',
+ option: {
+ tiktok: {
+ privacy_level: '',
+ comment_disabled: false,
+ duet_disabled: false,
+ stitch_disabled: false,
+ brand_organic_toggle: false,
+ brand_content_toggle: false,
+ },
+ },
+ },
+ };
+
+ return (
+ <div style={{ padding: '20px', maxWidth: '600px' }}>
+ <h2>TikTok 发布参数设置示例</h2>
+ <p>这个组件展示了 TikTok 发布时的所有必要参数设置:</p>
+
+ <ul>
+ <li>✅ 创作者信息显示(头像、昵称、用户名)</li>
+ <li>✅ 隐私级别选择(公开、朋友、仅自己)</li>
+ <li>✅ 用户交互权限(评论、合拍、拼接)</li>
+ <li>✅ 商业内容披露(您的品牌、品牌内容)</li>
+ <li>✅ 合规声明显示</li>
+ </ul>
+
+ <div style={{ border: '1px solid #ddd', borderRadius: '8px', padding: '16px' }}>
+ <TikTokParams pubItem={mockPubItem} />
+ </div>
+
+ <div style={{ marginTop: '20px', padding: '16px', background: '#f5f5f5', borderRadius: '8px' }}>
+ <h3>API 接口说明</h3>
+ <p><strong>获取创作者信息:</strong></p>
+ <code>GET /api/plat/tiktok/creator/info/{tiktok_account_id}</code>
+
+ <h4>响应示例:</h4>
+ <pre style={{ background: '#fff', padding: '10px', borderRadius: '4px', overflow: 'auto' }}>
+{`{
+ "data": {
+ "max_video_post_duration_sec": 3600,
+ "privacy_level_options": [
+ "PUBLIC_TO_EVERYONE",
+ "MUTUAL_FOLLOW_FRIENDS",
+ "SELF_ONLY"
+ ],
+ "stitch_disabled": false,
+ "comment_disabled": false,
+ "creator_avatar_url": "https://...",
+ "creator_nickname": "straydog",
+ "creator_username": "__straydog__",
+ "duet_disabled": false
+ },
+ "code": 0,
+ "message": "请求成功"
+}`}
+ </pre>
+ </div>
+
+ <div style={{ marginTop: '20px', padding: '16px', background: '#e6f7ff', borderRadius: '8px' }}>
+ <h3>符合 TikTok 开发指南</h3>
+ <p>本组件完全符合 <a href="https://developers.tiktok.com/doc/content-sharing-guidelines#required_ux_implementation_in_your_app" target="_blank" rel="noopener noreferrer">TikTok Content Sharing Guidelines</a> 的要求:</p>
+ <ul>
+ <li>✅ 显示创作者昵称和头像</li>
+ <li>✅ 检查创作者发布限制</li>
+ <li>✅ 验证视频时长限制</li>
+ <li>✅ 隐私级别手动选择</li>
+ <li>✅ 交互权限手动设置</li>
+ <li>✅ 商业内容披露功能</li>
+ <li>✅ 合规声明显示</li>
+ <li>✅ 无默认值设置</li>
+ <li>✅ 用户完全控制发布内容</li>
+ </ul>
+ </div>
+ </div>
+ );
+};
+
+export default TikTokParamsExample;
diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/plats/TikTokParams.test.tsx b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/TikTokParams.test.tsx
index 3b060417..df1ccc33 100644
--- a/src/components/PublishDialog/compoents/PlatParamsSetting/plats/TikTokParams.test.tsx
+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/TikTokParams.test.tsx
@@ -18,8 +18,21 @@ jest.mock('@/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatP
}));
jest.mock('@/utils/request', () => ({
- apiRequest: {
- get: jest.fn(),
+ __esModule: true,
+ default: {
+ get: jest.fn().mockResolvedValue({
+ code: 0,
+ data: {
+ max_video_post_duration_sec: 3600,
+ privacy_level_options: ['PUBLIC_TO_EVERYONE', 'MUTUAL_FOLLOW_FRIENDS', 'SELF_ONLY'],
+ stitch_disabled: false,
+ comment_disabled: false,
+ creator_avatar_url: 'https://example.com/avatar.jpg',
+ creator_nickname: 'Test User',
+ creator_username: 'testuser',
+ duet_disabled: false,
+ },
+ }),
},
}));
diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/plats/TikTokParams.tsx b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/TikTokParams.tsx
index d7f184d4..e6f8a99e 100644
--- a/src/components/PublishDialog/compoents/PlatParamsSetting/plats/TikTokParams.tsx
+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/TikTokParams.tsx
@@ -9,7 +9,7 @@ import CommonTitleInput from "@/components/PublishDialog/compoents/PlatParamsSet
import styles from "../platParamsSetting.module.scss";
import { Select, Checkbox, Switch, Alert } from "antd";
import { useTransClient } from "@/app/i18n/client";
-import { apiRequest } from "@/utils/request";
+import http from "@/utils/request";
// TikTok Creator Info 接口类型
interface TikTokCreatorInfo {
@@ -37,9 +37,9 @@ const TikTokParams = memo(
const fetchCreatorInfo = async () => {
try {
setLoading(true);
- const response = await apiRequest.get(`/api/plat/tiktok/creator/info/${pubItem.account.account}`);
- if (response.data.code === 0) {
- setCreatorInfo(response.data.data);
+ const response = await http.get<TikTokCreatorInfo>(`plat/tiktok/creator/info/${pubItem.account.account}`);
+ if (response && response.code === 0) {
+ setCreatorInfo(response.data as TikTokCreatorInfo);
}
} catch (error) {
console.error('Failed to fetch TikTok creator info:', error);
@@ -69,11 +69,11 @@ const TikTokParams = memo(
const getPrivacyLevelLabel = (value: string) => {
switch (value) {
case 'PUBLIC_TO_EVERYONE':
- return t('tiktok.privacy.public');
+ return t('tiktok.privacy.public' as any);
case 'MUTUAL_FOLLOW_FRIENDS':
- return t('tiktok.privacy.friends');
+ return t('tiktok.privacy.friends' as any);
case 'SELF_ONLY':
- return t('tiktok.privacy.private');
+ return t('tiktok.privacy.private' as any);
default:
return value;
}
@@ -84,13 +84,13 @@ const TikTokParams = memo(
const { brand_organic_toggle, brand_content_toggle } = pubItem.params.option.tiktok || {};
if (brand_organic_toggle && brand_content_toggle) {
- return t('tiktok.compliance.both');
+ return t('tiktok.compliance.both' as any);
} else if (brand_content_toggle) {
- return t('tiktok.compliance.branded');
+ return t('tiktok.compliance.branded' as any);
} else if (brand_organic_toggle) {
- return t('tiktok.compliance.organic');
+ return t('tiktok.compliance.organic' as any);
} else {
- return t('tiktok.compliance.default');
+ return t('tiktok.compliance.default' as any);
}
};
@@ -105,13 +105,12 @@ const TikTokParams = memo(
{/* Creator Info Display */}
{creatorInfo && (
<div className={styles.commonTitleInput} style={{ marginTop: "10px" }}>
- <div className="platParamsSetting-label">{t('tiktok.creatorInfo')}</div>
+ <div className="platParamsSetting-label">{t('tiktok.creatorInfo' as any)}</div>
<div style={{
display: 'flex',
alignItems: 'center',
gap: '8px',
padding: '8px',
- background: '#f5f5f5',
borderRadius: '4px'
}}>
<img
@@ -128,7 +127,7 @@ const TikTokParams = memo(
{/* Privacy Level Selection */}
{creatorInfo && (
<div className={styles.commonTitleInput} style={{ marginTop: "10px" }}>
- <div className="platParamsSetting-label">{t('tiktok.privacy.title')}</div>
+ <div className="platParamsSetting-label">{t('tiktok.privacy.title' as any)}</div>
<Select
style={{ width: "100%" }}
value={pubItem.params.option.tiktok?.privacy_level}
@@ -137,7 +136,7 @@ const TikTokParams = memo(
option.tiktok!.privacy_level = value;
setOnePubParams({ option }, pubItem.account.id);
}}
- placeholder={t('tiktok.privacy.placeholder')}
+ placeholder={t('tiktok.privacy.placeholder' as any)}
options={creatorInfo.privacy_level_options.map(level => ({
value: level,
label: getPrivacyLevelLabel(level)
@@ -148,7 +147,7 @@ const TikTokParams = memo(
{/* Allow users to interact */}
<div className={styles.commonTitleInput} style={{ marginTop: "10px" }}>
- <div className="platParamsSetting-label">{t('tiktok.interactions.title')}</div>
+ <div className="platParamsSetting-label">{t('tiktok.interactions.title' as any)}</div>
<div style={{ display: 'flex', flexDirection: 'row', gap: '8px' }}>
<Checkbox
checked={!pubItem.params.option.tiktok?.comment_disabled}
@@ -159,7 +158,7 @@ const TikTokParams = memo(
setOnePubParams({ option }, pubItem.account.id);
}}
>
- {t('tiktok.interactions.comment')}
+ {t('tiktok.interactions.comment' as any)}
</Checkbox>
<Checkbox
checked={!pubItem.params.option.tiktok?.duet_disabled}
@@ -170,7 +169,7 @@ const TikTokParams = memo(
setOnePubParams({ option }, pubItem.account.id);
}}
>
- {t('tiktok.interactions.duet')}
+ {t('tiktok.interactions.duet' as any)}
</Checkbox>
<Checkbox
checked={!pubItem.params.option.tiktok?.stitch_disabled}
@@ -181,14 +180,14 @@ const TikTokParams = memo(
setOnePubParams({ option }, pubItem.account.id);
}}
>
- {t('tiktok.interactions.stitch')}
+ {t('tiktok.interactions.stitch' as any)}
</Checkbox>
</div>
</div>
{/* Commercial Content Disclosure */}
<div className={styles.commonTitleInput} style={{ marginTop: "10px" }}>
- <div className="platParamsSetting-label">{t('tiktok.commercial.title')}</div>
+ <div className="platParamsSetting-label">{t('tiktok.commercial.title' as any)}</div>
<div style={{ marginBottom: '8px' }}>
<Switch
checked={pubItem.params.option.tiktok?.brand_organic_toggle || pubItem.params.option.tiktok?.brand_content_toggle}
@@ -201,7 +200,7 @@ const TikTokParams = memo(
setOnePubParams({ option }, pubItem.account.id);
}}
/>
- <span style={{ marginLeft: '8px', fontSize: '11px' }}>{t('tiktok.commercial.toggle')}</span>
+ <span style={{ marginLeft: '8px', fontSize: '11px' }}>{t('tiktok.commercial.toggle' as any)}</span>
</div>
{(pubItem.params.option.tiktok?.brand_organic_toggle || pubItem.params.option.tiktok?.brand_content_toggle) && (
@@ -214,7 +213,7 @@ const TikTokParams = memo(
setOnePubParams({ option }, pubItem.account.id);
}}
>
- {t('tiktok.commercial.yourBrand')}
+ {t('tiktok.commercial.yourBrand' as any)}
</Checkbox>
<Checkbox
checked={pubItem.params.option.tiktok?.brand_content_toggle}
@@ -224,7 +223,7 @@ const TikTokParams = memo(
setOnePubParams({ option }, pubItem.account.id);
}}
>
- {t('tiktok.commercial.brandedContent')}
+ {t('tiktok.commercial.brandedContent' as any)}
</Checkbox>
</div>
)}
diff --git a/src/components/PublishDialog/publishDialog.type.ts b/src/components/PublishDialog/publishDialog.type.ts
index 05bad13b..1213c8a5 100644
--- a/src/components/PublishDialog/publishDialog.type.ts
+++ b/src/components/PublishDialog/publishDialog.type.ts
@@ -71,6 +71,20 @@ export interface IPlatOption {
// Board ID,由获取Pinterest Board信息接口得到
boardId?: string;
};
+ tiktok?: {
+ // 隐私级别:PUBLIC_TO_EVERYONE、MUTUAL_FOLLOW_FRIENDS、SELF_ONLY
+ privacy_level?: string;
+ // 是否禁用评论
+ comment_disabled?: boolean;
+ // 是否禁用合拍
+ duet_disabled?: boolean;
+ // 是否禁用拼接
+ stitch_disabled?: boolean;
+ // 品牌有机内容开关
+ brand_organic_toggle?: boolean;
+ // 品牌内容开关
+ brand_content_toggle?: boolean;
+ };
}
// 发布参数