Skip to content

Let's use AI to Earn!

feat: Move the material selection in the upper right corner to "Upload Pictures/Videos"

gaoSir362cc4c91e1b
diff --git a/.env b/.env
index 65eaae89..663c2354 100644
--- a/.env
+++ b/.env
@@ -1,4 +1,8 @@
# OSS URL
NEXT_PUBLIC_OSS_URL="https://aitoearn.s3.ap-southeast-1.amazonaws.com/"
+
+# OSS URL 代理
+NEXT_PUBLIC_OSS_URL_PROXY="/ossProxy/"
+
# yika OSS
NEXT_PUBLIC_YIKA_OSS_HOST=https://yika-bj.oss-cn-beijing.aliyuncs.com
diff --git a/next.config.mjs b/next.config.mjs
index 12eb9d7d..440a0f47 100644
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -33,6 +33,10 @@ const nextConfig = {
productionBrowserSourceMaps: process.env.NEXT_PUBLIC_EVN === "dev",
rewrites: async () => {
const rewrites = [
+ {
+ source: `${process.env.NEXT_PUBLIC_OSS_URL_PROXY}:path*`,
+ destination: `${process.env.NEXT_PUBLIC_OSS_URL}/:path*`,
+ }
];
// 存在 NEXT_PUBLIC_PROXY_URL 则代理,本地直连 用
diff --git a/src/components/ImageEditorModal/index.tsx b/src/components/ImageEditorModal/index.tsx
index 0c16fc31..6ce40199 100644
--- a/src/components/ImageEditorModal/index.tsx
+++ b/src/components/ImageEditorModal/index.tsx
@@ -168,8 +168,8 @@ const ImageEditorModal = memo(
uiSize: { width: "1000px", height: "700px" },
menuBarPosition: "bottom",
}}
- cssMaxHeight={500}
- cssMaxWidth={700}
+ cssMaxHeight={430}
+ cssMaxWidth={800}
selectionStyle={{ cornerSize: 20, rotatingPointOffset: 70 }}
usageStatistics={false}
/>
diff --git a/src/components/PublishDialog/compoents/MaterialSelectionModal/index.tsx b/src/components/PublishDialog/compoents/MaterialSelectionModal/index.tsx
new file mode 100644
index 00000000..1e221a66
--- /dev/null
+++ b/src/components/PublishDialog/compoents/MaterialSelectionModal/index.tsx
@@ -0,0 +1,283 @@
+import {
+ ForwardedRef,
+ forwardRef,
+ memo,
+ useCallback,
+ useEffect,
+ useState,
+} from "react";
+import { Button, List, Modal, Spin } from "antd";
+import { PictureOutlined } from "@ant-design/icons";
+import { getOssUrl } from "@/utils/oss";
+import { useTransClient } from "@/app/i18n/client";
+import { getMediaGroupList, getMediaList } from "@/api/media";
+
+export interface IMaterialSelectionModalRef {}
+
+export interface IMaterialSelectionModalProps {
+ allowImage?: boolean;
+ allowVideo?: boolean;
+ libraryModalOpen: boolean;
+ onCancel: () => void;
+ onSelected?: (item: any) => void;
+}
+
+const MaterialSelectionModal = memo(
+ forwardRef(
+ (
+ {
+ allowImage = true,
+ allowVideo = true,
+ libraryModalOpen,
+ onCancel,
+ onSelected,
+ }: IMaterialSelectionModalProps,
+ ref: ForwardedRef<IMaterialSelectionModalRef>,
+ ) => {
+ // 素材库选择弹窗/数据
+ const [libraryGroupLoading, setLibraryGroupLoading] = useState(false);
+ const [libraryGroups, setLibraryGroups] = useState<any[]>([]);
+ const [selectedLibraryGroup, setSelectedLibraryGroup] = useState<
+ any | null
+ >(null);
+ const [libraryLoading, setLibraryLoading] = useState(false);
+ const [libraryItems, setLibraryItems] = useState<any[]>([]);
+ const { t } = useTransClient("publish");
+
+ // 获取素材库组列表
+ const fetchLibraryGroups = useCallback(async () => {
+ try {
+ setLibraryGroupLoading(true);
+ const res: any = await getMediaGroupList(1, 100);
+ const list = res?.data?.list || [];
+ const filtered = list.filter((g: any) => {
+ if (g.type === "img") return allowImage;
+ if (g.type === "video") return allowVideo;
+ return true;
+ });
+ setLibraryGroups(filtered);
+ } catch (e) {
+ } finally {
+ setLibraryGroupLoading(false);
+ }
+ }, [allowImage, allowVideo]);
+
+ // 获取素材库内容
+ const fetchLibraryItems = useCallback(async (groupId: string) => {
+ try {
+ setLibraryLoading(true);
+ const res: any = await getMediaList(groupId, 1, 100);
+ setLibraryItems(res?.data?.list || []);
+ } catch (e) {
+ } finally {
+ setLibraryLoading(false);
+ }
+ }, []);
+
+ // 素材库弹窗打开时获取组列表
+ useEffect(() => {
+ if (libraryModalOpen) {
+ setSelectedLibraryGroup(null);
+ setLibraryItems([]);
+ fetchLibraryGroups();
+ }
+ }, [libraryModalOpen, fetchLibraryGroups]);
+
+ // 选中素材库组后加载组内素材
+ useEffect(() => {
+ if (selectedLibraryGroup?._id) {
+ fetchLibraryItems(selectedLibraryGroup._id);
+ }
+ }, [selectedLibraryGroup, fetchLibraryItems]);
+
+ // 选择素材库内容后填充参数
+ const applyLibraryItem = useCallback(async (item: any) => {
+ if (onSelected) {
+ onSelected(item);
+ onCancel();
+ }
+ }, []);
+
+ return (
+ <Modal
+ open={libraryModalOpen}
+ onCancel={() => onCancel()}
+ footer={null}
+ title={
+ selectedLibraryGroup
+ ? t("draft.selectLibraryItem")
+ : t("draft.selectLibraryGroup")
+ }
+ width={720}
+ >
+ {!selectedLibraryGroup ? (
+ <div>
+ {libraryGroupLoading ? (
+ <div style={{ textAlign: "center", padding: 24 }}>
+ <Spin />
+ </div>
+ ) : (
+ <List
+ grid={{ gutter: 16, column: 2 }}
+ dataSource={libraryGroups}
+ locale={{ emptyText: t("draft.noLibraryGroups") }}
+ renderItem={(item: any) => (
+ <List.Item>
+ <div
+ style={{
+ background: "#F0F8FF",
+ border: "2px solid transparent",
+ padding: "16px",
+ borderRadius: "12px",
+ cursor: "pointer",
+ transition: "all 0.3s ease",
+ minHeight: "80px",
+ display: "flex",
+ flexDirection: "column",
+ justifyContent: "center",
+ alignItems: "center",
+ textAlign: "center",
+ position: "relative",
+ }}
+ onClick={() => setSelectedLibraryGroup(item)}
+ >
+ <div
+ style={{
+ fontSize: 24,
+ marginBottom: 8,
+ color: "#1890ff",
+ }}
+ >
+ <PictureOutlined />
+ </div>
+ <div
+ style={{
+ fontWeight: 600,
+ fontSize: 16,
+ color: "#2c3e50",
+ marginBottom: 4,
+ }}
+ >
+ {item.title}
+ </div>
+ {item.desc && (
+ <div
+ style={{
+ fontSize: 12,
+ color: "#7f8c8d",
+ lineHeight: 1.4,
+ }}
+ >
+ {item.desc}
+ </div>
+ )}
+ <div
+ style={{
+ position: "absolute",
+ top: 8,
+ left: 8,
+ padding: "2px 8px",
+ borderRadius: "12px",
+ fontSize: 10,
+ color: "#fff",
+ background:
+ item.type === "img" ? "#52c41a" : "#1890ff",
+ }}
+ >
+ {item.type === "img"
+ ? t("draft.imageGroup")
+ : t("draft.videoGroup")}
+ </div>
+ </div>
+ </List.Item>
+ )}
+ />
+ )}
+ </div>
+ ) : (
+ <div>
+ <div style={{ marginBottom: 12 }}>
+ <Button
+ type="link"
+ onClick={() => setSelectedLibraryGroup(null)}
+ >
+ {t("draft.backToLibraryGroups")}
+ </Button>
+ </div>
+ {libraryLoading ? (
+ <div style={{ textAlign: "center", padding: 24 }}>
+ <Spin />
+ </div>
+ ) : (
+ <List
+ grid={{ gutter: 16, column: 2 }}
+ dataSource={libraryItems}
+ locale={{ emptyText: t("draft.noLibraryItems") }}
+ renderItem={(item: any) => (
+ <List.Item>
+ <div
+ style={{
+ border: "1px solid #eee",
+ borderRadius: 8,
+ overflow: "hidden",
+ cursor: "pointer",
+ }}
+ onClick={() => applyLibraryItem(item)}
+ >
+ <div
+ style={{
+ width: "100%",
+ paddingTop: "56%",
+ position: "relative",
+ background: "#f7f7f7",
+ }}
+ >
+ {item.type === "img" ? (
+ <img
+ src={getOssUrl(item.url)}
+ alt=""
+ style={{
+ position: "absolute",
+ left: 0,
+ top: 0,
+ width: "100%",
+ height: "100%",
+ objectFit: "cover",
+ }}
+ />
+ ) : (
+ <video
+ src={getOssUrl(item.url)}
+ style={{
+ position: "absolute",
+ left: 0,
+ top: 0,
+ width: "100%",
+ height: "100%",
+ objectFit: "cover",
+ }}
+ />
+ )}
+ </div>
+ <div style={{ padding: 8 }}>
+ <div style={{ fontWeight: 600 }}>
+ {item.title || "-"}
+ </div>
+ <div style={{ fontSize: 12, color: "#999" }}>
+ {item.desc || ""}
+ </div>
+ </div>
+ </div>
+ </List.Item>
+ )}
+ />
+ )}
+ </div>
+ )}
+ </Modal>
+ );
+ },
+ ),
+);
+
+export default MaterialSelectionModal;
diff --git a/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasTextareaUpload.tsx b/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasTextareaUpload.tsx
index 46b6ca56..5b157894 100644
--- a/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasTextareaUpload.tsx
+++ b/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasTextareaUpload.tsx
@@ -3,10 +3,11 @@ import React, {
forwardRef,
memo,
useCallback,
+ useMemo,
useRef,
useState,
} from "react";
-import { message, Progress, Upload } from "antd";
+import { Dropdown, message, Progress, Upload } from "antd";
import {
formatImg,
formatVideo,
@@ -21,6 +22,9 @@ import { RcFile } from "antd/es/upload";
import { useTransClient } from "@/app/i18n/client";
import { UploadRef } from "antd/es/upload/Upload";
import { PlusOutlined } from "@ant-design/icons";
+import type { MenuProps } from "antd";
+import MaterialSelectionModal from "@/components/PublishDialog/compoents/MaterialSelectionModal";
+import { getOssUrl } from "@/utils/oss";
const { Dragger } = Upload;
@@ -54,6 +58,7 @@ const PubParmasTextareaUpload = memo(
const fileListRef = useRef<RcFile[]>([]);
const { t } = useTransClient("publish");
const uploadRef = useRef<UploadRef>(null);
+ const [materialSelectionOpen, setMaterialSelectionOpen] = useState(false);
// 上传视频
const uploadVideo = useCallback(
@@ -123,11 +128,80 @@ const PubParmasTextareaUpload = memo(
[onImgUpdateFinish],
);
+ const dropdownItems: MenuProps["items"] = useMemo(() => {
+ return [
+ {
+ key: "1",
+ label: (
+ <a
+ onClick={() => {
+ // 触发上传
+ uploadRef
+ .current!.nativeElement?.querySelector("input")!
+ .click();
+ }}
+ >
+ 上传本地图片或视频
+ </a>
+ ),
+ },
+ {
+ key: "2",
+ label: (
+ <a onClick={() => setMaterialSelectionOpen(true)}>
+ {t("actions.selectMaterial")}
+ </a>
+ ),
+ },
+ {
+ key: "3",
+ label: "选择草稿",
+ },
+ ];
+ }, []);
+
return (
<div
className="pubParmasTextarea-uploads-upload"
onClick={(e) => e.stopPropagation()}
>
+ <MaterialSelectionModal
+ onCancel={() => setMaterialSelectionOpen(false)}
+ libraryModalOpen={materialSelectionOpen}
+ allowImage={uploadAccept.includes("image")}
+ allowVideo={uploadAccept.includes("video")}
+ onSelected={async (item) => {
+ setUploadLoading(true);
+ const ossUrl = getOssUrl(item.url);
+ try {
+ if (item.type === "img") {
+ // 图片素材,下载
+ const req = await fetch(
+ ossUrl.replace(OSS_URL, "/ossProxy/"),
+ );
+ const blob = await req.blob();
+ const imagefile = await formatImg({
+ blob,
+ path: `${item.title || "image"}.${blob.type.split("/")[1]}`,
+ });
+ imagefile["ossUrl"] = item.url;
+ onImgUpdateFinish([imagefile]);
+ } else {
+ // TODO 视频素材,需要封面
+ const video: any = {
+ ossUrl: ossUrl,
+ videoUrl: ossUrl,
+ };
+ onVideoUpdateFinish(video);
+ }
+ } catch (e) {
+ console.error(e);
+ } finally {
+ setUploadLoading(false);
+ }
+ }}
+ />
+
<Dragger
ref={uploadRef}
style={{ display: "none" }}
@@ -188,20 +262,12 @@ const PubParmasTextareaUpload = memo(
)}
</div>
) : (
- <div
- className="pubParmasTextarea-uploads-upload-blocker"
- onClick={(e) => {
- e.stopPropagation();
- e.preventDefault();
- // 触发上传
- uploadRef
- .current!.nativeElement?.querySelector("input")!
- .click();
- }}
- >
- <PlusOutlined style={{ fontSize: "20px" }} />
- Select Files
- </div>
+ <Dropdown menu={{ items: dropdownItems }} placement="top">
+ <div className="pubParmasTextarea-uploads-upload-blocker">
+ <PlusOutlined style={{ fontSize: "20px" }} />
+ 选择文件
+ </div>
+ </Dropdown>
)}
</div>
);
diff --git a/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx b/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx
index fae2f102..89d5c0d1 100644
--- a/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx
+++ b/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx
@@ -411,7 +411,7 @@ const PubParmasTextarea = memo(
</div>
<Tooltip title={t("actions.preview")}>
<div className="pubParmasTextarea-uploads-item-video">
- <img src={v.cover.imgUrl} />
+ <img src={v.cover?.imgUrl} />
<div className="pubParmasTextarea-uploads-item-play">
<CaretRightOutlined />
</div>
diff --git a/src/components/PublishDialog/compoents/PublishDialogPreview.tsx b/src/components/PublishDialog/compoents/PublishDialogPreview.tsx
index f143b852..f98756df 100644
--- a/src/components/PublishDialog/compoents/PublishDialogPreview.tsx
+++ b/src/components/PublishDialog/compoents/PublishDialogPreview.tsx
@@ -76,7 +76,7 @@ const PublishDialogPreview = memo(
ref={videoRef}
src={expandedPubItem.params.video?.videoUrl}
controls
- poster={expandedPubItem.params.video?.cover.imgUrl}
+ poster={expandedPubItem.params.video?.cover?.imgUrl}
/>
{/* 视频信息显示 */}
<div className="publishDialogPreview-video-info" style={{ color: '#fff', fontSize: '11px' }}>
diff --git a/src/components/PublishDialog/index.tsx b/src/components/PublishDialog/index.tsx
index 2505d757..8a76d299 100644
--- a/src/components/PublishDialog/index.tsx
+++ b/src/components/PublishDialog/index.tsx
@@ -39,7 +39,6 @@ import {
import { generateUUID } from "@/utils";
import { useTransClient } from "@/app/i18n/client";
import { apiGetMaterialGroupList, apiGetMaterialList } from "@/api/material";
-import { getMediaGroupList, getMediaList } from "@/api/media";
import { getOssUrl } from "@/utils/oss";
import { toolsApi } from "@/api/tools";
import { useRouter } from "next/navigation";
@@ -215,8 +214,12 @@ const PublishDialog = memo(
await linkedinSkip(platform, targetSpaceId);
break;
default:
- console.warn(`${t("messages.unsupportedPlatformType" as any)}: ${platform}`);
- message.warning(t("messages.platformNotSupportedDirect" as any, { platform }));
+ console.warn(
+ `${t("messages.unsupportedPlatformType" as any)}: ${platform}`,
+ );
+ message.warning(
+ t("messages.platformNotSupportedDirect" as any, { platform }),
+ );
return;
}
@@ -226,7 +229,10 @@ const PublishDialog = memo(
await getAccountList();
console.log(t("messages.accountListRefreshed" as any));
} catch (error) {
- console.error(t("messages.refreshAccountListFailed" as any), error);
+ console.error(
+ t("messages.refreshAccountListFailed" as any),
+ error,
+ );
}
}, 3000); // 等待3秒让授权完成
} catch (error) {
@@ -284,7 +290,9 @@ const PublishDialog = memo(
setModerationResult(isSafe);
setModerationLevel(reason);
setModerationDesc(
- isSafe ? "" : descriptions || reason || t("actions.contentUnsafe" as any),
+ isSafe
+ ? ""
+ : descriptions || reason || t("actions.contentUnsafe" as any),
);
if (isSafe) {
message.success(t("actions.contentSafe" as any));
@@ -344,16 +352,6 @@ const PublishDialog = memo(
const [draftLoading, setDraftLoading] = useState(false);
const [drafts, setDrafts] = useState<any[]>([]);
- // 素材库选择弹窗/数据
- const [libraryModalOpen, setLibraryModalOpen] = useState(false);
- const [libraryGroupLoading, setLibraryGroupLoading] = useState(false);
- const [libraryGroups, setLibraryGroups] = useState<any[]>([]);
- const [selectedLibraryGroup, setSelectedLibraryGroup] = useState<
- any | null
- >(null);
- const [libraryLoading, setLibraryLoading] = useState(false);
- const [libraryItems, setLibraryItems] = useState<any[]>([]);
-
// 过滤可用类型(根据当前步骤和账户选择)
const allowImage = useMemo(() => {
if (step === 1 && expandedPubItem) {
@@ -415,36 +413,6 @@ const PublishDialog = memo(
}
}, []);
- // 获取素材库组列表
- const fetchLibraryGroups = useCallback(async () => {
- try {
- setLibraryGroupLoading(true);
- const res: any = await getMediaGroupList(1, 100);
- const list = res?.data?.list || [];
- const filtered = list.filter((g: any) => {
- if (g.type === "img") return allowImage;
- if (g.type === "video") return allowVideo;
- return true;
- });
- setLibraryGroups(filtered);
- } catch (e) {
- } finally {
- setLibraryGroupLoading(false);
- }
- }, [allowImage, allowVideo]);
-
- // 获取素材库内容
- const fetchLibraryItems = useCallback(async (groupId: string) => {
- try {
- setLibraryLoading(true);
- const res: any = await getMediaList(groupId, 1, 100);
- setLibraryItems(res?.data?.list || []);
- } catch (e) {
- } finally {
- setLibraryLoading(false);
- }
- }, []);
-
useEffect(() => {
if (draftModalOpen) {
setSelectedGroup(null);
@@ -459,22 +427,6 @@ const PublishDialog = memo(
}
}, [selectedGroup, fetchDrafts]);
- // 素材库弹窗打开时获取组列表
- useEffect(() => {
- if (libraryModalOpen) {
- setSelectedLibraryGroup(null);
- setLibraryItems([]);
- fetchLibraryGroups();
- }
- }, [libraryModalOpen, fetchLibraryGroups]);
-
- // 选中素材库组后加载组内素材
- useEffect(() => {
- if (selectedLibraryGroup?._id) {
- fetchLibraryItems(selectedLibraryGroup._id);
- }
- }, [selectedLibraryGroup, fetchLibraryItems]);
-
useEffect(() => {
if (open) {
init(accounts, defaultAccountId);
@@ -570,38 +522,6 @@ const PublishDialog = memo(
[setAccountAllParams, setOnePubParams, step, expandedPubItem],
);
- // 选择素材库内容后填充参数
- const applyLibraryItem = useCallback(
- (item: any) => {
- const nextParams: any = {};
- const ossUrl = getOssUrl(item.url);
-
- // 处理媒体内容
- if (item.type === "video") {
- const coverOss = item.cover;
- nextParams.video = {
- ossUrl,
- videoUrl: ossUrl,
- cover: {
- ossUrl: coverOss,
- imgUrl: coverOss,
- },
- };
- } else if (item.type === "img") {
- nextParams.images = [{ ossUrl, imgUrl: ossUrl }];
- }
-
- if (step === 1 && expandedPubItem) {
- setOnePubParams(nextParams, expandedPubItem.account.id);
- } else {
- setAccountAllParams(nextParams);
- }
- setLibraryModalOpen(false);
- message.success(t("draft.selectLibrarySuccess"));
- },
- [setAccountAllParams, setOnePubParams, step, expandedPubItem],
- );
-
// 是否打开右侧预览
const openRight = useMemo(() => {
if (step === 0) {
@@ -716,16 +636,6 @@ const PublishDialog = memo(
{t("title")}
</span>
<div style={{ display: "flex", gap: 8 }}>
- <Button
- size="small"
- icon={<PictureOutlined />}
- onClick={(e) => {
- e.stopPropagation();
- setLibraryModalOpen(true);
- }}
- >
- {t("actions.selectMaterial")}
- </Button>
<Button
size="small"
icon={<FileTextOutlined />}
@@ -1316,170 +1226,6 @@ const PublishDialog = memo(
)}
</Modal>
- {/* Material Library Selection Modal */}
- <Modal
- open={libraryModalOpen}
- onCancel={() => setLibraryModalOpen(false)}
- footer={null}
- title={
- selectedLibraryGroup
- ? t("draft.selectLibraryItem")
- : t("draft.selectLibraryGroup")
- }
- width={720}
- >
- {!selectedLibraryGroup ? (
- <div>
- {libraryGroupLoading ? (
- <div style={{ textAlign: "center", padding: 24 }}>
- <Spin />
- </div>
- ) : (
- <List
- grid={{ gutter: 16, column: 2 }}
- dataSource={libraryGroups}
- locale={{ emptyText: t("draft.noLibraryGroups") }}
- renderItem={(item: any) => (
- <List.Item>
- <div
- style={{
- background: "#F0F8FF",
- border: "2px solid transparent",
- padding: "16px",
- borderRadius: "12px",
- cursor: "pointer",
- transition: "all 0.3s ease",
- minHeight: "80px",
- display: "flex",
- flexDirection: "column",
- justifyContent: "center",
- alignItems: "center",
- textAlign: "center",
- position: "relative",
- }}
- onClick={() => setSelectedLibraryGroup(item)}
- >
- <div
- style={{
- fontSize: 24,
- marginBottom: 8,
- color: "#1890ff",
- }}
- >
- <PictureOutlined />
- </div>
- <div
- style={{
- fontWeight: 600,
- fontSize: 16,
- color: "#2c3e50",
- marginBottom: 4,
- }}
- >
- {item.title}
- </div>
- {item.desc && (
- <div
- style={{
- fontSize: 12,
- color: "#7f8c8d",
- lineHeight: 1.4,
- }}
- >
- {item.desc}
- </div>
- )}
- <div
- style={{
- position: "absolute",
- top: 8,
- left: 8,
- padding: "2px 8px",
- borderRadius: "12px",
- fontSize: 10,
- color: "#fff",
- background:
- item.type === "img" ? "#52c41a" : "#1890ff",
- }}
- >
- {item.type === "img"
- ? t("draft.imageGroup")
- : t("draft.videoGroup")}
- </div>
- </div>
- </List.Item>
- )}
- />
- )}
- </div>
- ) : (
- <div>
- <div style={{ marginBottom: 12 }}>
- <Button
- type="link"
- onClick={() => setSelectedLibraryGroup(null)}
- >
- {t("draft.backToLibraryGroups")}
- </Button>
- </div>
- {libraryLoading ? (
- <div style={{ textAlign: "center", padding: 24 }}>
- <Spin />
- </div>
- ) : (
- <List
- grid={{ gutter: 16, column: 2 }}
- dataSource={libraryItems}
- locale={{ emptyText: t("draft.noLibraryItems") }}
- renderItem={(item: any) => (
- <List.Item>
- <div
- style={{
- border: "1px solid #eee",
- borderRadius: 8,
- overflow: "hidden",
- cursor: "pointer",
- }}
- onClick={() => applyLibraryItem(item)}
- >
- <div
- style={{
- width: "100%",
- paddingTop: "56%",
- position: "relative",
- background: "#f7f7f7",
- }}
- >
- <img
- src={getOssUrl(item.url)}
- alt=""
- style={{
- position: "absolute",
- left: 0,
- top: 0,
- width: "100%",
- height: "100%",
- objectFit: "cover",
- }}
- />
- </div>
- <div style={{ padding: 8 }}>
- <div style={{ fontWeight: 600 }}>
- {item.title || "-"}
- </div>
- <div style={{ fontSize: 12, color: "#999" }}>
- {item.desc || ""}
- </div>
- </div>
- </div>
- </List.Item>
- )}
- />
- )}
- </div>
- )}
- </Modal>
-
{/* 下载App弹窗 */}
<DownloadAppModal
visible={downloadModalVisible}
diff --git a/src/constant.ts b/src/constant.ts
index 05e04eb1..d9ed2a59 100644
--- a/src/constant.ts
+++ b/src/constant.ts
@@ -2,7 +2,11 @@
export const APP_HOT_URL = "https://att-contents.yikart.cn/api";
// 代理地址
-export const ProxyUrls = ["/api/", process.env.NEXT_PUBLIC_BILI_OSS_PROXY];
+export const ProxyUrls = [
+ "/api/",
+ process.env.NEXT_PUBLIC_BILI_OSS_PROXY,
+ process.env.NEXT_PUBLIC_OSS_URL_PROXY,
+];
// OSS URL
-export const OSS_URL = process.env.NEXT_PUBLIC_OSS_URL;
+export const OSS_URL = process.env.NEXT_PUBLIC_OSS_URL!;
diff --git a/src/utils/oss.ts b/src/utils/oss.ts
index 0f62b9eb..9990a701 100644
--- a/src/utils/oss.ts
+++ b/src/utils/oss.ts
@@ -1,9 +1,9 @@
// 获取OSS域名
-export const OSS_DOMAIN = 'https://aitoearn.s3.ap-southeast-1.amazonaws.com';
+import { OSS_URL } from "@/constant";
// 获取完整的OSS URL
export const getOssUrl = (path: string) => {
- if (!path) return '';
- if (path.startsWith('http')) return path;
- return `${OSS_DOMAIN}/${path}`;
-};
\ No newline at end of file
+ if (!path) return "";
+ if (path.startsWith("http") || path.startsWith("https")) return path;
+ return `${OSS_URL}${path}`;
+};