Skip to content

Let's use AI to Earn!

fix: 修复类型错误,更改next配置

gaoSir4256395d67df
diff --git a/.env b/.env
index b8d1218f..7b3ec4d8 100644
--- a/.env
+++ b/.env
@@ -1,3 +1,2 @@
# baseURL 代理字段
NEXT_PUBLIC_API_URL_PROXY="/baseUrlProxy/"
-
diff --git a/.env.production b/.env.production
index 7cb88fb8..36bf65f2 100644
--- a/.env.production
+++ b/.env.production
@@ -1,4 +1,4 @@
NEXT_PUBLIC_EVN=prod
-NEXT_PUBLIC_API_URL=http://localhost:3000/api/
+NEXT_PUBLIC_API_URL=https://apitest.aiearn.ai/api/
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 33bd0c32..c14d6895 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,96 +4,20 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
- <list default="true" id="90ed3383-49aa-4e32-95a2-9f070c0da49b" name="更改" comment="feat: 授权改到后端">
- <change afterPath="$PROJECT_DIR$/src/components/PublishDialog/PublishDialog.util.ts" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PubParmasTextarea/VideoCoverSeting.tsx" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PubParmasTextarea/videoCoverSeting.module.scss" afterDir="false" />
+ <list default="true" id="90ed3383-49aa-4e32-95a2-9f070c0da49b" name="更改" comment="refactor(发布): 旧发布和发布记录全部删除">
+ <change afterPath="$PROJECT_DIR$/src/app/i18n/locales/en/material.json" afterDir="false" />
+ <change afterPath="$PROJECT_DIR$/src/app/i18n/locales/zh-CN/material.json" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/.env" beforeDir="false" afterPath="$PROJECT_DIR$/.env" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/.env.production" beforeDir="false" afterPath="$PROJECT_DIR$/.env.production" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/comment.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/AICreateTitle/AICreateTitle.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/AICreateTitle/aICreateTitle.module.scss" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/AICreateTitle/useAICreateTitle.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/Choose/ImgChoose.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/Choose/ImgChoose.tsx" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/Choose/ImgChoose.util.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/Choose/VideoChoose.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/Choose/videoChoose.util.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/ChooseAccountModule/ChooseAccountModule.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/ChooseAccountModule/chooseAccountModule.module.scss" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/ChooseAccountModule/components/PlatChoose.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/CommonComponents/CommonComponents.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/CommonComponents/CommonLocationSelect.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/CommonComponents/CommonScheduledTimeSelect.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/CommonComponents/CommonTopicSelect.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/CommonComponents/CommonUserSelect.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/CommonComponents/commonComponents.module.scss" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/PubAccountDetModule/PubAccountDetModule.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/PubAccountDetModule/pubAccountDetModule.module.scss" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/PubProgressModule/PubProgressModule.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/PubProgressModule/pubProgressModule.module.scss" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/PublishSidebar.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/SupportPlat/SupportPlat.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/components/SupportPlat/supportPlat.module.scss" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/hooks/usePubParamsVerify.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/imagePage/components/ImageLeftSetting/ImageLeftSetting.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/imagePage/components/ImageLeftSetting/ImgTextImagesView.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/imagePage/components/ImageLeftSetting/imgTextImagesView.module.scss" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/imagePage/components/ImageRightSetting/ImageRightSetting.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ImageParamsSet.type.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ImageRightSettingCommon.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/children/hooks/useImagePlatParams.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/imageParamsSet.module.scss" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/imagePage/image.module.scss" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/imagePage/imagePage.type.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/imagePage/page.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/imagePage/useImagePageStore.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/layout.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/page.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/pubRecord/page.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/pubRecord/pubRecord.common.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/pubRecord/pubRecord.module.scss" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/publish.module.scss" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/comment.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/components/CommonPubSetting.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/components/NoChoosePage.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/components/VideoChooseItem.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/components/VideoCoverSeting.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_KWAI.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/hooks/useVideoPubSetModal.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/TopicSelect.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/UserSelect.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/VideoPubSetModalVideo.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/useDebounceFetcher.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/videoPubSetModal.module.scss" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/videoPubSetModal.type.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/components/videoCoverSeting.module.scss" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/images/importRecord.png" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/images/localUpload.png" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/page.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/useVideoPageStore.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/video.module.scss" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/videoPage/videoPage.type.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/layout/BellMessage/bellMessage.module.scss" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/layout/BellMessage/index.tsx" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/layout/LyaoutHeader.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/layout/LyaoutHeader.tsx" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/layout/routerData.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/layout/routerData.ts" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/plat/PlatBase.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/plat/PlatManage.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/plat/plat.type.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/plat/plat.util.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/plat/platChildren/bilibili/BilibiliPlat.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/plat/platChildren/bilibili/BilibiliPubCore.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/plat/platChildren/kwai/KwaiPlat.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/plat/platChildren/kwai/KwaiPubCore.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/plat/platChildren/youtube/YoutubePlat.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/plat/platChildren/youtube/YoutubePubCore.ts" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/plats/plats.type.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/plats/plats.type.ts" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/publishDialog.type.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/publishDialog.type.ts" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/@types/resources.d.ts" beforeDir="false" afterPath="$PROJECT_DIR$/@types/resources.d.ts" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/next.config.mjs" beforeDir="false" afterPath="$PROJECT_DIR$/next.config.mjs" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/pm2.json" beforeDir="false" afterPath="$PROJECT_DIR$/pm2.json" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/app/[lng]/cgmaterial/cgmaterialPageCore.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/cgmaterial/cgmaterialPageCore.tsx" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/app/[lng]/cgmaterial/page.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/cgmaterial/page.tsx" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/app/[lng]/demo/demoPageCore.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/demo/demoPageCore.tsx" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/store/bellMessageStroe.ts" beforeDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -207,7 +131,7 @@
<workItem from="1751273285905" duration="3882000" />
<workItem from="1751278214456" duration="955000" />
<workItem from="1751334170049" duration="2844000" />
- <workItem from="1751351785412" duration="16797000" />
+ <workItem from="1751351785412" duration="20814000" />
</task>
<task id="LOCAL-00001" summary="feat: 日历完善">
<option name="closed" value="true" />
@@ -377,7 +301,15 @@
<option name="project" value="LOCAL" />
<updated>1751376590963</updated>
</task>
- <option name="localTasksCounter" value="22" />
+ <task id="LOCAL-00022" summary="refactor(发布): 旧发布和发布记录全部删除">
+ <option name="closed" value="true" />
+ <created>1751441171457</created>
+ <option name="number" value="00022" />
+ <option name="presentableId" value="LOCAL-00022" />
+ <option name="project" value="LOCAL" />
+ <updated>1751441171457</updated>
+ </task>
+ <option name="localTasksCounter" value="23" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -418,6 +350,7 @@
<MESSAGE value="feat: 日历拖拽初步开发" />
<MESSAGE value="feat: 拖动调整完成(目前等待接接口)" />
<MESSAGE value="feat: 授权改到后端" />
- <option name="LAST_COMMIT_MESSAGE" value="feat: 授权改到后端" />
+ <MESSAGE value="refactor(发布): 旧发布和发布记录全部删除" />
+ <option name="LAST_COMMIT_MESSAGE" value="refactor(发布): 旧发布和发布记录全部删除" />
</component>
</project>
\ No newline at end of file
diff --git a/@types/resources.d.ts b/@types/resources.d.ts
index 505a2c88..db960ca6 100644
--- a/@types/resources.d.ts
+++ b/@types/resources.d.ts
@@ -73,6 +73,7 @@ interface Resources {
"registerError": "注册失败,请稍后重试",
"googleLoginFailed": "Google 登录失败"
},
+ "material": {},
"route": {
"home": "首页",
"accounts": "账户",
diff --git a/next.config.mjs b/next.config.mjs
index 32c44d40..9346fc03 100644
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -8,6 +8,8 @@ const nextConfig = {
experimental: {
forceSwcTransforms: true,
},
+ output: 'standalone',
+ productionBrowserSourceMaps: process.env.NEXT_PUBLIC_EVN === 'dev',
};
const CorsHeaders = [
diff --git a/package.json b/package.json
index 5420ed05..3ce1b01f 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,7 @@
"private": true,
"scripts": {
"postbuild": "next-sitemap",
- "dev": "next dev -p 6060 --experimental-https",
+ "dev": "next dev --experimental-https",
"build": "tsc && next build",
"start": "next start",
"lint": "next lint",
diff --git a/pm2.json b/pm2.json
index a5efe933..8c1ab879 100644
--- a/pm2.json
+++ b/pm2.json
@@ -2,7 +2,7 @@
"apps": [
{
"name": "aitoearn-web",
- "cwd": ".next",
+ "cwd": "standalone",
"script": "node server.js",
"instances": "1",
"exec_mode": "cluster",
diff --git a/public/robots.txt b/public/robots.txt
new file mode 100644
index 00000000..c3498d5d
--- /dev/null
+++ b/public/robots.txt
@@ -0,0 +1,9 @@
+# *
+User-agent: *
+Allow: /
+
+# Host
+Host: https://www.yikart.cn
+
+# Sitemaps
+Sitemap: https://www.yikart.cn/sitemap.xml
diff --git a/public/sitemap.xml b/public/sitemap.xml
new file mode 100644
index 00000000..39fed003
--- /dev/null
+++ b/public/sitemap.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
+</sitemapindex>
\ No newline at end of file
diff --git a/src/app/[lng]/cgmaterial/cgmaterialPageCore.tsx b/src/app/[lng]/cgmaterial/cgmaterialPageCore.tsx
index 3cda1c15..c5857599 100644
--- a/src/app/[lng]/cgmaterial/cgmaterialPageCore.tsx
+++ b/src/app/[lng]/cgmaterial/cgmaterialPageCore.tsx
@@ -106,6 +106,7 @@ export default function CgMaterialPageCore() {
setMaterialLoading(true);
try {
const res = await apiGetMaterialList(groupId, 1, 50);
+ // @ts-ignore
setMaterialList(res?.data?.list || []);
} catch (e) {
message.error("获取草稿素材失败");
@@ -167,6 +168,7 @@ export default function CgMaterialPageCore() {
setSelectedMediaGroup(group);
setMediaGroupModal(false);
const res = await getMediaList(group._id, 1, 100);
+ // @ts-ignore
setMediaList(res?.data?.list || []);
setSelectedCover(null);
setSelectedMaterials([]);
@@ -269,6 +271,7 @@ export default function CgMaterialPageCore() {
}
if (taskId) {
const res = await apiPreviewMaterialTask(taskId);
+ // @ts-ignore
setPreviewData(res?.data?.data || null);
setPreviewModal(true);
} else {
diff --git a/src/app/[lng]/cgmaterial/page.tsx b/src/app/[lng]/cgmaterial/page.tsx
index 7e4fee1a..056c3108 100644
--- a/src/app/[lng]/cgmaterial/page.tsx
+++ b/src/app/[lng]/cgmaterial/page.tsx
@@ -5,6 +5,7 @@ import { getMetadata } from "@/utils/general";
import dynamic from "next/dynamic";
const CgMaterialPageCore = dynamic(
+ // @ts-ignore
() => import("./cgmaterialPageCore").then(mod => mod.default || mod.CgMaterialPageCore),
{ ssr: false }
);
diff --git a/src/app/[lng]/demo/demoPageCore.tsx b/src/app/[lng]/demo/demoPageCore.tsx
index aed19b54..12c32974 100644
--- a/src/app/[lng]/demo/demoPageCore.tsx
+++ b/src/app/[lng]/demo/demoPageCore.tsx
@@ -1,350 +1,5 @@
"use client";
-import { useTransClient } from "@/app/i18n/client";
-import { useAccountStore } from "@/store/account";
-import { useEffect, useState } from "react";
-import {
- apiInitBilibiliVideo,
- apiUploadBilibiliCover,
- apiSubmitBilibiliArchive,
- apiUploadBilibilivideo,
- apiUploadBilibiliVideoPart,
- apiCompleteBilibiliVideo,
- apiGetBilibiliPartitions,
-} from "@/api/bilibili";
-import { getAccountListApi } from "@/api/account";
-import { calculateChunks, readBlobRange } from "@/app/plat/plat.util";
-
-interface Account {
- id: string;
- type: string;
- nickname: string;
- avatar: string;
-}
-
-interface Partition {
- id: number;
- name: string;
- description: string;
- parent: number;
- children?: Partition[];
-}
-
export const DemoPageCore = () => {
- const { t } = useTransClient("demo");
- const accountStore = useAccountStore();
- const [accounts, setAccounts] = useState<Account[]>([]);
- const [uploadToken, setUploadToken] = useState<string>("");
- const [selectedFile, setSelectedFile] = useState<File | null>(null);
- const [coverFile, setCoverFile] = useState<File | null>(null);
- const [uploadProgress, setUploadProgress] = useState<number>(0);
- const [isUploading, setIsUploading] = useState<boolean>(false);
- const fileBlockSize = 4194304; // 4MB per chunk
- const [coverUrl, setCoverUrl] = useState<string>("");
- const [partitions, setPartitions] = useState<Partition[]>([]);
- const [selectedPartition, setSelectedPartition] = useState<number>(21); // 默认选择日常分区
-
- useEffect(() => {
- const fetchAccounts = async () => {
- const result = await getAccountListApi();
- console.log("accountList", result);
- if (result?.code === 0 && result?.data) {
- setAccounts(result.data);
-
- const res = await fetchPartitions(result.data[0].id);
- console.log("------ rew", res);
- }
- };
- fetchAccounts();
- }, []);
-
- const handleInitVideo = async (accountId: string) => {
- try {
- const res: any = await apiInitBilibiliVideo({
- accountId,
- name: "files.mp4",
- });
- if (res?.data?.data) {
- const token = res.data.data;
- setUploadToken(token);
- console.log("获取上传token成功:", token);
- // 获取分区列表
- }
- } catch (error) {
- console.error("获取上传token失败:", error);
- }
- };
-
- const fetchPartitions = async (token: string) => {
- try {
- const res: any = await apiGetBilibiliPartitions(token);
- if (res?.code === 0 && res?.data?.data) {
- setPartitions(res.data.data);
- }
- } catch (error) {
- console.error("获取分区列表失败:", error);
- }
- };
-
- const handleVideoUpload = async (accountId: string, file: File) => {
- if (!uploadToken) {
- console.error("请先获取上传token");
- return;
- }
-
- try {
- const formData = new FormData();
- formData.append("file", file);
-
- const res = await apiUploadBilibilivideo(
- accountId,
- uploadToken,
- formData,
- );
- if (res?.code === 0) {
- console.log("视频上传成功:", res);
- return true;
- } else {
- throw new Error("视频上传失败");
- }
- } catch (error) {
- console.error("视频上传失败:", error);
- return false;
- }
- };
-
- const handleChunkedVideoUpload = async (accountId: string, file: File) => {
- if (!uploadToken) {
- console.error("请先获取上传token");
- return;
- }
-
- try {
- setIsUploading(true);
- setUploadProgress(0);
-
- // 计算分片
- const chunkRange = calculateChunks(file.size, fileBlockSize);
- console.log(`文件将被分为 ${chunkRange.length} 个分片`);
-
- // 分片上传
- for (let i = 0; i < chunkRange.length; i++) {
- const range = chunkRange[i];
- // 获取要上传的视频分片
- // const chunk = await readBlobRange(file, range.start, range.end);
- const sliced = file.slice(range.start, range.end);
- // const blob = new Blob([chunk], { type: "application/octet-stream" });
- console.log("上传分片:", sliced);
-
- // 上传分片
- const res = await apiUploadBilibiliVideoPart(
- accountId,
- uploadToken,
- i + 1,
- sliced,
- );
- if (res?.code !== 0) {
- throw new Error(`分片 ${i} 上传失败`);
- }
-
- // 更新进度
- const progress = Math.round(((i + 1) / chunkRange.length) * 100);
- setUploadProgress(progress);
- console.log(
- `分片 ${i + 1}/${chunkRange.length} 上传成功,总进度:${progress}%`,
- );
- }
-
- // 合并分片
- console.log("开始合并分片...");
- const completeRes = await apiCompleteBilibiliVideo(
- accountId,
- uploadToken,
- );
- if (completeRes?.code !== 0) {
- throw new Error("分片合并失败");
- }
-
- console.log("视频上传完成");
- setUploadProgress(100);
- return true;
- } catch (error) {
- console.error("视频上传失败:", error);
- setUploadProgress(-1);
- return false;
- } finally {
- setIsUploading(false);
- }
- };
-
- const handleUploadCover = async (accountId: string) => {
- if (!coverFile) {
- console.error("请选择封面文件");
- return null;
- }
-
- try {
- const formData = new FormData();
- formData.append("file", coverFile);
- const res: any = await apiUploadBilibiliCover(accountId, formData);
- if (res?.data) {
- console.log("封面上传成功:", res.data);
- // 保存封面地址
- setCoverUrl(res.data.url);
- return res.data;
- }
- return null;
- } catch (error) {
- console.error("封面上传失败:", error);
- return null;
- }
- };
-
- const handleSubmitArchive = async (accountId: string) => {
- try {
- const archiveData = {
- accountId,
- uploadToken,
- title: "看看我的车阿达",
- cover: coverUrl,
- tid: selectedPartition,
- noReprint: 0,
- desc: "vv7维修保安上课方式大健康",
- tag: ["vv7", "clientDome"],
- copyright: 1,
- };
-
- const res = await apiSubmitBilibiliArchive(archiveData);
- console.log("稿件提交结果:", res);
- } catch (error) {
- console.error("稿件提交失败:", error);
- }
- };
-
- const handleFileChange = (
- event: React.ChangeEvent<HTMLInputElement>,
- type: "video" | "cover",
- ) => {
- const file = event.target.files?.[0];
- if (file) {
- if (type === "video") {
- setSelectedFile(file);
- } else {
- setCoverFile(file);
- }
- }
- };
-
- return (
- <div>
- <div>{t("demoText")}</div>
- <div>
- <h3>账户列表:</h3>
- {accounts.map((account) => (
- <div key={account.id}>
- <p>平台: {account.type}</p>
- <p>昵称: {account.nickname}</p>
- <p>
- 头像:{" "}
- <img src={account.avatar} alt="avatar" width={50} height={50} />
- </p>
- <button onClick={() => handleInitVideo(account.id)}>
- 获取上传Token
- </button>
-
- <div style={{ marginTop: "10px" }}>
- <p>上传视频</p>
- <input
- type="file"
- accept="video/*"
- onChange={(e) => handleFileChange(e, "video")}
- disabled={isUploading}
- />
- {selectedFile && (
- <>
- <button
- onClick={() => handleVideoUpload(account.id, selectedFile)}
- disabled={isUploading}
- >
- 普通上传
- </button>
- <button
- onClick={() =>
- handleChunkedVideoUpload(account.id, selectedFile)
- }
- disabled={isUploading}
- >
- 分片上传
- </button>
- {uploadProgress > 0 && (
- <div style={{ marginTop: "10px" }}>
- <div
- style={{
- width: "100%",
- height: "20px",
- backgroundColor: "#f0f0f0",
- borderRadius: "10px",
- overflow: "hidden",
- }}
- >
- <div
- style={{
- width: `${uploadProgress}%`,
- height: "100%",
- backgroundColor: "#1890ff",
- transition: "width 0.3s ease-in-out",
- }}
- />
- </div>
- <p>上传进度: {uploadProgress}%</p>
- </div>
- )}
- </>
- )}
- </div>
-
- <div style={{ marginTop: "10px" }}>
- <p>上传封面</p>
- <input
- type="file"
- accept="image/*"
- onChange={(e) => handleFileChange(e, "cover")}
- />
- {coverFile && (
- <button onClick={() => handleUploadCover(account.id)}>
- 上传封面
- </button>
- )}
- </div>
-
- <div style={{ marginTop: "10px" }}>
- <p>选择分区:</p>
- <select
- value={selectedPartition}
- onChange={(e) => setSelectedPartition(Number(e.target.value))}
- style={{ marginBottom: "10px" }}
- >
- {partitions &&
- partitions.map((partition) => (
- <optgroup key={partition.id} label={partition.name}>
- {partition.children?.map((child: Partition) => (
- <option key={child.id} value={child.id}>
- {child.name} - {child.description}
- </option>
- ))}
- </optgroup>
- ))}
- </select>
- </div>
-
- <div style={{ marginTop: "10px" }}>
- <button onClick={() => handleSubmitArchive(account.id)}>
- 提交稿件
- </button>
- </div>
- </div>
- ))}
- </div>
- </div>
- );
+ return <>demo</>;
};
diff --git a/src/app/i18n/locales/en/material.json b/src/app/i18n/locales/en/material.json
new file mode 100644
index 00000000..9e26dfee
--- /dev/null
+++ b/src/app/i18n/locales/en/material.json
@@ -0,0 +1 @@
+{}
\ No newline at end of file
diff --git a/src/app/i18n/locales/zh-CN/material.json b/src/app/i18n/locales/zh-CN/material.json
new file mode 100644
index 00000000..9e26dfee
--- /dev/null
+++ b/src/app/i18n/locales/zh-CN/material.json
@@ -0,0 +1 @@
+{}
\ No newline at end of file
diff --git a/src/store/bellMessageStroe.ts b/src/store/bellMessageStroe.ts
deleted file mode 100644
index b8d80b4e..00000000
--- a/src/store/bellMessageStroe.ts
+++ /dev/null
@@ -1,76 +0,0 @@
-import { create } from "zustand";
-import { combine } from "zustand/middleware";
-import lodash from "lodash";
-// import { PublishProgressRes } from "../../electron/main/plat/pub/PubItemVideo";
-// import { onVideoPublishProgress } from "../icp/receiveMsg";
-import { PubStatus } from "@/app/config/publishConfig";
-import { PublishProgressRes } from "@/app/plat/plat.type";
-
-export interface NoticeItem {
- title: string;
- time: Date;
- // 以下为不同类型通知独有的字段
- // 发布
- pub?: {
- // 发布状态
- status: PubStatus;
- // TODO 发布记录进度类型
- // progressList: PublishProgressRes[];
- progressList: any[];
- };
- id: string | number;
-}
-
-export enum NoticeType {
- // 发布通知
- PubNotice = "1",
-}
-
-export interface IBellMessageStroe {
- noticeMap: Map<NoticeType, NoticeItem[]>;
-}
-
-const store: IBellMessageStroe = {
- noticeMap: new Map<NoticeType, NoticeItem[]>(),
-};
-
-const getStore = () => {
- return lodash.cloneDeep(store);
-};
-
-// 视频发布所有组件的共享状态和方法
-export const useBellMessageStroe = create(
- combine(
- {
- ...getStore(),
- },
- (set, get, storeApi) => {
- const methods = {
- // 添加数据
- addNotice(type: NoticeType, data: NoticeItem[]) {
- const noticeMap = new Map(get().noticeMap);
- noticeMap.set(type, data);
-
- set({ noticeMap });
- },
-
- // 发布进度设置
- publishProgressSet(progressData: PublishProgressRes) {
- const noticeMap = new Map(get().noticeMap);
- const noticeList = noticeMap.get(NoticeType.PubNotice) || [];
- const noticeItem = noticeList.find((v) => v.id === progressData.id);
-
- noticeItem?.pub?.progressList.find((v, i) => {
- if (v.account.id === progressData.account.id) {
- noticeItem!.pub!.progressList[i] = progressData;
- return true;
- }
- });
-
- set({ noticeMap });
- },
- };
- return methods;
- },
- ),
-);