Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
add params
bulaienaofutuojiesenzhang94609af52de9
diff --git a/src/app/i18n/locales/en/publish.json b/src/app/i18n/locales/en/publish.jsonindex 2f6cb0ea..313d73a3 100644--- a/src/app/i18n/locales/en/publish.json+++ b/src/app/i18n/locales/en/publish.json@@ -46,6 +46,10 @@"private": "Private","region": "Region","regionPlaceholder": "Select region",+ "license": "License",+ "licensePlaceholder": "Select license",+ "standardYouTubeLicense": "Standard YouTube License",+ "creativeCommonsLicense": "Creative Commons License","category": "Category","categoryPlaceholder": "Select category","categoryPlaceholderDisabled": "Select region first",diff --git a/src/app/i18n/locales/zh-CN/publish.json b/src/app/i18n/locales/zh-CN/publish.jsonindex 2867d95d..b19686f0 100644--- a/src/app/i18n/locales/zh-CN/publish.json+++ b/src/app/i18n/locales/zh-CN/publish.json@@ -46,6 +46,10 @@"private": "私人","region": "国区","regionPlaceholder": "请选择国区",+ "license": "许可证",+ "licensePlaceholder": "请选择许可证",+ "standardYouTubeLicense": "标准 YouTube 许可证",+ "creativeCommonsLicense": "知识共享许可证","category": "视频分类","categoryPlaceholder": "请选择视频分类","categoryPlaceholderDisabled": "请先选择国区",diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/plats/YouTubeParams.tsx b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/YouTubeParams.tsxindex 41d71298..fe04b461 100644--- a/src/components/PublishDialog/compoents/PlatParamsSetting/plats/YouTubeParams.tsx+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/YouTubeParams.tsx@@ -19,23 +19,19 @@ const YouTubeParams = memo(const { t } = useTransClient("publish");const { pubParmasTextareaCommonParams, setOnePubParams } =usePlatParamsCommon(pubItem);- const {- getYouTubeRegions,- getYouTubeCategories,- youTubeRegions,- youTubeCategories+ const {+ getYouTubeCategories,+ youTubeCategories} = usePublishDialogData(useShallow((state) => ({- getYouTubeRegions: state.getYouTubeRegions,getYouTubeCategories: state.getYouTubeCategories,- youTubeRegions: state.youTubeRegions,youTubeCategories: state.youTubeCategories,})),);useEffect(() => {- getYouTubeRegions();- }, [getYouTubeRegions]);+ getYouTubeCategories();+ }, [getYouTubeCategories]);// 初始化YouTube参数useEffect(() => {@@ -44,11 +40,15 @@ const YouTubeParams = memo(option.youtube = {};}let needsUpdate = false;-+if (!option.youtube.privacyStatus) {option.youtube.privacyStatus = 'public';needsUpdate = true;}+ if (!option.youtube.license) {+ option.youtube.license = 'youtube';+ needsUpdate = true;+ }if ((option.youtube as any).notifySubscribers === undefined) {(option.youtube as any).notifySubscribers = true;needsUpdate = true;@@ -61,7 +61,7 @@ const YouTubeParams = memo((option.youtube as any).selfDeclaredMadeForKids = false;needsUpdate = true;}-+if (needsUpdate) {setOnePubParams({@@ -72,13 +72,6 @@ const YouTubeParams = memo(}}, [pubItem.account.id]);- // 当国区变化时,重新获取视频分类- useEffect(() => {- const regionCode = pubItem.params.option.youtube?.regionCode;- if (regionCode) {- getYouTubeCategories(regionCode);- }- }, [pubItem.params.option.youtube?.regionCode, getYouTubeCategories]);return (<>@@ -88,115 +81,115 @@ const YouTubeParams = memo(<><CommonTitleInput pubItem={pubItem} />- <div- className={styles.commonTitleInput}- style={{ marginTop: "10px" }}- >- <div className="platParamsSetting-label">{t("form.region")}</div>- <Select- style={{ width: "100%" }}- options={youTubeRegions.map((item) => ({- label: item,- value: item,- }))}- value={pubItem.params.option.youtube?.regionCode}- onChange={(value) => {- const option = pubItem.params.option;- if (!option.youtube) {- option.youtube = {};- }- option.youtube.regionCode = value;- // 清空之前选择的视频分类- option.youtube.categoryId = undefined;- setOnePubParams(- {- option,- },- pubItem.account.id,- );- }}- showSearch={true}- placeholder={t("form.regionPlaceholder")}- />- </div>- <div style={{display: 'flex', flexDirection: 'row', alignItems: 'center', gap: '10px'}}>+ <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', gap: '10px' }}>- <div- className={styles.commonTitleInput}- style={{ marginTop: "10px", flex: 1 }}- >- <div className="platParamsSetting-label">{t("form.privacyStatus")}</div>- <Select- value={pubItem.params.option.youtube?.privacyStatus}- options={[- { value: "public", label: t("form.public") },- { value: "unlisted", label: t("form.unlisted") },- { value: "private", label: t("form.private") },- ]}- onChange={(value) => {- const option = pubItem.params.option;- if (!option.youtube) {- option.youtube = {};- }- option.youtube.privacyStatus = value;- setOnePubParams(- {- option,- },- pubItem.account.id,- );- }}- style={{ width: "100%" }}- placeholder="请选择隐私状态"- />- </div>- <div- className={styles.commonTitleInput}- style={{ marginTop: "10px", flex: 1 }}- >- <div className="platParamsSetting-label">{t("form.category")}</div>- <Select- style={{ width: "100%" }}- options={youTubeCategories.map((item) => ({- label: item.snippet.title,- value: item.id,- }))}- value={pubItem.params.option.youtube?.categoryId}- onChange={(value) => {- const option = pubItem.params.option;- if (!option.youtube) {- option.youtube = {};- }- option.youtube.categoryId = value;- setOnePubParams(- {- option,- },- pubItem.account.id,- );- }}- showSearch={true}- placeholder={pubItem.params.option.youtube?.regionCode ? t("form.categoryPlaceholder") : t("form.categoryPlaceholderDisabled")}- disabled={!pubItem.params.option.youtube?.regionCode}- />- </div>+++ <div+ className={styles.commonTitleInput}+ style={{ marginTop: "10px", flex: 1 }}+ >+ <div className="platParamsSetting-label">{t("form.category")}</div>+ <Select+ style={{ width: "100%" }}+ options={youTubeCategories.map((item) => ({+ label: item.snippet.title,+ value: item.id,+ }))}+ value={pubItem.params.option.youtube?.categoryId}+ onChange={(value) => {+ const option = pubItem.params.option;+ if (!option.youtube) {+ option.youtube = {};+ }+ option.youtube.categoryId = value;+ setOnePubParams(+ {+ option,+ },+ pubItem.account.id,+ );+ }}+ showSearch={true}+ placeholder={t("form.categoryPlaceholder")}+ />+ </div>++ <div+ className={styles.commonTitleInput}+ style={{ marginTop: "10px", flex: 1 }}+ >+ <div className="platParamsSetting-label">{t("form.privacyStatus")}</div>+ <Select+ value={pubItem.params.option.youtube?.privacyStatus}+ options={[+ { value: "public", label: t("form.public") },+ { value: "unlisted", label: t("form.unlisted") },+ { value: "private", label: t("form.private") },+ ]}+ onChange={(value) => {+ const option = pubItem.params.option;+ if (!option.youtube) {+ option.youtube = {};+ }+ option.youtube.privacyStatus = value;+ setOnePubParams(+ {+ option,+ },+ pubItem.account.id,+ );+ }}+ style={{ width: "100%" }}+ placeholder="请选择隐私状态"+ />+ </div></div>+ <div+ className={styles.commonTitleInput}+ style={{ marginTop: "10px" }}+ >+ <div className="platParamsSetting-label">{t("form.license" as any)}</div>+ <Select+ style={{ width: "100%" }}+ options={[+ { value: "youtube", label: t("form.standardYouTubeLicense" as any) },+ { value: "creativeCommon", label: t("form.creativeCommonsLicense" as any) },+ ]}+ value={pubItem.params.option.youtube?.license}+ onChange={(value) => {+ const option = pubItem.params.option;+ if (!option.youtube) {+ option.youtube = {};+ }+ option.youtube.license = value;+ setOnePubParams(+ {+ option,+ },+ pubItem.account.id,+ );+ }}+ placeholder={t("form.licensePlaceholder" as any)}+ />+ </div>+{/* YouTube 复选框选项 */}- <div style={{- display: 'flex',- flexDirection: 'row',+ <div style={{+ display: 'flex',+ flexDirection: 'row',alignItems: 'center',justifyContent: 'space-between',marginTop: '20px',flexWrap: 'wrap'}}>- <div style={{width: '40px'}}> </div>+ <div style={{ width: '40px' }}> </div><Checkboxchecked={(pubItem.params.option.youtube as any)?.notifySubscribers}onChange={(e) => {diff --git a/src/components/PublishDialog/publishDialog.type.ts b/src/components/PublishDialog/publishDialog.type.tsindex 4c6e12a4..62efa96d 100644--- a/src/components/PublishDialog/publishDialog.type.ts+++ b/src/components/PublishDialog/publishDialog.type.ts@@ -62,8 +62,8 @@ export interface IPlatOption {youtube?: {// 隐私状态:public、unlisted、privateprivacyStatus?: string;- // 国区代码- regionCode?: string;+ // 许可证类型:youtube、creativeCommon+ license?: string;// 视频分类IDcategoryId?: string;// 是否通知订阅者