Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat: 图文支持线上https
gaoSir4a82212a03a1
diff --git a/electron/plat/utils/index.ts b/electron/plat/utils/index.tsindex c394c803..a822c339 100644--- a/electron/plat/utils/index.ts+++ b/electron/plat/utils/index.ts@@ -34,8 +34,8 @@ export async function getFileContent(filePath: string): Promise<Buffer> {* @param filePath*/export async function getImageBaseInfo(filePath: string) {- const absolutePath = path.resolve(filePath);- const metadata = await sharp(absolutePath).metadata();+ const buffer = await getFileContent(filePath);+ const metadata = await sharp(buffer).metadata();return {width: metadata.width,diff --git a/src/icp/publish.ts b/src/icp/publish.tsindex f8cbe0c8..0723707c 100644--- a/src/icp/publish.ts+++ b/src/icp/publish.ts@@ -53,6 +53,7 @@ export async function icpCreateImgTextPubRecord(0,platInfo.commonPubParamsConfig.imgTextConfig?.imagesMax,);+ console.log(pubRecord);const res: ImgTextModel = await window.ipcRenderer.invoke('ICP_PUBLISH_CREATE_IMG_TEXT_PUL',pubRecord,diff --git a/src/views/publish/children/pubRecord/page.tsx b/src/views/publish/children/pubRecord/page.tsxindex 2385ce6c..f9a75648 100644--- a/src/views/publish/children/pubRecord/page.tsx+++ b/src/views/publish/children/pubRecord/page.tsx@@ -22,10 +22,16 @@ export const ImageView = ({height: number | string;}) => {const [imgFile, setImgFile] = useState<IImgFile>();+ const [imgUrl, setImgUrl] = useState('');+useEffect(() => {- getImgFile(prm.coverPath).then((res) => {- setImgFile(res);- });+ if (prm.coverPath.includes('https://')) {+ setImgUrl(prm.coverPath);+ } else {+ getImgFile(prm.coverPath).then((res) => {+ setImgFile(res);+ });+ }}, []);const filename = useMemo(() => {@@ -37,10 +43,18 @@ export const ImageView = ({className={styles['pubRecord-pubCon']}style={{ minHeight: height + 'px' }}>- {imgFile && <Image src={imgFile.imgUrl} height={height} width={width} />}- <span title={filename} className="pubRecord-pubCon-name">- {filename}- </span>+ {imgUrl ? (+ <Image src={imgUrl} height={height} width={width} />+ ) : (+ <>+ {imgFile && (+ <Image src={imgFile.imgUrl} height={height} width={width} />+ )}+ <span title={filename} className="pubRecord-pubCon-name">+ {filename}+ </span>+ </>+ )}</div>);};diff --git a/src/views/task/articleTask.tsx b/src/views/task/articleTask.tsxindex f7e4550b..ae94bf6c 100644--- a/src/views/task/articleTask.tsx+++ b/src/views/task/articleTask.tsx@@ -182,6 +182,8 @@ export default function ArticleTask() {});if (!recordRes) return err();+ console.log(accountListChoose);+for (const account of accountListChoose) {// 创建二级记录await icpCreateImgTextPubRecord({@@ -192,7 +194,7 @@ export default function ArticleTask() {pubRecordId: recordRes.id,publishTime: new Date(),coverPath: FILE_BASE_URL + (selectedTask.dataInfo?.imageList?.[0] || ''),- imagesPath: selectedTask.dataInfo?.imageList || [],+ imagesPath: selectedTask.dataInfo?.imageList.map(v => `https://ai-to-earn.oss-cn-beijing.aliyuncs.com/${v}`) || [],});}