This commit is contained in:
archer 2025-05-30 17:27:21 +08:00
parent d7b9f94270
commit 165b783a95
No known key found for this signature in database
GPG Key ID: 4446499B846D4A9E
2 changed files with 79 additions and 62 deletions

View File

@ -105,7 +105,6 @@ function PermissionSelect({
const per = new Permission({ per: perValue }); const per = new Permission({ per: perValue });
per.addPer(...selectedMultipleValues); per.addPer(...selectedMultipleValues);
onChange(per.value); onChange(per.value);
setIsOpen(false);
}; };
useOutsideClick({ useOutsideClick({
@ -187,15 +186,14 @@ function PermissionSelect({
); );
})} })}
{permissionSelectList.multipleCheckBoxList.length > 0 && (
<>
<MyDivider my={2} /> <MyDivider my={2} />
{/* {permissionSelectList.multipleCheckBoxList.length > 0 && (
<Box m="4"></Box>
)} */}
{permissionSelectList.multipleCheckBoxList.map((item) => { {permissionSelectList.multipleCheckBoxList.map((item) => {
const isChecked = selectedMultipleValues.includes(item.value); const isChecked = selectedMultipleValues.includes(item.value);
const isDisabled = new Permission({ per: selectedSingleValue }).checkPer(item.value); const isDisabled = new Permission({ per: selectedSingleValue }).checkPer(
item.value
);
const change = () => { const change = () => {
if (isDisabled) return; if (isDisabled) return;
const per = new Permission({ per: value }); const per = new Permission({ per: value });
@ -211,23 +209,18 @@ function PermissionSelect({
key={item.value} key={item.value}
{...(isChecked {...(isChecked
? { ? {
color: 'primary.500', color: 'primary.600'
bg: 'myWhite.300'
} }
: {})} : {})}
whiteSpace="pre-wrap" {...MenuStyle}
flexDirection="row" maxW={['70vw', '260px']}
justifyContent="start"
p="2"
_hover={{
bg: 'myGray.50'
}}
{...(isDisabled {...(isDisabled
? { ? {
cursor: 'not-allowed', cursor: 'not-allowed'
opacity: 0.5
} }
: {})} : {
cursor: 'pointer'
})}
> >
<Checkbox <Checkbox
size="lg" size="lg"
@ -235,13 +228,18 @@ function PermissionSelect({
onChange={change} onChange={change}
isDisabled={isDisabled} isDisabled={isDisabled}
/> />
<Flex px="4" flexDirection="column" onClick={change}> <Box ml={4} onClick={change}>
<Box fontWeight="500">{t(item.name as any)}</Box> <Box>{t(item.name as any)}</Box>
<Box fontWeight="400">{t(item.description as any)}</Box> <Box color={'myGray.500'} fontSize={'mini'}>
</Flex> {t(item.description as any)}
</Box>
</Box>
</Flex> </Flex>
); );
})} })}
</>
)}
{onDelete && ( {onDelete && (
<> <>
<MyDivider my={2} h={'2px'} borderColor={'myGray.200'} /> <MyDivider my={2} h={'2px'} borderColor={'myGray.200'} />

View File

@ -1,5 +1,5 @@
import { Box, HStack } from '@chakra-ui/react'; 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 { AppContext, TabEnum } from './context';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { useTranslation } from 'next-i18next'; import { useTranslation } from 'next-i18next';
@ -25,11 +25,17 @@ const RouteTab = () => {
const tabList = useMemo( const tabList = useMemo(
() => [ () => [
...(appDetail.permission.hasWritePer
? [
{ {
label: label:
appDetail.type === AppTypeEnum.plugin ? t('app:setting_plugin') : t('app:setting_app'), appDetail.type === AppTypeEnum.plugin
? t('app:setting_plugin')
: t('app:setting_app'),
id: TabEnum.appEdit id: TabEnum.appEdit
}, }
]
: []),
...(appDetail.permission.hasManagePer ...(appDetail.permission.hasManagePer
? [ ? [
{ {
@ -40,9 +46,22 @@ const RouteTab = () => {
: []), : []),
...(appDetail.permission.hasLogPer ? [{ label: t('app:chat_logs'), id: TabEnum.logs }] : []) ...(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 ( return (
<HStack spacing={4} whiteSpace={'nowrap'}> <HStack spacing={4} whiteSpace={'nowrap'}>
{tabList.map((tab) => ( {tabList.map((tab) => (