diff --git a/packages/global/support/user/type.d.ts b/packages/global/support/user/type.d.ts index 43ea840e4..6c5245418 100644 --- a/packages/global/support/user/type.d.ts +++ b/packages/global/support/user/type.d.ts @@ -27,7 +27,6 @@ export type UserType = { timezone: string; promotionRate: UserModelSchema['promotionRate']; team: TeamTmbItemType; - standardInfo?: standardInfoType; notificationAccount?: string; permission: TeamPermission; contact?: string; diff --git a/packages/web/components/common/Icon/icons/feedback.svg b/packages/web/components/common/Icon/icons/feedback.svg index 551b78a55..3f4c99b5f 100644 --- a/packages/web/components/common/Icon/icons/feedback.svg +++ b/packages/web/components/common/Icon/icons/feedback.svg @@ -1,4 +1,4 @@ - + diff --git a/packages/web/i18n/en/common.json b/packages/web/i18n/en/common.json index 3d0a4b630..d1b1b39be 100644 --- a/packages/web/i18n/en/common.json +++ b/packages/web/i18n/en/common.json @@ -1012,6 +1012,7 @@ "plugin.go to laf": "Go to Write", "plugin.path": "Path", "prompt_input_placeholder": "Please enter the prompt word", + "question_feedback": "Work order", "read_quote": "View citations", "required": "Required", "resume_failed": "Resume Failed", diff --git a/packages/web/i18n/zh-CN/common.json b/packages/web/i18n/zh-CN/common.json index d0ed58c0b..640486d9f 100644 --- a/packages/web/i18n/zh-CN/common.json +++ b/packages/web/i18n/zh-CN/common.json @@ -1015,6 +1015,7 @@ "plugin.go to laf": "去编写", "plugin.path": "路径", "prompt_input_placeholder": "请输入提示词", + "question_feedback": "工单咨询", "read_quote": "查看引用", "required": "必须", "resume_failed": "恢复失败", @@ -1283,6 +1284,5 @@ "xx_search_result": "{{key}} 的搜索结果", "yes": "是", "yesterday": "昨天", - "yesterday_detail_time": "昨天 {{time}}", - "question_feedback": "问题反馈" + "yesterday_detail_time": "昨天 {{time}}" } diff --git a/packages/web/i18n/zh-Hant/common.json b/packages/web/i18n/zh-Hant/common.json index a2e56234a..1e08fd693 100644 --- a/packages/web/i18n/zh-Hant/common.json +++ b/packages/web/i18n/zh-Hant/common.json @@ -1011,6 +1011,7 @@ "plugin.go to laf": "前往編寫", "plugin.path": "路徑", "prompt_input_placeholder": "請輸入提示詞", + "question_feedback": "工單諮詢", "read_quote": "查看引用", "required": "必填", "resume_failed": "恢復失敗", diff --git a/projects/app/src/components/support/workorder/WorkorderButton.tsx b/projects/app/src/components/Layout/WorkorderButton.tsx similarity index 58% rename from projects/app/src/components/support/workorder/WorkorderButton.tsx rename to projects/app/src/components/Layout/WorkorderButton.tsx index 8518657b4..b0445ea92 100644 --- a/projects/app/src/components/support/workorder/WorkorderButton.tsx +++ b/projects/app/src/components/Layout/WorkorderButton.tsx @@ -1,33 +1,64 @@ +import { useSystemStore } from '@/web/common/system/useSystemStore'; import { getWorkorderURL } from '@/web/common/workorder/api'; +import { useUserStore } from '@/web/support/user/useUserStore'; import { Box, Flex } from '@chakra-ui/react'; +import { StandardSubLevelEnum } from '@fastgpt/global/support/wallet/sub/constants'; import Icon from '@fastgpt/web/components/common/Icon'; import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; +import { useSystem } from '@fastgpt/web/hooks/useSystem'; import { useToggle } from 'ahooks'; import { useTranslation } from 'next-i18next'; +import { useRouter } from 'next/router'; +import { useMemo } from 'react'; + +const WorkOrderShowRouter: { [key: string]: boolean } = { + '/app/list': true, + '/dataset/list': true, + '/toolkit': true +}; function WorkorderButton() { + const router = useRouter(); const [open, setOpen] = useToggle(true); const { t } = useTranslation(); - const { data, runAsync } = useRequest2(getWorkorderURL, { - manual: true + const { feConfigs, subPlans } = useSystemStore(); + const { teamPlanStatus } = useUserStore(); + + const { isPc } = useSystem(); + + const { runAsync: onFeedback } = useRequest2(getWorkorderURL, { + manual: true, + onSuccess(data) { + if (data) { + window.open(data.redirectUrl); + } + } }); - const onFeedback = async () => { - await runAsync(); - if (data) { - window.open(data.redirectUrl); - } - }; - return ( + const showWorkorder = WorkOrderShowRouter[router.pathname]; + + const isPlanUser = useMemo(() => { + if (!teamPlanStatus) return false; + if (teamPlanStatus.standard?.currentSubLevel !== StandardSubLevelEnum.free) return true; + if (teamPlanStatus.datasetMaxSize !== subPlans?.standard?.free?.maxDatasetSize) return true; + if (teamPlanStatus.totalPoints !== subPlans?.standard?.free?.totalPoints) return true; + return false; + }, [ + subPlans?.standard?.free?.maxDatasetSize, + subPlans?.standard?.free?.totalPoints, + teamPlanStatus + ]); + + return showWorkorder && feConfigs?.show_workorder && isPlanUser && isPc ? ( <> {open ? ( - - + + {t('common:question_feedback')} @@ -82,7 +113,7 @@ function WorkorderButton() { ) : ( )} - ); + ) : null; } export default WorkorderButton; diff --git a/projects/app/src/components/Layout/auth.tsx b/projects/app/src/components/Layout/auth.tsx index 85baf1fe0..0c2c0c42b 100644 --- a/projects/app/src/components/Layout/auth.tsx +++ b/projects/app/src/components/Layout/auth.tsx @@ -3,7 +3,6 @@ import { useUserStore } from '@/web/support/user/useUserStore'; import { useQuery } from '@tanstack/react-query'; import { useTranslation } from 'next-i18next'; import { useToast } from '@fastgpt/web/hooks/useToast'; -import { useSystemStore } from '@/web/common/system/useSystemStore'; const unAuthPage: { [key: string]: boolean } = { '/': true, diff --git a/projects/app/src/components/Layout/index.tsx b/projects/app/src/components/Layout/index.tsx index e880b2a68..40d1b0246 100644 --- a/projects/app/src/components/Layout/index.tsx +++ b/projects/app/src/components/Layout/index.tsx @@ -14,7 +14,7 @@ import { useSystem } from '@fastgpt/web/hooks/useSystem'; import { useDebounceEffect, useMount } from 'ahooks'; import { useTranslation } from 'next-i18next'; import { useToast } from '@fastgpt/web/hooks/useToast'; -import WorkorderButton from '../support/workorder/WorkorderButton'; +import WorkorderButton from './WorkorderButton'; const Navbar = dynamic(() => import('./navbar')); const NavbarPhone = dynamic(() => import('./navbarPhone')); @@ -57,7 +57,8 @@ const Layout = ({ children }: { children: JSX.Element }) => { const { loading, feConfigs, notSufficientModalType, llmModelList, embeddingModelList } = useSystemStore(); const { isPc } = useSystem(); - const { userInfo, isUpdateNotification, setIsUpdateNotification } = useUserStore(); + const { userInfo, teamPlanStatus, isUpdateNotification, setIsUpdateNotification } = + useUserStore(); const { setUserDefaultLng } = useI18nLng(); const isChatPage = useMemo( @@ -122,7 +123,6 @@ const Layout = ({ children }: { children: JSX.Element }) => { - {feConfigs.show_workorder && } {children} @@ -161,6 +161,7 @@ const Layout = ({ children }: { children: JSX.Element }) => { {!!userInfo && importantInforms.length > 0 && ( )} + )} diff --git a/projects/app/src/pages/account/info/index.tsx b/projects/app/src/pages/account/info/index.tsx index be3a3bd1c..2af5156e3 100644 --- a/projects/app/src/pages/account/info/index.tsx +++ b/projects/app/src/pages/account/info/index.tsx @@ -42,6 +42,8 @@ import AccountContainer from '@/pageComponents/account/AccountContainer'; import { serviceSideProps } from '@fastgpt/web/common/system/nextjs'; import { useRouter } from 'next/router'; import TeamSelector from '@/pageComponents/account/TeamSelector'; +import { getWorkorderURL } from '@/web/common/workorder/api'; +import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; const StandDetailModal = dynamic( () => import('@/pageComponents/account/info/standardDetailModal'), @@ -580,9 +582,19 @@ const ButtonStyles = { }; const Other = ({ onOpenContact }: { onOpenContact: () => void }) => { const { feConfigs } = useSystemStore(); + const { teamPlanStatus } = useUserStore(); const { t } = useTranslation(); const { isPc } = useSystem(); + const { runAsync: onFeedback } = useRequest2(getWorkorderURL, { + manual: true, + onSuccess(data) { + if (data) { + window.open(data.redirectUrl); + } + } + }); + return ( @@ -619,6 +631,16 @@ const Other = ({ onOpenContact }: { onOpenContact: () => void }) => { )} + {feConfigs?.show_workorder && + teamPlanStatus && + teamPlanStatus.standard?.currentSubLevel !== StandardSubLevelEnum.free && ( + + + + {t('common:question_feedback')} + + + )} );