From 435eddd8676ecdcad079e03625a0239ba13bcee1 Mon Sep 17 00:00:00 2001 From: KVOJJJin Date: Tue, 14 Jan 2025 10:00:57 +0800 Subject: [PATCH] Feat: copyright modification (#12707) --- .../app/overview/settings/index.tsx | 374 ++++++++++++------ .../app/overview/settings/style.module.css | 18 - .../chat/chat-with-history/sidebar/index.tsx | 8 +- .../icons/assets/public/common/highlight.svg | 9 + .../assets/public/common/sparkles-soft.svg | 6 + .../icons/src/public/common/Highlight.json | 67 ++++ .../icons/src/public/common/Highlight.tsx | 16 + .../icons/src/public/common/SparklesSoft.json | 47 +++ .../icons/src/public/common/SparklesSoft.tsx | 16 + .../base/icons/src/public/common/index.ts | 2 + .../components/base/premium-badge/index.css | 48 +++ .../components/base/premium-badge/index.tsx | 78 ++++ .../share/text-generation/index.tsx | 6 +- web/i18n/en-US/app-overview.ts | 7 +- web/i18n/zh-Hans/app-overview.ts | 3 + 15 files changed, 550 insertions(+), 155 deletions(-) delete mode 100644 web/app/components/app/overview/settings/style.module.css create mode 100644 web/app/components/base/icons/assets/public/common/highlight.svg create mode 100644 web/app/components/base/icons/assets/public/common/sparkles-soft.svg create mode 100644 web/app/components/base/icons/src/public/common/Highlight.json create mode 100644 web/app/components/base/icons/src/public/common/Highlight.tsx create mode 100644 web/app/components/base/icons/src/public/common/SparklesSoft.json create mode 100644 web/app/components/base/icons/src/public/common/SparklesSoft.tsx create mode 100644 web/app/components/base/premium-badge/index.css create mode 100644 web/app/components/base/premium-badge/index.tsx diff --git a/web/app/components/app/overview/settings/index.tsx b/web/app/components/app/overview/settings/index.tsx index e7cc4148e..f9d13b927 100644 --- a/web/app/components/app/overview/settings/index.tsx +++ b/web/app/components/app/overview/settings/index.tsx @@ -1,26 +1,33 @@ 'use client' import type { FC } from 'react' -import React, { useEffect, useState } from 'react' -import { ChevronRightIcon } from '@heroicons/react/20/solid' +import React, { useCallback, useEffect, useState } from 'react' +import { RiArrowRightSLine, RiCloseLine } from '@remixicon/react' import Link from 'next/link' import { Trans, useTranslation } from 'react-i18next' -import { useContextSelector } from 'use-context-selector' -import s from './style.module.css' +import { useContext, useContextSelector } from 'use-context-selector' +import { SparklesSoft } from '@/app/components/base/icons/src/public/common' import Modal from '@/app/components/base/modal' +import ActionButton from '@/app/components/base/action-button' import Button from '@/app/components/base/button' +import Divider from '@/app/components/base/divider' import Input from '@/app/components/base/input' import Textarea from '@/app/components/base/textarea' import AppIcon from '@/app/components/base/app-icon' import Switch from '@/app/components/base/switch' +import PremiumBadge from '@/app/components/base/premium-badge' import { SimpleSelect } from '@/app/components/base/select' import type { AppDetailResponse } from '@/models/app' import type { AppIconType, AppSSO, Language } from '@/types/app' import { useToastContext } from '@/app/components/base/toast' -import { languages } from '@/i18n/language' +import { LanguagesSupported, languages } from '@/i18n/language' import Tooltip from '@/app/components/base/tooltip' import AppContext, { useAppContext } from '@/context/app-context' +import { useProviderContext } from '@/context/provider-context' +import { useModalContext } from '@/context/modal-context' import type { AppIconSelection } from '@/app/components/base/app-icon-picker' import AppIconPicker from '@/app/components/base/app-icon-picker' +import I18n from '@/context/i18n' +import cn from '@/utils/classnames' export type ISettingsModalProps = { isChat: boolean @@ -84,6 +91,7 @@ const SettingsModal: FC = ({ chatColorTheme: chat_color_theme, chatColorThemeInverted: chat_color_theme_inverted, copyright, + copyrightSwitchValue: !!copyright, privacyPolicy: privacy_policy, customDisclaimer: custom_disclaimer, show_workflow_steps, @@ -93,6 +101,7 @@ const SettingsModal: FC = ({ const [language, setLanguage] = useState(default_language) const [saveLoading, setSaveLoading] = useState(false) const { t } = useTranslation() + const { locale } = useContext(I18n) const [showAppIconPicker, setShowAppIconPicker] = useState(false) const [appIcon, setAppIcon] = useState( @@ -100,7 +109,16 @@ const SettingsModal: FC = ({ ? { type: 'image', url: icon_url!, fileId: icon } : { type: 'emoji', icon, background: icon_background! }, ) - const isChatBot = appInfo.mode === 'chat' || appInfo.mode === 'advanced-chat' || appInfo.mode === 'agent-chat' + + const { enableBilling, plan } = useProviderContext() + const { setShowPricingModal, setShowAccountSettingModal } = useModalContext() + const isFreePlan = plan.type === 'sandbox' + const handlePlanClick = useCallback(() => { + if (isFreePlan) + setShowPricingModal() + else + setShowAccountSettingModal({ payload: 'billing' }) + }, [isFreePlan, setShowAccountSettingModal, setShowPricingModal]) useEffect(() => { setInputInfo({ @@ -109,6 +127,7 @@ const SettingsModal: FC = ({ chatColorTheme: chat_color_theme, chatColorThemeInverted: chat_color_theme_inverted, copyright, + copyrightSwitchValue: !!copyright, privacyPolicy: privacy_policy, customDisclaimer: custom_disclaimer, show_workflow_steps, @@ -158,7 +177,11 @@ const SettingsModal: FC = ({ chat_color_theme: inputInfo.chatColorTheme, chat_color_theme_inverted: inputInfo.chatColorThemeInverted, prompt_public: false, - copyright: inputInfo.copyright, + copyright: isFreePlan + ? '' + : inputInfo.copyrightSwitchValue + ? inputInfo.copyright + : '', privacy_policy: inputInfo.privacyPolicy, custom_disclaimer: inputInfo.customDisclaimer, icon_type: appIcon.type, @@ -192,141 +215,232 @@ const SettingsModal: FC = ({ return ( <> -
{t(`${prefixSettings}.webName`)}
-
- { setShowAppIconPicker(true) }} - className='cursor-pointer !mr-3 self-center' - iconType={appIcon.type} - icon={appIcon.type === 'image' ? appIcon.fileId : appIcon.icon} - background={appIcon.type === 'image' ? undefined : appIcon.background} - imageUrl={appIcon.type === 'image' ? appIcon.url : undefined} - /> - + {/* header */} +
+
+
{t(`${prefixSettings}.title`)}
+ + + +
+
+ {t(`${prefixSettings}.modalTip`)} + {t('common.operation.learnMore')} +
-
{t(`${prefixSettings}.webDesc`)}
-

{t(`${prefixSettings}.webDescTip`)}

-