This commit is contained in:
archer
2025-05-30 17:27:21 +08:00
parent d7b9f94270
commit 165b783a95
2 changed files with 79 additions and 62 deletions

View File

@@ -1,5 +1,5 @@
import { Box, HStack } from '@chakra-ui/react';
import React, { useCallback, useMemo } from 'react';
import React, { useCallback, useEffect, useMemo } from 'react';
import { AppContext, TabEnum } from './context';
import { useRouter } from 'next/router';
import { useTranslation } from 'next-i18next';
@@ -25,11 +25,17 @@ const RouteTab = () => {
const tabList = useMemo(
() => [
{
label:
appDetail.type === AppTypeEnum.plugin ? t('app:setting_plugin') : t('app:setting_app'),
id: TabEnum.appEdit
},
...(appDetail.permission.hasWritePer
? [
{
label:
appDetail.type === AppTypeEnum.plugin
? t('app:setting_plugin')
: t('app:setting_app'),
id: TabEnum.appEdit
}
]
: []),
...(appDetail.permission.hasManagePer
? [
{
@@ -40,9 +46,22 @@ const RouteTab = () => {
: []),
...(appDetail.permission.hasLogPer ? [{ label: t('app:chat_logs'), id: TabEnum.logs }] : [])
],
[appDetail.permission.hasManagePer, appDetail.type]
[
appDetail.permission.hasLogPer,
appDetail.permission.hasManagePer,
appDetail.permission.hasWritePer,
appDetail.type,
t
]
);
useEffect(() => {
// 没找到合适的 id则自动跳转
if (!tabList.find((item) => item.id === currentTab)) {
setCurrentTab(tabList[0].id);
}
}, [tabList, currentTab, setCurrentTab]);
return (
<HStack spacing={4} whiteSpace={'nowrap'}>
{tabList.map((tab) => (