Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
多语言和注册携带密码
daoyianc060556ce220
diff --git a/@types/resources.d.ts b/@types/resources.d.tsindex 1f2eee5b..8f1de53c 100644--- a/@types/resources.d.ts+++ b/@types/resources.d.ts@@ -626,6 +626,25 @@ interface Resources {"category": "视频分类","categoryPlaceholder": "请选择视频分类","categoryPlaceholderDisabled": "请先选择国区"+ },+ "upload": {+ "finishingUp": "正在完成...",+ "uploadImageOrVideo": "上传图片或视频",+ "dragAndSelect": "拖放 & 选择图片或视频"+ },+ "validation": {+ "uploadImageOrVideo": "请上传图片或视频",+ "topicMaxExceeded": "{{platformName}}话题最多不能超过{{maxCount}}个",+ "topicFormatError": "描述中的话题必须使用空格分割,如:\"#话题1 #话题2\"",+ "titleRequired": "标题是必须的",+ "partitionRequired": "您必须选择分区!",+ "sourceRequired": "转载时必须填写转载来源!",+ "pageRequired": "您必须选择页面!",+ "coverSizeError": "封面最小尺寸400*400!"+ },+ "preview": {+ "title": "预览",+ "emptyDescription": "在这里看到你的作品预览"}}}diff --git a/src/app/[lng]/login/page.tsx b/src/app/[lng]/login/page.tsxindex d3af27c3..2cd70858 100644--- a/src/app/[lng]/login/page.tsx+++ b/src/app/[lng]/login/page.tsx@@ -40,8 +40,9 @@ export default function LoginPage() {if (response.code === 0) {if (response.data.type === 'regist') {- // 用户未注册,显示弹窗提示+ // 用户未注册,显示弹窗提示,并设置表单的默认密码值setRegistCode(response.data.code || '');+ form.setFieldsValue({ password: password }); // 设置密码字段的默认值setIsModalOpen(true);setIsChecking(true);} else if (response.data.token) {@@ -86,6 +87,7 @@ export default function LoginPage() {setIsActivating(false);setIsChecking(false);setIsModalOpen(false);+ form.resetFields(); // 重置表单setToken(response.data.token);if (response.data.userInfo) {setUserInfo(response.data.userInfo);@@ -215,6 +217,7 @@ export default function LoginPage() {setIsModalOpen(false);setIsChecking(false);setIsActivating(false);+ form.resetFields(); // 重置表单if (activationTimer) {clearInterval(activationTimer);}diff --git a/src/app/i18n/locales/en/publish.json b/src/app/i18n/locales/en/publish.jsonindex 37488481..06bdbc07 100644--- a/src/app/i18n/locales/en/publish.json+++ b/src/app/i18n/locales/en/publish.json@@ -42,5 +42,24 @@"category": "Category","categoryPlaceholder": "Select category","categoryPlaceholderDisabled": "Select region first"+ },+ "upload": {+ "finishingUp": "Finishing up...",+ "uploadImageOrVideo": "Upload image or video",+ "dragAndSelect": "Drag & select image or video"+ },+ "validation": {+ "uploadImageOrVideo": "Please upload image or video",+ "topicMaxExceeded": "{{platformName}} topics cannot exceed {{maxCount}}",+ "topicFormatError": "Topics in description must be separated by spaces, such as: \"#topic1 #topic2\"",+ "titleRequired": "Title is required",+ "partitionRequired": "You must select a partition!",+ "sourceRequired": "Source must be filled when reprinting!",+ "pageRequired": "You must select a page!",+ "coverSizeError": "Cover minimum size 400*400!"+ },+ "preview": {+ "title": "Preview",+ "emptyDescription": "See your work preview here"}}\ No newline at end of filediff --git a/src/app/i18n/locales/zh-CN/publish.json b/src/app/i18n/locales/zh-CN/publish.jsonindex 3d708d2c..b9d97e2d 100644--- a/src/app/i18n/locales/zh-CN/publish.json+++ b/src/app/i18n/locales/zh-CN/publish.json@@ -42,5 +42,24 @@"category": "视频分类","categoryPlaceholder": "请选择视频分类","categoryPlaceholderDisabled": "请先选择国区"+ },+ "upload": {+ "finishingUp": "正在完成...",+ "uploadImageOrVideo": "上传图片或视频",+ "dragAndSelect": "拖放 & 选择图片或视频"+ },+ "validation": {+ "uploadImageOrVideo": "请上传图片或视频",+ "topicMaxExceeded": "{{platformName}}话题最多不能超过{{maxCount}}个",+ "topicFormatError": "描述中的话题必须使用空格分割,如:\"#话题1 #话题2\"",+ "titleRequired": "标题是必须的",+ "partitionRequired": "您必须选择分区!",+ "sourceRequired": "转载时必须填写转载来源!",+ "pageRequired": "您必须选择页面!",+ "coverSizeError": "封面最小尺寸400*400!"+ },+ "preview": {+ "title": "预览",+ "emptyDescription": "在这里看到你的作品预览"}}\ No newline at end of filediff --git a/src/app/layout/Providers.tsx b/src/app/layout/Providers.tsxindex 0936b34e..596e9d59 100644--- a/src/app/layout/Providers.tsx+++ b/src/app/layout/Providers.tsx@@ -49,7 +49,7 @@ export function Providers({}, [lng]);return (- <GoogleOAuthProvider clientId="471394506793-t2g4mg90vr8qgpq5stbua0b22pofqrne.apps.googleusercontent.com">+ <GoogleOAuthProvider clientId="471394506793-t2g4mg90vr8qgpq5stbua0b22pofqrne.apps.googleusercontent.com"><ConfigProviderlocale={getAntdLang(lng)}theme={{diff --git a/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasTextareaUpload.tsx b/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasTextareaUpload.tsxindex 5993e39b..02cb4b8c 100644--- a/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasTextareaUpload.tsx+++ b/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasTextareaUpload.tsx@@ -19,6 +19,7 @@ import {import { toolsApi } from "@/api/tools";import { OSS_URL } from "@/constant";import { RcFile } from "antd/es/upload";+import { useTransClient } from "@/app/i18n/client";const { Dragger } = Upload;@@ -50,6 +51,7 @@ const PubParmasTextareaUpload = memo(const [uploadLoading, setUploadLoading] = useState(false);const chooseCount = useRef<number>(0);const fileListRef = useRef<RcFile[]>([]);+ const { t } = useTransClient("publish");// 上传视频const uploadVideo = useCallback(@@ -137,7 +139,7 @@ const PubParmasTextareaUpload = memo(color: "var(--theColor6)",}}>- Finishing up…+ {t("upload.finishingUp")}</span>): undefined@@ -150,7 +152,7 @@ const PubParmasTextareaUpload = memo()}</div>) : (- <Tooltip title="上传图片或视频">+ <Tooltip title={t("upload.uploadImageOrVideo")}><Draggeraccept={uploadAccept}multiple={true}@@ -177,7 +179,7 @@ const PubParmasTextareaUpload = memo(showUploadList={false}><PlusOutlined />- <p>拖放 & 选择图片或视频</p>+ <p>{t("upload.dragAndSelect")}</p></Dragger></Tooltip>)}diff --git a/src/components/PublishDialog/hooks/usePubParamsVerify.tsx b/src/components/PublishDialog/hooks/usePubParamsVerify.tsxindex c0cb96eb..53a14e3d 100644--- a/src/components/PublishDialog/hooks/usePubParamsVerify.tsx+++ b/src/components/PublishDialog/hooks/usePubParamsVerify.tsx@@ -3,6 +3,7 @@ import { parseTopicString } from "@/utils";import { AccountPlatInfoMap, PlatType } from "@/app/config/platConfig";import { PubItem } from "@/components/PublishDialog/publishDialog.type";import { Alert } from "antd";+import { useTransClient } from "@/app/i18n/client";export interface ErrPubParamsItem {// 参数错误提示消息@@ -18,6 +19,7 @@ export type ErrPubParamsMapType = Map<string | number, ErrPubParamsItem>;export default function usePubParamsVerify(data: PubItem[]) {// 用于判断描述中的话题是否符合规范const descTopicRegex = /#\S+#\S+/;+ const { t } = useTransClient("publish");// 错误参数,发布之前会检测错误参数,防止平台无法发布const errParamsMap = useMemo(() => {@@ -40,17 +42,15 @@ export default function usePubParamsVerify(data: PubItem[]) {// 图片或者视频校验,视频和图片必须要上传一个if (v.params.images?.length === 0 && !v.params.video) {- return setErrorMsg("请上传图片或视频");+ return setErrorMsg(t("validation.uploadImageOrVideo"));}// 话题校验if (topicsAll.length > topicMax) {- return setErrorMsg(`${platInfo.name}话题最多不能超过${topicMax}个`);+ return setErrorMsg(t("validation.topicMaxExceeded", { platformName: platInfo.name, maxCount: topicMax }));}// 判断描述中的话题中间是否用空格分割,如:#话题1#话题2#话题3 这种格式错误if (descTopicRegex.test(v.params.des || "")) {- return setErrorMsg(- `描述中的话题必须使用空格分割,如:“#话题1 #话题2”`,- );+ return setErrorMsg(t("validation.topicFormatError"));}// ------------------------ 单个平台参数校验 ------------------------@@ -59,23 +59,23 @@ export default function usePubParamsVerify(data: PubItem[]) {if (v.account.type === PlatType.BILIBILI) {// 强制需要标题if (!v.params.title) {- return setErrorMsg("标题是必须的");+ return setErrorMsg(t("validation.titleRequired"));}if (!v.params.option.bilibili?.tid) {- return setErrorMsg("您必须选择分区!");+ return setErrorMsg(t("validation.partitionRequired"));}if (v.params.option.bilibili.copyright === 2 &&!v.params.option.bilibili.source) {- return setErrorMsg("转载时必须填写转载来源!");+ return setErrorMsg(t("validation.sourceRequired"));}}// Facebook的强制校验if (v.account.type === PlatType.Facebook) {if (!v.params.option.facebook?.page_id) {- return setErrorMsg("您必须选择页面!");+ return setErrorMsg(t("validation.pageRequired"));}}@@ -86,13 +86,13 @@ export default function usePubParamsVerify(data: PubItem[]) {(v.params.video.cover.width < 400 ||v.params.video.cover.height < 400)) {- return setErrorMsg("封面最小尺寸400*400!");+ return setErrorMsg(t("validation.coverSizeError"));}}})();}return errParamsMapTemp;- }, [data]);+ }, [data, t]);return {errParamsMap,