Browse Source

1、菜单增加隐藏功能

2、调整WebSite模块目录
main
dark 5 months ago
parent
commit
e361e75cc0
  1. 6
      src/layout/RootLayout.tsx
  2. 29
      src/pages/system/menus/index.tsx
  3. 8
      src/pages/system/menus/style.ts
  4. 2
      src/pages/websites/account/index.tsx
  5. 2
      src/pages/websites/account/style.ts
  6. 0
      src/pages/websites/acme/AcmeList.tsx
  7. 0
      src/pages/websites/ca/CAList.tsx
  8. 0
      src/pages/websites/ca/Detail.tsx
  9. 0
      src/pages/websites/ca/SelfSign.tsx
  10. 0
      src/pages/websites/ca/store.ts
  11. 0
      src/pages/websites/ca/style.ts
  12. 0
      src/pages/websites/dns/DNSList.tsx
  13. 0
      src/pages/websites/domain/index.tsx
  14. 0
      src/pages/websites/domain/style.ts
  15. 0
      src/pages/websites/record/index.tsx
  16. 0
      src/pages/websites/record/style.ts
  17. 12
      src/pages/websites/ssl/index.tsx
  18. 2
      src/service/websites.ts
  19. 51
      src/types/system/menus.d.ts

6
src/layout/RootLayout.tsx

@ -26,7 +26,7 @@ const getBreadcrumbData = (menuData: MenuItem[], pathname: string) => {
const findItem = (menuData: any[], pathname: string) => { const findItem = (menuData: any[], pathname: string) => {
for (let i = 0; i < menuData.length; i++) { for (let i = 0; i < menuData.length; i++) {
if (menuData[i].path === pathname) { if (menuData[i].path === pathname) {
menuData[i].label =<span className={'s-title'}>{ menuData[i].name}</span>
menuData[i].label = <span className={'s-title'}>{menuData[i].name}</span>
breadcrumbData.push(menuData[i]) breadcrumbData.push(menuData[i])
return true return true
} }
@ -56,7 +56,7 @@ export default () => {
const menusFlatten = useRef<MenuItem[]>() const menusFlatten = useRef<MenuItem[]>()
if (!menusFlatten.current) { if (!menusFlatten.current) {
menusFlatten.current = flattenTree<MenuItem>(menuData, { key: 'id', title: 'name' })
menusFlatten.current = flattenTree<MenuItem>(menuData, { key: 'id', title: 'name' }).filter(item => !item.hidden)
} }
const [ rootMenuKeys, setRootMenuKeys ] = useState<string[]>(() => { const [ rootMenuKeys, setRootMenuKeys ] = useState<string[]>(() => {
const item = menusFlatten.current?.find(item => item.path === location.pathname) const item = menusFlatten.current?.find(item => item.path === location.pathname)
@ -127,7 +127,7 @@ export default () => {
collapsedButtonRender={false} collapsedButtonRender={false}
// collapsed={false} // collapsed={false}
postMenuData={() => { postMenuData={() => {
return menuData.map(item => ({
return menuData.filter(item=>!item.hidden).map(item => ({
...item, ...item,
children: [], children: [],
})) as any })) as any

29
src/pages/system/menus/index.tsx

@ -2,7 +2,19 @@ import Glass from '@/components/glass'
import { useTranslation } from '@/i18n.ts' import { useTranslation } from '@/i18n.ts'
import { PlusOutlined } from '@ant-design/icons' import { PlusOutlined } from '@ant-design/icons'
import { ProCard } from '@ant-design/pro-components' import { ProCard } from '@ant-design/pro-components'
import { Button, Form, Input, Radio, TreeSelect, InputNumber, notification, Alert, InputRef, Divider } from 'antd'
import {
Button,
Form,
Input,
Radio,
TreeSelect,
InputNumber,
notification,
Alert,
InputRef,
Divider,
Checkbox
} from 'antd'
import { useAtom, useAtomValue } from 'jotai' import { useAtom, useAtomValue } from 'jotai'
import { defaultMenu, menuDataAtom, saveOrUpdateMenuAtom, selectedMenuAtom } from '@/store/system/menu.ts' import { defaultMenu, menuDataAtom, saveOrUpdateMenuAtom, selectedMenuAtom } from '@/store/system/menu.ts'
import IconPicker from '@/components/icon/picker' import IconPicker from '@/components/icon/picker'
@ -45,7 +57,9 @@ const Menus = () => {
<TwoColPageLayout <TwoColPageLayout
className={styles.container} className={styles.container}
leftPanel={<> leftPanel={<>
<ProCard title={t('system.menus.title', '菜单')}
<ProCard
className={styles.card}
title={t('system.menus.title', '菜单')}
extra={ extra={
<> <>
<BatchButton/> <BatchButton/>
@ -172,12 +186,23 @@ const Menus = () => {
> >
<Input addonBefore={'pages/'}/> <Input addonBefore={'pages/'}/>
</Form.Item> </Form.Item>
<Form.Item label={t('system.menus.form.hidden', '隐藏')}
help={t('system.menus.form.hiddenHelp', '菜单不显示在导航中,但用户依然可以访问,例如详情页')}
>
<Form.Item valuePropName={'checked'} noStyle={true} name={'hidden'}>
<Checkbox></Checkbox>
</Form.Item>
<Form.Item valuePropName={'checked'} noStyle={true} name={'hidden_breadcrumb'}>
<Checkbox></Checkbox>
</Form.Item>
</Form.Item>
<Form.Item label={' '}> <Form.Item label={' '}>
<Button type="primary" <Button type="primary"
htmlType={'submit'} htmlType={'submit'}
loading={isPending} loading={isPending}
onClick={() => { onClick={() => {
form.validateFields().then((values) => { form.validateFields().then((values) => {
console.log(values)
mutate(values) mutate(values)
}) })
}} }}

8
src/pages/system/menus/style.ts

@ -85,10 +85,16 @@ export const useStyle = createStyles(({ token, css, cx, prefixCls }) => {
z-index: 10; z-index: 10;
background: ${token.colorBgContainer}; background: ${token.colorBgContainer};
` `
const card = css`
.ant-pro-card-body{
height: calc(100% - 115px)!important;
min-height: calc(100% - 115px)!important;
}
`
return { return {
container: cx(prefix, container), container: cx(prefix, container),
box, box,
card,
emptyForm, emptyForm,
tree, tree,
form, form,

2
src/pages/websites/ssl/account/index.tsx → src/pages/websites/account/index.tsx

@ -1,4 +1,4 @@
import { useTranslation } from '@/i18n.ts'
import { useTranslation } from '../../../i18n.ts'
import { Button, Form, Popconfirm, Divider, Space, Tooltip, Badge } from 'antd' import { Button, Form, Popconfirm, Divider, Space, Tooltip, Badge } from 'antd'
import { useAtom, useAtomValue } from 'jotai' import { useAtom, useAtomValue } from 'jotai'
import { import {

2
src/pages/websites/ssl/account/style.ts → src/pages/websites/account/style.ts

@ -1,4 +1,4 @@
import { createStyles } from '@/theme'
import { createStyles } from '../../../theme'
export const useStyle = createStyles(({ token, css, cx, prefixCls }, props: any) => { export const useStyle = createStyles(({ token, css, cx, prefixCls }, props: any) => {
const prefix = `${prefixCls}-${token?.proPrefix}-websiteDnsAccount-list-page` const prefix = `${prefixCls}-${token?.proPrefix}-websiteDnsAccount-list-page`

0
src/pages/websites/ssl/acme/AcmeList.tsx → src/pages/websites/acme/AcmeList.tsx

0
src/pages/websites/ssl/ca/CAList.tsx → src/pages/websites/ca/CAList.tsx

0
src/pages/websites/ssl/ca/Detail.tsx → src/pages/websites/ca/Detail.tsx

0
src/pages/websites/ssl/ca/SelfSign.tsx → src/pages/websites/ca/SelfSign.tsx

0
src/pages/websites/ssl/ca/store.ts → src/pages/websites/ca/store.ts

0
src/pages/websites/ssl/ca/style.ts → src/pages/websites/ca/style.ts

0
src/pages/websites/ssl/dns/DNSList.tsx → src/pages/websites/dns/DNSList.tsx

0
src/pages/websites/ssl/domain/index.tsx → src/pages/websites/domain/index.tsx

0
src/pages/websites/ssl/domain/style.ts → src/pages/websites/domain/style.ts

0
src/pages/websites/ssl/record/index.tsx → src/pages/websites/record/index.tsx

0
src/pages/websites/ssl/record/style.ts → src/pages/websites/record/style.ts

12
src/pages/websites/ssl/index.tsx

@ -16,19 +16,19 @@ import { useTranslation } from '@/i18n.ts'
import { Button, Form, Popconfirm, Space } from 'antd' import { Button, Form, Popconfirm, Space } from 'antd'
import { PlusOutlined } from '@ant-design/icons' import { PlusOutlined } from '@ant-design/icons'
import DrawerPicker, { DrawerPickerRef } from '@/components/drawer-picker/DrawerPicker.tsx' import DrawerPicker, { DrawerPickerRef } from '@/components/drawer-picker/DrawerPicker.tsx'
import AcmeList from './acme/AcmeList.tsx'
import AcmeList from '../acme/AcmeList.tsx'
import { acmeListAtom, AcmeType, getAcmeAccountTypeName } from '@/store/websites/acme.ts' import { acmeListAtom, AcmeType, getAcmeAccountTypeName } from '@/store/websites/acme.ts'
import { dnsListAtom, getDNSTypeName } from '@/store/websites/dns.ts' import { dnsListAtom, getDNSTypeName } from '@/store/websites/dns.ts'
import DNSList from './dns/DNSList.tsx'
import CAList from './ca/CAList.tsx'
import DNSList from '../dns/DNSList.tsx'
import CAList from '../ca/CAList.tsx'
import { WebSite } from '@/types' import { WebSite } from '@/types'
import Switch from '@/components/switch' import Switch from '@/components/switch'
import { Else, If, Then } from 'react-if' import { Else, If, Then } from 'react-if'
import Action from '@/components/action/Action.tsx' import Action from '@/components/action/Action.tsx'
import { Status } from '@/components/status' import { Status } from '@/components/status'
import SSLDetail from './components/Detail.tsx'
import { detailAtom } from './components/store.ts'
import Upload from './components/Upload.tsx'
import SSLDetail from '@/pages/websites/ssl/components/Detail.tsx'
import { detailAtom } from '@/pages/websites/ssl/components/store.ts'
import Upload from '@/pages/websites/ssl/components/Upload.tsx'
import { FormInstance } from 'antd/lib' import { FormInstance } from 'antd/lib'
import Download from '@/components/download/Download.tsx' import Download from '@/components/download/Download.tsx'
import { Table as ProTable } from '@/components/table' import { Table as ProTable } from '@/components/table'

2
src/service/websites.ts

@ -19,7 +19,7 @@ const websitesServ = {
...createCURD<any, WebSite.IAcmeAccount>('/website/acme') ...createCURD<any, WebSite.IAcmeAccount>('/website/acme')
}, },
dns: { dns: {
...createCURD<any, WebSite.IDnsAccount>('/website/account'),
...createCURD<any, WebSite.IDnsAccount>('/website/dns_account'),
sync: async (params: WebSite.IDnsAccount) => { sync: async (params: WebSite.IDnsAccount) => {
return request.post<any, WebSite.IDnsAccount>('/website/dns_account/sync', params) return request.post<any, WebSite.IDnsAccount>('/website/dns_account/sync', params)
} }

51
src/types/system/menus.d.ts

@ -1,7 +1,6 @@
export interface MenuButton { export interface MenuButton {
code: string,
label: string
code: string,
label: string
} }
@ -11,27 +10,29 @@ export interface Meta {
} }
export interface IMenu { export interface IMenu {
id: number,
key: string,
parent_id: number,
sort: number,
code: string,
name: string,
parentName: string[],
title: string,
component: string,
icon: string | any,
description: string,
sequence: number,
type: string,
path: string,
properties: string,
status: string,
parent_path: string,
affix: boolean,
redirect: string,
button: MenuButton[],
meta: Meta,
id: number,
key: string,
parent_id: number,
sort: number,
code: string,
name: string,
parentName: string[],
title: string,
component: string,
icon: string | any,
description: string,
sequence: number,
type: string,
path: string,
properties: string,
status: string,
parent_path: string,
affix: boolean,
hidden: boolean,
hidden_breadcrumb: boolean,
redirect: string,
button: MenuButton[],
meta: Meta,
children: IMenu[]
children: IMenu[]
} }
Loading…
Cancel
Save