Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat: Move the subscription management to Settings (#411)
Gao2b82b03a4747
diff --git a/project/web/public/sitemap-0.xml b/project/web/public/sitemap-0.xmlindex 0e7b6a0e..bac7e2a5 100644--- a/project/web/public/sitemap-0.xml+++ b/project/web/public/sitemap-0.xml@@ -1,6 +1,6 @@<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">-<url><loc>https://aitoearn.ai/healthz</loc><lastmod>2025-12-18T10:24:31.293Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>+<url><loc>https://aitoearn.ai/healthz</loc><lastmod>2025-12-18T10:26:51.048Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url><url><loc>https://aitoearn.ai/en</loc><lastmod>2025-12-17T16:35:41.143Z</lastmod><changefreq>monthly</changefreq><priority>0.8</priority></url><url><loc>https://aitoearn.ai/en/websit/terms-of-service</loc><lastmod>2025-12-12T06:46:42.350Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url><url><loc>https://aitoearn.ai/en/websit/privacy-policy</loc><lastmod>2025-12-12T06:46:42.349Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>diff --git a/project/web/src/app/[lng]/chat/[taskId]/page.tsx b/project/web/src/app/[lng]/chat/[taskId]/page.tsxindex 6b5ec479..2a4ffe1f 100644--- a/project/web/src/app/[lng]/chat/[taskId]/page.tsx+++ b/project/web/src/app/[lng]/chat/[taskId]/page.tsx@@ -273,7 +273,7 @@ export default function ChatDetailPage() {/>{/* 底部输入区域 */}- <div className="w-full p-4">+ <div className="p-4 bg-background border-t border-border shrink-0"><ChatInputvalue={inputValue}onChange={setInputValue}diff --git a/project/web/src/app/[lng]/pricing/components/PricingContent/index.tsx b/project/web/src/app/[lng]/pricing/components/PricingContent/index.tsxindex 852280d5..37107b91 100644--- a/project/web/src/app/[lng]/pricing/components/PricingContent/index.tsx+++ b/project/web/src/app/[lng]/pricing/components/PricingContent/index.tsx@@ -16,7 +16,7 @@ import { useUserStore } from '@/store/user'import { Skeleton } from '@/components/ui/skeleton'import { toast } from '@/lib/toast'import { createPaymentOrderApi, PaymentType } from '@/api/vip'-import { SubscriptionManagementDialog } from '../SubscriptionManagementDialog'+import { useSettingsModalStore } from '@/components/SettingsModal/store'/** 企业版联系邮箱 */const ENTERPRISE_EMAIL = '[email protected]'@@ -53,7 +53,7 @@ export const PricingContent = memo(({ lng }: PricingContentProps) => {const userStore = useUserStore()const router = useRouter()const [loadingPlan, setLoadingPlan] = useState<string | null>(null)- const [subscriptionDialogOpen, setSubscriptionDialogOpen] = useState(false)+ const openSettings = useSettingsModalStore(state => state.openSettings)// 状态判断辅助函数const getVipStatusInfo = (status: string) => {@@ -241,21 +241,13 @@ export const PricingContent = memo(({ lng }: PricingContentProps) => {isVip={!!isVip}isLoading={loadingPlan === plan.id}onSelect={() => handleSelectPlan(plan.id)}- onOpenSubscriptionManagement={() => setSubscriptionDialogOpen(true)}+ onOpenSubscriptionManagement={() => openSettings('membership')}t={t}/>))}</div></div></div>-- {/* 订阅管理对话框 */}- {userStore.userInfo && (- <SubscriptionManagementDialog- open={subscriptionDialogOpen}- onClose={() => setSubscriptionDialogOpen(false)}- />- )}</>)})diff --git a/project/web/src/app/i18n/locales/en/settings.json b/project/web/src/app/i18n/locales/en/settings.jsonindex d637aa07..30539427 100644--- a/project/web/src/app/i18n/locales/en/settings.json+++ b/project/web/src/app/i18n/locales/en/settings.json@@ -4,6 +4,7 @@"profile": "Profile","agent": "Agent","subscription": "Subscription",+ "membership": "Membership","general": "General"},"profile": {diff --git a/project/web/src/app/i18n/locales/zh-CN/settings.json b/project/web/src/app/i18n/locales/zh-CN/settings.jsonindex acb04116..565e7e25 100644--- a/project/web/src/app/i18n/locales/zh-CN/settings.json+++ b/project/web/src/app/i18n/locales/zh-CN/settings.json@@ -4,6 +4,7 @@"profile": "个人资料","agent": "Agent","subscription": "订阅",+ "membership": "会员","general": "通用"},"profile": {diff --git a/project/web/src/app/layout/LayoutSidebar/index.tsx b/project/web/src/app/layout/LayoutSidebar/index.tsxindex 4037347a..a330f3b0 100644--- a/project/web/src/app/layout/LayoutSidebar/index.tsx+++ b/project/web/src/app/layout/LayoutSidebar/index.tsx@@ -20,6 +20,7 @@ import {IconBar,UserSection,} from './components'+import { useSettingsModalStore } from '@/components/SettingsModal/store'/*** 侧边栏主组件@@ -33,8 +34,12 @@ const LayoutSidebar = () => {// UI 状态const [collapsed, setCollapsed] = useState(false)const [notificationVisible, setNotificationVisible] = useState(false)- const [settingsVisible, setSettingsVisible] = useState(false)- const [settingsDefaultTab, setSettingsDefaultTab] = useState<SettingsTab | undefined>(undefined)+ const {+ settingsVisible,+ settingsDefaultTab,+ openSettings,+ closeSettings,+ } = useSettingsModalStore()// 获取当前路由let currRouter = '/'@@ -59,14 +64,12 @@ const LayoutSidebar = () => {// 打开设置弹框const handleOpenSettings = (defaultTab?: SettingsTab) => {- setSettingsDefaultTab(defaultTab)- setSettingsVisible(true)+ openSettings(defaultTab)}// 关闭设置弹框const handleCloseSettings = () => {- setSettingsVisible(false)- setSettingsDefaultTab(undefined)+ closeSettings()}// 转换路由数据为 NavSection 所需格式diff --git a/project/web/src/components/SettingsModal/index.tsx b/project/web/src/components/SettingsModal/index.tsxindex 922e78a5..c004a589 100644--- a/project/web/src/components/SettingsModal/index.tsx+++ b/project/web/src/components/SettingsModal/index.tsx@@ -7,7 +7,7 @@'use client'import type { ReactNode } from 'react'-import { Bot, CreditCard, Globe, User } from 'lucide-react'+import { Bot, CreditCard, Crown, Globe, User } from 'lucide-react'import Image from 'next/image'import { useEffect, useState } from 'react'import { useTransClient } from '@/app/i18n/client'@@ -18,11 +18,11 @@ import {} from '@/components/ui/dialog'import { cn } from '@/lib/utils'import { useUserStore } from '@/store/user'-import { AgentTab, GeneralTab, ProfileTab, SubscriptionTab } from './tabs'+import { AgentTab, GeneralTab, MembershipTab, ProfileTab, SubscriptionTab } from './tabs'import logo from '@/assets/images/logo.png'/** 设置页面类型 */-type SettingsTab = 'profile' | 'agent' | 'subscription' | 'general'+type SettingsTab = 'profile' | 'agent' | 'subscription' | 'membership' | 'general'/** Tab 配置项类型 */interface TabConfig {@@ -51,6 +51,7 @@ export interface SettingsModalProps {export const SettingsModal = ({ open, onClose, defaultTab }: SettingsModalProps) => {const { t } = useTransClient('settings')const token = useUserStore(state => state.token)+ const userInfo = useUserStore(state => state.userInfo)const isLoggedIn = !!tokenconst [activeTab, setActiveTab] = useState<SettingsTab>(isLoggedIn ? 'profile' : 'general')@@ -74,6 +75,15 @@ export const SettingsModal = ({ open, onClose, defaultTab }: SettingsModalProps){ key: 'profile', icon: <User className="h-4 w-4" />, label: t('tabs.profile'), requireAuth: true },{ key: 'agent', icon: <Bot className="h-4 w-4" />, label: t('tabs.agent'), requireAuth: true },{ key: 'subscription', icon: <CreditCard className="h-4 w-4" />, label: t('tabs.subscription'), requireAuth: true },+ // 会员 Tab:只有用户曾经有过 vipInfo 才显示+ ...(userInfo?.vipInfo+ ? [{+ key: 'membership' as SettingsTab,+ icon: <Crown className="h-4 w-4" />,+ label: t('tabs.membership' as any) ?? '会员',+ requireAuth: true,+ }]+ : []),{ key: 'general', icon: <Globe className="h-4 w-4" />, label: t('tabs.general') },]@@ -89,6 +99,8 @@ export const SettingsModal = ({ open, onClose, defaultTab }: SettingsModalProps)return isLoggedIn ? <AgentTab /> : <GeneralTab />case 'subscription':return isLoggedIn ? <SubscriptionTab /> : <GeneralTab />+ case 'membership':+ return isLoggedIn ? <MembershipTab /> : <GeneralTab />case 'general':return <GeneralTab />default:@@ -98,10 +110,13 @@ export const SettingsModal = ({ open, onClose, defaultTab }: SettingsModalProps)return (<Dialog open={open} onOpenChange={isOpen => !isOpen && onClose()}>- <DialogContent className="max-w-[880px] gap-0 overflow-hidden p-0" aria-describedby={undefined}>+ <DialogContent+ className="max-w-[880px] gap-0 overflow-hidden p-0"+ aria-describedby={undefined}+ ><DialogTitle className="sr-only">{t('title')}</DialogTitle>- <div className="flex min-h-[560px]">+ <div className="flex h-[70vh]">{/* 左侧侧边栏 */}<div className="flex w-52 shrink-0 flex-col border-r border-border">{/* 侧边栏头部 - Logo + 项目名称 */}@@ -135,14 +150,14 @@ export const SettingsModal = ({ open, onClose, defaultTab }: SettingsModalProps)</div>{/* 右侧内容区域 */}- <div className="flex flex-1 flex-col overflow-hidden">+ <div className="flex flex-1 flex-col overflow-hidden min-h-0">{/* 右侧头部 - 设置标题 */}<div className="flex shrink-0 items-center border-b border-border px-8 py-4"><h2 className="text-lg font-semibold text-foreground">{t('title')}</h2></div>{/* 右侧内容 */}- <div className="flex-1 overflow-auto px-8 py-6">+ <div className="flex-1 overflow-y-auto px-8 py-6">{renderContent()}</div></div>diff --git a/project/web/src/components/SettingsModal/tabs/index.ts b/project/web/src/components/SettingsModal/tabs/index.tsindex b7f487e5..e1c95f93 100644--- a/project/web/src/components/SettingsModal/tabs/index.ts+++ b/project/web/src/components/SettingsModal/tabs/index.ts@@ -6,4 +6,5 @@ export * from './ProfileTab'export * from './AgentTab'export * from './GeneralTab'export * from './SubscriptionTab'+export * from './MembershipTab'diff --git a/project/web/src/store/agent/handlers/action.handlers.ts b/project/web/src/store/agent/handlers/action.handlers.tsindex 82c6376f..4007a39d 100644--- a/project/web/src/store/agent/handlers/action.handlers.ts+++ b/project/web/src/store/agent/handlers/action.handlers.ts@@ -16,6 +16,7 @@ import { PluginStatus } from '@/store/plugin/types/baseTypes'import type { PluginPublishItem } from '@/store/plugin/store'import { driver } from 'driver.js'import type { ITaskData, IActionContext, ActionType, IMediaItem } from '../agent.types'+import { useTransClient } from '@/app/i18n/client'// ============ Action Handler 接口 ============@@ -320,7 +321,8 @@ const saveDraftHandler: IActionHandler = {},async execute(taskData, context) {- const { router, lng, t } = context+ const { router, lng } = context+ const { t } = useTransClient('home')try {// 转换 medias 格式@@ -397,7 +399,8 @@ const updateChannelHandler: IActionHandler = {},async execute(taskData, context) {- const { router, lng, t } = context+ const { router, lng } = context+ const { t } = useTransClient('home')const platform = taskData.platformtoast.warning(t('aiGeneration.channelAuthExpired' as any))@@ -425,7 +428,8 @@ const loginChannelHandler: IActionHandler = {},async execute(taskData, context) {- const { router, lng, t } = context+ const { router, lng } = context+ const { t } = useTransClient('home')const platform = taskData.platformtoast.info(t('aiGeneration.needLoginChannel' as any))@@ -453,8 +457,9 @@ const createChannelHandler: IActionHandler = {},async execute(taskData, context) {- const { router, lng, t } = context+ const { router, lng } = contextconst platform = taskData.platform+ const { t } = useTransClient('home')toast.warning(taskData.errorMessage || (t('aiGeneration.needBindChannel' as any) as string))@@ -590,9 +595,9 @@ export const ActionRegistry = {* @param context Action 上下文*/async executePluginBatch(pluginTasks: ITaskData[], context: IActionContext): Promise<void> {- const { t } = contextconst pluginStatus = usePluginStore.getState().statusconst isPluginReady = pluginStatus === PluginStatus.READY+ const { t } = useTransClient('home')if (!isPluginReady) {toast.warning(t('plugin.platformNeedsPlugin' as any))