Skip to content

Let's use AI to Earn!

fix: auth status

gaoSir8bbf520cd568
diff --git a/project/aitoearn-backend/apps/aitoearn-server/src/core/channels/auth/auth.service.ts b/project/aitoearn-backend/apps/aitoearn-server/src/core/channels/auth/auth.service.ts
index 2418b71e..03f4baf6 100644
--- a/project/aitoearn-backend/apps/aitoearn-server/src/core/channels/auth/auth.service.ts
+++ b/project/aitoearn-backend/apps/aitoearn-server/src/core/channels/auth/auth.service.ts
@@ -429,6 +429,9 @@ export class AuthService {
platform: AccountType | undefined,
sessionId: string,
): Promise<AuthSessionResult> {
+ if (this.relayClientService?.enabled) {
+ throw new RelayAuthException()
+ }
const session = await this.redis.getChannelAuthSession<AuthSession>(sessionId)
if (!session || session.userId !== userId) {
throw new AppException(ResponseCode.ChannelAuthSessionInvalid)
diff --git a/project/aitoearn-web/src/api/_server/README.md b/project/aitoearn-web/src/api/_server/README.md
index 79785881..1ab15551 100644
--- a/project/aitoearn-web/src/api/_server/README.md
+++ b/project/aitoearn-web/src/api/_server/README.md
@@ -11,5 +11,5 @@
## 使用规则
- 仅用于无需鉴权的公开 API。
-- 具体业务 SSR helper 放回对应 API 模块,例如 `src/api/tasks/task.server.ts`、`src/api/channels/channel.server.ts`。
+- 具体业务 SSR helper 放回对应 API 模块,例如 `src/api/tasks/task.server.ts` 或其它模块的 `*.server.ts`。
- 客户端请求继续使用 `src/utils/request`。
diff --git a/project/aitoearn-web/src/api/channels/README.md b/project/aitoearn-web/src/api/channels/README.md
index f5d4613c..b2dec86b 100644
--- a/project/aitoearn-web/src/api/channels/README.md
+++ b/project/aitoearn-web/src/api/channels/README.md
@@ -9,7 +9,6 @@
- `channel.api.ts`
- `channel.constants.ts`
- `channel.types.ts`
-- `channel.server.ts`
## 接口清单
@@ -32,19 +31,6 @@
| `startChannelOAuthLoginApi` | `GET v2/channels/oauth/{param}` | 开始平台 OAuth 登录 |
| `updateChannelPublishAtApi` | `PATCH v2/channels/publish/tasks/{param}/publish-at` | 修改发布时间 |
-## SSR Helper 清单
-
-| 方法 | 说明 |
-| -------------------------------- | -------------------------------- |
-| `getPlatformMetadataInitialData` | SSR 预取平台元数据原始列表。 |
-| `getPlatformMetadataSSR` | 按语言归一化 SSR 平台元数据。 |
-| `getPlatformInfoMapSSR` | SSR 获取平台信息 Map。 |
-| `getPlatformInfoSSR` | SSR 获取单个平台信息。 |
-| `getEnabledPlatformsSSR` | SSR 获取启用平台 tuple 列表。 |
-| `getPublishPlatformsSSR` | SSR 获取发布平台 tuple 列表。 |
-| `getTaskPlatformsSSR` | SSR 获取任务平台 tuple 列表。 |
-| `getPlatformNameFromMap` | 从 SSR 平台 Map 中解析平台名称。 |
-
## 类型清单
| 名称 | 类型 | 说明 |
diff --git a/project/aitoearn-web/src/api/channels/channel.api.ts b/project/aitoearn-web/src/api/channels/channel.api.ts
index 31528da2..2f176fbd 100644
--- a/project/aitoearn-web/src/api/channels/channel.api.ts
+++ b/project/aitoearn-web/src/api/channels/channel.api.ts
@@ -1,4 +1,4 @@
-import type { ChannelAccountAuthStart, ChannelAccountAuthStatus, ChannelCreatePublishFlowParams, ChannelOAuthLoginStart, ChannelPlatformListOptions, ChannelPublicPublishRecordItem, ChannelPublishFlowVo, ChannelPublishRecordItem, ChannelPublishRecordListVo, ChannelPublishRecordQueryParams, ChannelPublishTaskActionVo, ChannelPublishUserActionVo, ChannelWorkAnalyticsVo, ChannelWorkQueryParams, PlatformMetadataVo, StartChannelAccountAuthParams, StartChannelOAuthLoginParams } from './channel.types'
+import type { ChannelAccountAuthStart, ChannelAccountAuthStatus, ChannelCreatePublishFlowParams, ChannelOAuthLoginStart, ChannelPlatformListOptions, ChannelPublicPublishRecordItem, ChannelPublishFlowVo, ChannelPublishRecordItem, ChannelPublishRecordListVo, ChannelPublishRecordQueryParams, ChannelPublishTaskActionVo, ChannelPublishUserActionVo, ChannelWorkAnalyticsVo, ChannelWorkQueryParams, PlatformMetadataVo, StartChannelAccountAuthParams, StartChannelOAuthLoginParams } from './channel.types'
import type { PlatType } from '@/app/config/platConfig'
import http, { request } from '@/utils/request'
@@ -77,7 +77,6 @@ export function createChannelPublishFlowApi(data: ChannelCreatePublishFlowParams
return http.post<ChannelPublishFlowVo>('v2/channels/publish/flows', data)
}
-
/**
* 获取 Flow 详情
* 根据 flowId 获取发布 flow 聚合信息
diff --git a/project/aitoearn-web/src/app/[lng]/layout.tsx b/project/aitoearn-web/src/app/[lng]/layout.tsx
index ef6f18b4..02bf3ec4 100644
--- a/project/aitoearn-web/src/app/[lng]/layout.tsx
+++ b/project/aitoearn-web/src/app/[lng]/layout.tsx
@@ -1,7 +1,6 @@
import { dir } from 'i18next'
import { headers } from 'next/headers'
import Script from 'next/script'
-import { getPlatformMetadataInitialData } from '@/api/channels/channel.server'
import { useTranslation } from '@/app/i18n'
import { getHreflang } from '@/app/i18n/languageConfig'
import { fallbackLng, languages } from '@/app/i18n/settings'
@@ -55,7 +54,6 @@ export default async function RootLayout({
params: Promise<{ lng: string }>
}>) {
const { lng } = await params
- const platformMetadata = await getPlatformMetadataInitialData()
const autoLoginToken = process.env.AUTO_LOGIN_TOKEN?.trim() || undefined
return (
@@ -81,7 +79,7 @@ export default async function RootLayout({
}}
/>
<Script src="https://r.wdfl.co/rw.js" data-rewardful="ded70f" strategy="afterInteractive" />
- <Providers lng={lng} platformMetadata={platformMetadata ?? []} autoLoginToken={autoLoginToken}>
+ <Providers lng={lng} autoLoginToken={autoLoginToken}>
{/* 全局频道管理弹框 */}
<ChannelManager />
<p className="hidden">Impact-Site-Verification: f9836212-462a-482f-9232-8a877970eacf</p>
diff --git a/project/aitoearn-web/src/app/layout/Providers.tsx b/project/aitoearn-web/src/app/layout/Providers.tsx
index 57fb8da2..12f7f97b 100644
--- a/project/aitoearn-web/src/app/layout/Providers.tsx
+++ b/project/aitoearn-web/src/app/layout/Providers.tsx
@@ -5,7 +5,6 @@
'use client'
-import type { PlatformMetadataVo } from '@/api/channels/channel.types'
import { GoogleOAuthProvider } from '@react-oauth/google'
import { ThemeProvider } from 'next-themes'
import { usePathname } from 'next/navigation'
@@ -34,12 +33,10 @@ export function usePublicRoute() {
export function Providers({
children,
lng,
- platformMetadata,
autoLoginToken,
}: {
children: React.ReactNode
lng: string
- platformMetadata: PlatformMetadataVo[]
autoLoginToken?: string
}) {
const pathname = usePathname()
@@ -55,14 +52,6 @@ export function Providers({
})),
)
- useLayoutEffect(() => {
- if (platformMetadata.length === 0)
- return
- if (usePlatformMetadataStore.getState().loadedLng === lng)
- return
- usePlatformMetadataStore.getState().setPlatformMetadata(platformMetadata, lng)
- }, [lng, platformMetadata])
-
useEffect(() => {
if (usePlatformMetadataStore.getState().loadedLng === lng)
return
diff --git a/project/aitoearn-web/src/app/layout/SettingsModal/tabs/ProfileTab.tsx b/project/aitoearn-web/src/app/layout/SettingsModal/tabs/ProfileTab.tsx
index 8afd3adc..d0c4eec0 100644
--- a/project/aitoearn-web/src/app/layout/SettingsModal/tabs/ProfileTab.tsx
+++ b/project/aitoearn-web/src/app/layout/SettingsModal/tabs/ProfileTab.tsx
@@ -1,4 +1,4 @@
-/**
+/**
* ProfileTab - 个人资料设置 Tab
*/
@@ -10,13 +10,13 @@ import { useShallow } from 'zustand/shallow'
import { updateUserInfoApi } from '@/api/auth/auth.api'
import { uploadToOss } from '@/api/materials/material.api'
import { useTransClient } from '@/app/i18n/client'
-import { AvatarCropModal } from './components/AvatarCropModal'
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
import { Button } from '@/components/ui/button'
-import { toast } from '@/utils/ui/toast'
-import { cn } from '@/utils/className'
import { useUserStore } from '@/store/user'
+import { cn } from '@/utils/className'
import { getOssUrl } from '@/utils/oss'
+import { toast } from '@/utils/ui/toast'
+import { AvatarCropModal } from './components/AvatarCropModal'
interface ProfileTabProps {
onClose: () => void
diff --git a/project/aitoearn-web/src/components/ChannelManager/channelManagerStore.ts b/project/aitoearn-web/src/components/ChannelManager/channelManagerStore.ts
index 3c7136da..f9b3125c 100644
--- a/project/aitoearn-web/src/components/ChannelManager/channelManagerStore.ts
+++ b/project/aitoearn-web/src/components/ChannelManager/channelManagerStore.ts
@@ -27,7 +27,6 @@ import {
PluginStatus,
usePluginStore,
} from '@/store/plugin'
-import { useUserStore } from '@/store/user'
import { confirmPlatformRegionRedirect } from '@/utils/region/redirect'
import { toast } from '@/utils/ui/toast'
import { DEFAULT_AUTH_COUNTDOWN, POLLING_INTERVAL } from './types'
diff --git a/project/aitoearn-web/src/store/README.md b/project/aitoearn-web/src/store/README.md
index dc7f0cff..5ace8d26 100644
--- a/project/aitoearn-web/src/store/README.md
+++ b/project/aitoearn-web/src/store/README.md
@@ -13,7 +13,7 @@ src/store/
├── settingsModal.ts # 全局设置弹窗状态
├── configManagerDialog.ts # 全局配置管理弹窗状态
├── login-dialog/ # 全局登录弹窗状态
-├── platformMetadata/ # 平台元数据、静态图标和场景过滤
+├── platformMetadata/ # 客户端平台元数据、静态图标和场景过滤
├── publishDetailCache.ts # 发布详情缓存
├── douyinPublishSession.ts # 抖音 H5 发布会话缓存
├── thumbnailCache.ts # 视频缩略图缓存
@@ -32,7 +32,7 @@ src/store/
| `settingsModal.ts` | `useSettingsModalStore` | 全局设置弹窗可见性、默认 Tab 与子 Tab | 否 |
| `configManagerDialog.ts` | `useConfigManagerDialogStore` | 全局配置管理弹窗可见性与触发来源 | 否 |
| `login-dialog/` | `useLoginDialogStore` | 全局登录弹窗、登录后跳转与邀请码 | 否 |
-| `platformMetadata/` | `usePlatformMetadataStore` | 后端平台元数据、静态图标兜底、平台状态与场景过滤 | 否 |
+| `platformMetadata/` | `usePlatformMetadataStore` | 客户端平台元数据、静态图标兜底、平台状态与场景过滤 | 否 |
| `publishDetailCache.ts` | `usePublishDetailCache` | 发布详情缓存(5 分钟过期) | 是(IndexedDB) |
| `douyinPublishSession.ts` | `useDouyinPublishSessionStore` | 抖音 H5 发布会话缓存(10 分钟恢复) | 是(IndexedDB) |
| `thumbnailCache.ts` | `useThumbnailCacheStore` | 视频缩略图缓存 | 是 |
@@ -56,7 +56,7 @@ src/store/
### `usePlatformMetadataStore` — 平台元数据
-- 统一承接 SSR 初始平台数据和客户端刷新。
+- 统一通过客户端请求加载平台数据,并支持按语言重新归一化已有数据。
- 提供平台 Map、静态图标兜底、启用平台、发布平台、任务平台等场景过滤能力。
### `useDouyinPublishSessionStore` — 抖音 H5 发布会话
diff --git a/project/aitoearn-web/src/store/platformMetadata/index.ts b/project/aitoearn-web/src/store/platformMetadata/index.ts
index 6a7ebb04..caa11ef8 100644
--- a/project/aitoearn-web/src/store/platformMetadata/index.ts
+++ b/project/aitoearn-web/src/store/platformMetadata/index.ts
@@ -97,11 +97,6 @@ function createPlatformMetadataState(rawList: PlatformMetadataVo[], lng: string)
export const usePlatformMetadataStore = create(
combine(initialState, (set, get) => ({
- setPlatformMetadata(rawList: PlatformMetadataVo[], lng: string) {
- latestRequestedLng = lng
- set(createPlatformMetadataState(rawList, lng))
- },
-
async ensureLoaded(lng: string, options?: { force?: boolean }) {
latestRequestedLng = lng
const force = options?.force === true