perf: work order tip (#3874)

This commit is contained in:
Archer
2025-02-24 20:26:15 +08:00
committed by GitHub
parent fb6dbaf2d6
commit 4f0dd96699
9 changed files with 82 additions and 28 deletions

View File

@@ -27,7 +27,6 @@ export type UserType = {
timezone: string;
promotionRate: UserModelSchema['promotionRate'];
team: TeamTmbItemType;
standardInfo?: standardInfoType;
notificationAccount?: string;
permission: TeamPermission;
contact?: string;

View File

@@ -1,4 +1,4 @@
<svg width="29" height="28" viewBox="0 0 29 28" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg viewBox="0 0 29 28" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8.49993 10.1261C8.49993 9.48174 9.02226 8.9594 9.6666 8.9594H14.3333C14.9776 8.9594 15.4999 9.48174 15.4999 10.1261C15.4999 10.7704 14.9776 11.2927 14.3333 11.2927H9.6666C9.02226 11.2927 8.49993 10.7704 8.49993 10.1261Z" fill="url(#paint0_linear_17422_2138)"/>
<path d="M8.49993 14.7927C8.49993 14.1484 9.02226 13.6261 9.6666 13.6261H18.4041C19.0485 13.6261 19.5708 14.1484 19.5708 14.7927C19.5708 15.4371 19.0485 15.9594 18.4041 15.9594H9.6666C9.02226 15.9594 8.49993 15.4371 8.49993 14.7927Z" fill="url(#paint1_linear_17422_2138)"/>
<path d="M17.6859 9.1641C17.3948 9.37757 17.2057 9.72212 17.2057 10.1108V11.2504C17.2057 11.2738 17.2247 11.2927 17.248 11.2927H18.3745C18.7286 11.2927 19.0462 11.1358 19.262 10.8878L25.8249 4.32494C26.2805 3.86933 26.2805 3.13063 25.8249 2.67502C25.3693 2.21941 24.6306 2.21941 24.175 2.67502L17.6859 9.1641Z" fill="url(#paint2_linear_17422_2138)"/>

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -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",

View File

@@ -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}}"
}

View File

@@ -1011,6 +1011,7 @@
"plugin.go to laf": "前往編寫",
"plugin.path": "路徑",
"prompt_input_placeholder": "請輸入提示詞",
"question_feedback": "工單諮詢",
"read_quote": "查看引用",
"required": "必填",
"resume_failed": "恢復失敗",

View File

@@ -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 ? (
<Flex
position="fixed"
bottom="20%"
bottom="10%"
right="0"
height="62px"
width="58px"
height="56px"
width="56px"
zIndex={100}
boxShadow="0px 12px 32px -4px #00175633"
alignItems="center"
@@ -39,16 +70,16 @@ function WorkorderButton() {
borderColor={'#DFE6F2'}
>
<Box
zIndex={101}
width="14px"
height="14px"
zIndex={10}
width="1rem"
height="1rem"
position="absolute"
left="-6px"
top="-6px"
borderRadius="full"
background="white"
border="1px"
borderColor={'myGray.25'}
borderColor={'myGray.100'}
bgColor="myGray.25"
_hover={{
cursor: 'pointer',
@@ -73,8 +104,8 @@ function WorkorderButton() {
borderBottomLeftRadius="8px"
onClick={onFeedback}
>
<Icon name="feedback" width="28px" height="28px" />
<Box fontSize="11px" fontWeight="500">
<Icon name="feedback" width="24px" height="24px" />
<Box fontSize="xs" fontWeight="500">
{t('common:question_feedback')}
</Box>
</Flex>
@@ -82,7 +113,7 @@ function WorkorderButton() {
) : (
<Flex
position="fixed"
bottom="20%"
bottom="10%"
right="0"
height="44px"
width="19px"
@@ -106,7 +137,7 @@ function WorkorderButton() {
</Flex>
)}
</>
);
) : null;
}
export default WorkorderButton;

View File

@@ -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,

View File

@@ -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 }) => {
<Auth>
<Box h={'100%'} position={'fixed'} left={0} top={0} w={navbarWidth}>
<Navbar unread={unread} />
{feConfigs.show_workorder && <WorkorderButton />}
</Box>
<Box h={'100%'} ml={navbarWidth} overflow={'overlay'}>
{children}
@@ -161,6 +161,7 @@ const Layout = ({ children }: { children: JSX.Element }) => {
{!!userInfo && importantInforms.length > 0 && (
<ImportantInform informs={importantInforms} refetch={refetchUnRead} />
)}
<WorkorderButton />
</>
)}

View File

@@ -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 (
<Box>
<Grid gridGap={4} mt={3}>
@@ -619,6 +631,16 @@ const Other = ({ onOpenContact }: { onOpenContact: () => void }) => {
</Box>
</Flex>
)}
{feConfigs?.show_workorder &&
teamPlanStatus &&
teamPlanStatus.standard?.currentSubLevel !== StandardSubLevelEnum.free && (
<Flex onClick={onFeedback} {...ButtonStyles}>
<MyIcon name={'feedback'} w={'18px'} color={'myGray.600'} />
<Box ml={2} flex={1}>
{t('common:question_feedback')}
</Box>
</Flex>
)}
</Grid>
</Box>
);