Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat: 1. 热门内容,抖音、b站、快手。 2. 将获取用户信息放到全局
gaoSirf74dcb9fb34a
diff --git a/src/api/hot.ts b/src/api/hot.tsindex ad59578c..de0dbe4a 100644--- a/src/api/hot.ts+++ b/src/api/hot.ts@@ -92,6 +92,8 @@ export interface Stats {}export interface RankingContent {+ mid: string;+ secUid: string;id: string;title: string;cover: string;diff --git a/src/app/[lng]/hotContent/components/HotContent/index.tsx b/src/app/[lng]/hotContent/components/HotContent/index.tsxindex 5f074f2b..64e596fd 100644--- a/src/app/[lng]/hotContent/components/HotContent/index.tsx+++ b/src/app/[lng]/hotContent/components/HotContent/index.tsx@@ -99,23 +99,24 @@ const HotContent = memo(// 跳转到作者主页const goAuthorPage = useCallback((data: RankingContent) => {+ let authorUrl = "";switch (selectedLabelInfo.ranking.platform.type) {case "douyin":- console.log(data);+ authorUrl = `https://www.douyin.com/user/${data.secUid}`;break;case "xiaohongshu":- window.open(- `https://www.xiaohongshu.com/user/profile/${data.author.id}`,- "_blank",- );+ authorUrl = `https://www.xiaohongshu.com/user/profile/${data.author.id}`;break;case "kuaishou":+ authorUrl = `https://kuaishou.cn/profile/${data.secUid}`;break;case "bilibili":+ authorUrl = `https://space.bilibili.com/${data.mid}`;break;case "shipinhao":break;}+ if (authorUrl) window.open(authorUrl, "_blank");},[selectedLabelInfo],);diff --git a/src/app/layout/Providers.tsx b/src/app/layout/Providers.tsxindex b57b556e..23661dbf 100644--- a/src/app/layout/Providers.tsx+++ b/src/app/layout/Providers.tsx@@ -3,7 +3,7 @@import { GoogleOAuthProvider } from "@react-oauth/google";import { ConfigProvider, App, notification } from "antd";import { AntdRegistry } from "@ant-design/nextjs-registry";-import { Suspense, useEffect, useMemo } from "react";+import { Suspense, useEffect } from "react";import type { Locale } from "antd/es/locale";import zh_CN from "antd/es/locale/zh_CN";import en_US from "antd/es/locale/en_US";@@ -36,20 +36,24 @@ export function Providers({top: 74,});+ useEffect(() => {+ useUserStore.getState().getUserInfo();++ if (useUserStore.getState().token) {+ useAccountStore.getState().accountInit();+ }+ }, []);+useEffect(() => {useCommontStore.getState().setNotification(api);}, [api]);- if (useUserStore.getState().token) {- useAccountStore.getState().accountInit();- }-useEffect(() => {useUserStore.getState().setLang(lng);}, [lng]);return (- <GoogleOAuthProvider clientId="1094109734611-flskoscgp609mecqk9ablvc6i3205vqk.apps.googleusercontent.com">+ <GoogleOAuthProvider clientId="1094109734611-flskoscgp609mecqk9ablvc6i3205vqk.apps.googleusercontent.com"><ConfigProviderlocale={getAntdLang(lng)}theme={{diff --git a/src/store/account.ts b/src/store/account.tsindex 562aadc1..3f1365a9 100644--- a/src/store/account.ts+++ b/src/store/account.ts@@ -4,6 +4,7 @@ import lodash from "lodash";import { AccountGroupItem, SocialAccount } from "@/api/types/account.type";import { getAccountGroupApi, getAccountListApi } from "@/api/account";import { directTrans } from "@/app/i18n/client";+import { useUserStore } from "@/store/user";export interface AccountGroup extends AccountGroupItem {children: SocialAccount[];@@ -77,7 +78,10 @@ export const useAccountStore = create(const timeoutPromise = new Promise<any>((resolve) => {setTimeout(() => resolve({ code: -1, data: [] }), timeoutMs);});- const result = await Promise.race([getAccountListApi(), timeoutPromise]);+ const result = await Promise.race([+ getAccountListApi(),+ timeoutPromise,+ ]);if (result?.code !== 0) return;diff --git a/src/store/user.ts b/src/store/user.tsindex fd60240e..4048e2be 100644--- a/src/store/user.ts+++ b/src/store/user.ts@@ -1,4 +1,5 @@import { createPersistStore } from "@/utils/createPersistStore";+import { getUserInfoApi } from "@/api/apiReq";export interface UserInfo {createTime: string;@@ -61,6 +62,16 @@ export const useUserStore = createPersistStore(set({ userInfo });},+ // 获取用户信息+ async getUserInfo() {+ const res = await getUserInfoApi();+ if (res) {+ set({+ userInfo: res.data,+ });+ }+ },+// 清除登录状态clearLoginStatus: () => {set({ token: undefined, userInfo: undefined });