From fb6dbaf2d614d4e1de0f2a3e7a817d16935e741f Mon Sep 17 00:00:00 2001 From: Finley Ge <32237950+FinleyGe@users.noreply.github.com> Date: Mon, 24 Feb 2025 19:59:06 +0800 Subject: [PATCH] feat/workorder (#3860) * feat: workorder * pref: workorder button * chore: move workorder to common * chore: format code * pref: style --- .../global/common/system/types/index.d.ts | 1 + .../web/components/common/Icon/constants.ts | 4 +- .../components/common/Icon/icons/close.svg | 3 + .../Icon/icons/core/chat/chevronLeft.svg | 3 + .../components/common/Icon/icons/feedback.svg | 29 +++++ packages/web/i18n/zh-CN/common.json | 3 +- projects/app/src/components/Layout/auth.tsx | 1 + projects/app/src/components/Layout/index.tsx | 2 + .../support/workorder/WorkorderButton.tsx | 112 ++++++++++++++++++ .../pageComponents/account/team/context.tsx | 2 +- projects/app/src/web/common/workorder/api.ts | 5 + 11 files changed, 162 insertions(+), 3 deletions(-) create mode 100644 packages/web/components/common/Icon/icons/close.svg create mode 100644 packages/web/components/common/Icon/icons/core/chat/chevronLeft.svg create mode 100644 packages/web/components/common/Icon/icons/feedback.svg create mode 100644 projects/app/src/components/support/workorder/WorkorderButton.tsx create mode 100644 projects/app/src/web/common/workorder/api.ts diff --git a/packages/global/common/system/types/index.d.ts b/packages/global/common/system/types/index.d.ts index 5f376e8a9..892beb480 100644 --- a/packages/global/common/system/types/index.d.ts +++ b/packages/global/common/system/types/index.d.ts @@ -41,6 +41,7 @@ export type FastGPTConfigFileType = { }; export type FastGPTFeConfigsType = { + show_workorder?: boolean; show_emptyChat?: boolean; register_method?: ['email' | 'phone' | 'sync']; login_method?: ['email' | 'phone']; // Attention: login method is diffrent with oauth diff --git a/packages/web/components/common/Icon/constants.ts b/packages/web/components/common/Icon/constants.ts index bdb91dc63..b40c72eb1 100644 --- a/packages/web/components/common/Icon/constants.ts +++ b/packages/web/components/common/Icon/constants.ts @@ -1,11 +1,11 @@ // @ts-nocheck - export const iconPaths = { book: () => import('./icons/book.svg'), change: () => import('./icons/change.svg'), chatSend: () => import('./icons/chatSend.svg'), check: () => import('./icons/check.svg'), checkCircle: () => import('./icons/checkCircle.svg'), + close: () => import('./icons/close.svg'), closeSolid: () => import('./icons/closeSolid.svg'), code: () => import('./icons/code.svg'), collectionLight: () => import('./icons/collectionLight.svg'), @@ -161,6 +161,7 @@ export const iconPaths = { 'core/chat/chatLight': () => import('./icons/core/chat/chatLight.svg'), 'core/chat/chatModelTag': () => import('./icons/core/chat/chatModelTag.svg'), 'core/chat/chevronDown': () => import('./icons/core/chat/chevronDown.svg'), + 'core/chat/chevronLeft': () => import('./icons/core/chat/chevronLeft.svg'), 'core/chat/chevronRight': () => import('./icons/core/chat/chevronRight.svg'), 'core/chat/chevronSelector': () => import('./icons/core/chat/chevronSelector.svg'), 'core/chat/chevronUp': () => import('./icons/core/chat/chevronUp.svg'), @@ -329,6 +330,7 @@ export const iconPaths = { edit: () => import('./icons/edit.svg'), empty: () => import('./icons/empty.svg'), export: () => import('./icons/export.svg'), + feedback: () => import('./icons/feedback.svg'), 'file/csv': () => import('./icons/file/csv.svg'), 'file/fill/csv': () => import('./icons/file/fill/csv.svg'), 'file/fill/doc': () => import('./icons/file/fill/doc.svg'), diff --git a/packages/web/components/common/Icon/icons/close.svg b/packages/web/components/common/Icon/icons/close.svg new file mode 100644 index 000000000..8beb0440a --- /dev/null +++ b/packages/web/components/common/Icon/icons/close.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/web/components/common/Icon/icons/core/chat/chevronLeft.svg b/packages/web/components/common/Icon/icons/core/chat/chevronLeft.svg new file mode 100644 index 000000000..4b12b753b --- /dev/null +++ b/packages/web/components/common/Icon/icons/core/chat/chevronLeft.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/web/components/common/Icon/icons/feedback.svg b/packages/web/components/common/Icon/icons/feedback.svg new file mode 100644 index 000000000..551b78a55 --- /dev/null +++ b/packages/web/components/common/Icon/icons/feedback.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/web/i18n/zh-CN/common.json b/packages/web/i18n/zh-CN/common.json index 67b458279..d0ed58c0b 100644 --- a/packages/web/i18n/zh-CN/common.json +++ b/packages/web/i18n/zh-CN/common.json @@ -1283,5 +1283,6 @@ "xx_search_result": "{{key}} 的搜索结果", "yes": "是", "yesterday": "昨天", - "yesterday_detail_time": "昨天 {{time}}" + "yesterday_detail_time": "昨天 {{time}}", + "question_feedback": "问题反馈" } diff --git a/projects/app/src/components/Layout/auth.tsx b/projects/app/src/components/Layout/auth.tsx index 0c2c0c42b..85baf1fe0 100644 --- a/projects/app/src/components/Layout/auth.tsx +++ b/projects/app/src/components/Layout/auth.tsx @@ -3,6 +3,7 @@ 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 883e77d75..e880b2a68 100644 --- a/projects/app/src/components/Layout/index.tsx +++ b/projects/app/src/components/Layout/index.tsx @@ -14,6 +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'; const Navbar = dynamic(() => import('./navbar')); const NavbarPhone = dynamic(() => import('./navbarPhone')); @@ -121,6 +122,7 @@ const Layout = ({ children }: { children: JSX.Element }) => { + {feConfigs.show_workorder && } {children} diff --git a/projects/app/src/components/support/workorder/WorkorderButton.tsx b/projects/app/src/components/support/workorder/WorkorderButton.tsx new file mode 100644 index 000000000..8518657b4 --- /dev/null +++ b/projects/app/src/components/support/workorder/WorkorderButton.tsx @@ -0,0 +1,112 @@ +import { getWorkorderURL } from '@/web/common/workorder/api'; +import { Box, Flex } from '@chakra-ui/react'; +import Icon from '@fastgpt/web/components/common/Icon'; +import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; +import { useToggle } from 'ahooks'; +import { useTranslation } from 'next-i18next'; + +function WorkorderButton() { + const [open, setOpen] = useToggle(true); + const { t } = useTranslation(); + + const { data, runAsync } = useRequest2(getWorkorderURL, { + manual: true + }); + + const onFeedback = async () => { + await runAsync(); + if (data) { + window.open(data.redirectUrl); + } + }; + return ( + <> + {open ? ( + + setOpen.set(false)} + > + + + + + + {t('common:question_feedback')} + + + + ) : ( + setOpen.set(true)} + > + + + )} + + ); +} + +export default WorkorderButton; diff --git a/projects/app/src/pageComponents/account/team/context.tsx b/projects/app/src/pageComponents/account/team/context.tsx index d21545947..99ab3e2c3 100644 --- a/projects/app/src/pageComponents/account/team/context.tsx +++ b/projects/app/src/pageComponents/account/team/context.tsx @@ -92,7 +92,7 @@ export const TeamModalContextProvider = ({ children }: { children: ReactNode }) total: memberTotal, ScrollData: MemberScrollData } = useScrollPagination(getTeamMembers, { - pageSize: 20, + pageSize: 1000, params: { withLeaved: true } diff --git a/projects/app/src/web/common/workorder/api.ts b/projects/app/src/web/common/workorder/api.ts new file mode 100644 index 000000000..b99c660ce --- /dev/null +++ b/projects/app/src/web/common/workorder/api.ts @@ -0,0 +1,5 @@ +import { GET } from '@/web/common/api/request'; +export const getWorkorderURL = () => + GET<{ + redirectUrl: string; + }>('/proApi/common/workorder/create');