Browse Source

types目录结构调整

main
dark 7 months ago
parent
commit
359c5fc442
  1. 2
      src/Auth.tsx
  2. 2
      src/components/avatar/index.tsx
  3. 2
      src/components/department-tree/DepartmentCascader.tsx
  4. 4
      src/components/department-tree/DepartmentTree.tsx
  5. 2
      src/components/error/404.tsx
  6. 2
      src/components/role-picker/RolePicker.tsx
  7. 2
      src/components/user-picker/UserPicker.tsx
  8. 2
      src/components/user-picker/store.ts
  9. 2
      src/global.d.ts
  10. 2
      src/layout/RootLayout.tsx
  11. 2
      src/pages/login/index.tsx
  12. 4
      src/pages/system/departments/components/DepartmentTree.tsx
  13. 2
      src/pages/system/departments/components/TreeNodeRender.tsx
  14. 2
      src/pages/system/departments/index.tsx
  15. 2
      src/pages/system/logs/login/index.tsx
  16. 2
      src/pages/system/menus/components/BatchButton.tsx
  17. 2
      src/pages/system/menus/components/MenuTree.tsx
  18. 2
      src/pages/system/menus/components/TreeNodeRender.tsx
  19. 2
      src/pages/system/menus/index.tsx
  20. 6
      src/pages/system/roles/index.tsx
  21. 2
      src/pages/system/users/index.tsx
  22. 8
      src/pages/websites/ssl/components/AcmeList.tsx
  23. 8
      src/pages/websites/ssl/components/CAList.tsx
  24. 8
      src/pages/websites/ssl/components/DNSList.tsx
  25. 8
      src/pages/websites/ssl/index.tsx
  26. 2
      src/routes.tsx
  27. 24
      src/service/system.ts
  28. 13
      src/service/websites.ts
  29. 10
      src/store/system/department.ts
  30. 0
      src/store/system/logs.ts
  31. 7
      src/store/system/menu.ts
  32. 6
      src/store/system/role.ts
  33. 20
      src/store/system/user.ts
  34. 6
      src/store/websites/acme.ts
  35. 6
      src/store/websites/ca.ts
  36. 6
      src/store/websites/dns.ts
  37. 5
      src/store/websites/ssl.ts
  38. 14
      src/types/index.d.ts
  39. 5
      src/types/index.ts
  40. 30
      src/types/roles.d.ts
  41. 0
      src/types/system/department.d.ts
  42. 10
      src/types/system/login.d.ts
  43. 0
      src/types/system/logs.d.ts
  44. 36
      src/types/system/menus.d.ts
  45. 10
      src/types/system/roles.d.ts
  46. 0
      src/types/system/user.d.ts
  47. 2
      src/utils/index.ts
  48. 2
      src/utils/uuid.ts

2
src/Auth.tsx

@ -1,7 +1,7 @@
import React from 'react'
import { Props } from './global'
import { useAtomValue } from 'jotai'
import { authAtom } from './store/user.ts'
import { authAtom } from './store/system/user.ts'
export type AuthProps = Props & {

2
src/components/avatar/index.tsx

@ -1,6 +1,6 @@
import Icon from '@/components/icon'
import { useTranslation } from '@/i18n.ts'
import { currentUserAtom, logoutAtom } from '@/store/user.ts'
import { currentUserAtom, logoutAtom } from '@/store/system/user.ts'
import { Avatar as AntAvatar, Dropdown, Spin } from 'antd'
import { useAtomValue } from 'jotai'
import { useNavigate } from '@tanstack/react-router'

2
src/components/department-tree/DepartmentCascader.tsx

@ -1,6 +1,6 @@
import { Cascader, CascaderProps } from '@/components/cascader'
import { useAtomValue } from 'jotai/index'
import { departTreeAtom } from '@/store/department.ts'
import { departTreeAtom } from '@/store/system/department.ts'
import { usePageStoreOptions } from '@/store'
import { Spin } from 'antd'
import { useTranslation } from '@/i18n.ts'

4
src/components/department-tree/DepartmentTree.tsx

@ -2,12 +2,12 @@ import { usePageStoreOptions } from '@/store'
import { Empty, Spin, Tree, TreeDataNode, TreeProps } from 'antd'
import { useStyle } from './style.ts'
import { useTranslation } from '@/i18n.ts'
import { departTreeAtom, } from '@/store/department.ts'
import { departTreeAtom, } from '@/store/system/department.ts'
import { useAtomValue } from 'jotai'
import { useRef } from 'react'
import { flattenTree } from '@/utils'
import { useDeepCompareEffect } from 'react-use'
import { IDepartment } from '@/types/department'
import { IDepartment } from '@/types/system/department'
export interface DepartmentTreeProps extends TreeProps {
root?: TreeDataNode | boolean | string

2
src/components/error/404.tsx

@ -2,7 +2,7 @@ import { useTranslation } from '@/i18n.ts'
import { useNavigate } from '@tanstack/react-router'
import { Button, Result } from 'antd'
import { useAtomValue } from 'jotai'
import { userMenuDataAtom } from '@/store/user.ts'
import { userMenuDataAtom } from '@/store/system/user.ts'
const NotFound = () => {

2
src/components/role-picker/RolePicker.tsx

@ -1,7 +1,7 @@
import { convertToBool } from '@/utils'
import { Select, SelectProps } from 'antd'
import { useAtomValue } from 'jotai'
import { rolesAtom } from '@/store/role.ts'
import { rolesAtom } from '@/store/system/role.ts'
import { memo } from 'react'
import { useTranslation } from '@/i18n.ts'

2
src/components/user-picker/UserPicker.tsx

@ -7,7 +7,7 @@ import { useTranslation } from '@/i18n.ts'
import DepartmentTree from '@/components/department-tree/DepartmentTree.tsx'
import { DraggablePanel } from '@/components/draggable-panel'
import { useAtom, useAtomValue } from 'jotai'
import { userListAtom, userSearchAtom, } from '@/store/user.ts'
import { userListAtom, userSearchAtom, } from '@/store/system/user.ts'
import { IUser } from '@/types'
import EmptyWrap from '@/components/empty/EmptyWrap.tsx'

2
src/components/user-picker/store.ts

@ -1,4 +1,4 @@
import { IUser } from '@/types/user'
import { IUser } from '@/types/system/user'
import { atom } from 'jotai'
export const userSelectedAtom = atom<IUser[]>([])

2
src/global.d.ts

@ -1,4 +1,4 @@
import { IMenu } from '@/types/menus'
import { IMenu } from '@/types/system/menus'
import { QueryClient } from '@tanstack/react-query'
import { Router } from '@tanstack/react-router'
import { RouteOptions } from '@tanstack/react-router/src/route.ts'

2
src/layout/RootLayout.tsx

@ -3,7 +3,7 @@ import PageBreadcrumb from '@/components/breadcrumb'
import ErrorPage from '@/components/error/error.tsx'
import SelectLang from '@/components/select-lang'
import { appAtom } from '@/store/system.ts'
import { userMenuDataAtom } from '@/store/user.ts'
import { userMenuDataAtom } from '@/store/system/user.ts'
import { MenuItem } from '@/global'
import { ProConfigProvider, ProLayout, } from '@ant-design/pro-components'
import { zhCNIntl, enUSIntl } from '@ant-design/pro-provider/es/intl'

2
src/pages/login/index.tsx

@ -3,7 +3,7 @@ import { createFileRoute } from '@tanstack/react-router'
import { Button, Form, Input, Space } from 'antd'
import { useAtom, useAtomValue } from 'jotai'
import { useTranslation } from '@/i18n.ts'
import { loginAtom, loginFormAtom } from '@/store/user.ts'
import { loginAtom, loginFormAtom } from '@/store/system/user.ts'
import { memo, useLayoutEffect } from 'react'
import { useStyles } from './style.ts'

4
src/pages/system/departments/components/DepartmentTree.tsx

@ -3,14 +3,14 @@ import { Empty, Spin, Tree } from 'antd'
import { useStyle } from '../style.ts'
import { useTranslation } from '@/i18n.ts'
import { useSetAtom } from 'jotai'
import { selectedDepartAtom, departTreeAtom, batchIdsAtom } from '@/store/department.ts'
import { selectedDepartAtom, departTreeAtom, batchIdsAtom } from '@/store/system/department.ts'
import { FormInstance } from 'antd/lib'
import { useAtomValue } from 'jotai'
import { TreeNodeRender } from './TreeNodeRender.tsx'
import { useEffect, useRef } from 'react'
import { flattenTree } from '@/utils'
import { useDeepCompareEffect } from 'react-use'
import { IDepartment } from '@/types/department'
import { IDepartment } from '@/types/system/department'
export const DepartmentTree = ({ form }: { form: FormInstance }) => {

2
src/pages/system/departments/components/TreeNodeRender.tsx

@ -6,7 +6,7 @@ import { FormInstance } from 'antd/lib'
import { useTranslation } from '@/i18n.ts'
import { useStyle } from '../style.ts'
import { useAtomValue, useSetAtom } from 'jotai'
import { selectedDepartAtom, deleteDepartAtom, defaultDepart } from '@/store/department.ts'
import { selectedDepartAtom, deleteDepartAtom, defaultDepart } from '@/store/system/department.ts'
import { PlusOutlined } from '@ant-design/icons'
import ActionIcon, { DeleteAction } from '@/components/icon/action'

2
src/pages/system/departments/index.tsx

@ -4,7 +4,7 @@ import { useStyle } from './style.ts'
import DepartmentTree from './components/DepartmentTree.tsx'
import { Alert, Button, Divider, Form, Input, InputNumber, InputRef, notification, TreeSelect } from 'antd'
import { PlusOutlined } from '@ant-design/icons'
import { defaultDepart, selectedDepartAtom, departTreeAtom, saveOrUpdateDepartAtom } from '@/store/department.ts'
import { defaultDepart, selectedDepartAtom, departTreeAtom, saveOrUpdateDepartAtom } from '@/store/system/department.ts'
import { useAtom, useAtomValue, } from 'jotai'
import Glass from '@/components/glass'
import { useEffect, useRef } from 'react'

2
src/pages/system/logs/login/index.tsx

@ -11,7 +11,7 @@ import { useAtom, useAtomValue } from 'jotai'
import { useTranslation } from '@/i18n.ts'
import { Button, Space, Table, Popconfirm } from 'antd'
import { deleteLoginLogAtom, loginLogPageAtom, loginLogsAtom, loginLogSearchAtom } from '@/store/logs.ts'
import { deleteLoginLogAtom, loginLogPageAtom, loginLogsAtom, loginLogSearchAtom } from '@/store/system/logs.ts'
const LoginLog = memo(() => {

2
src/pages/system/menus/components/BatchButton.tsx

@ -1,7 +1,7 @@
import { Button, Popconfirm } from 'antd'
import { useAtomValue } from 'jotai'
import { batchIdsAtom, deleteMenuAtom } from '@/store/menu.ts'
import { batchIdsAtom, deleteMenuAtom } from '@/store/system/menu.ts'
import { useTranslation } from '@/i18n.ts'
const BatchButton = () => {

2
src/pages/system/menus/components/MenuTree.tsx

@ -4,7 +4,7 @@ import { MenuItem } from '@/global'
import { useStyle } from '../style.ts'
import { useTranslation } from '@/i18n.ts'
import { useSetAtom } from 'jotai'
import { batchIdsAtom, menuDataAtom, selectedMenuAtom } from '@/store/menu.ts'
import { batchIdsAtom, menuDataAtom, selectedMenuAtom } from '@/store/system/menu.ts'
import { FormInstance } from 'antd/lib'
import { useAtomValue } from 'jotai'
import { TreeNodeRender } from './TreeNodeRender.tsx'

2
src/pages/system/menus/components/TreeNodeRender.tsx

@ -6,7 +6,7 @@ import { FormInstance } from 'antd/lib'
import { useTranslation } from '@/i18n.ts'
import { useStyle } from '../style.ts'
import { useAtomValue, useSetAtom } from 'jotai'
import { defaultMenu, deleteMenuAtom, selectedMenuAtom } from '@/store/menu.ts'
import { defaultMenu, deleteMenuAtom, selectedMenuAtom } from '@/store/system/menu.ts'
import { PlusOutlined } from '@ant-design/icons'
import ActionIcon, { DeleteAction } from '@/components/icon/action'

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

@ -4,7 +4,7 @@ import { PlusOutlined } from '@ant-design/icons'
import { ProCard } from '@ant-design/pro-components'
import { Button, Form, Input, Radio, TreeSelect, InputNumber, notification, Alert, InputRef, Divider } from 'antd'
import { useAtom, useAtomValue } from 'jotai'
import { defaultMenu, menuDataAtom, saveOrUpdateMenuAtom, selectedMenuAtom } from '@/store/menu.ts'
import { defaultMenu, menuDataAtom, saveOrUpdateMenuAtom, selectedMenuAtom } from '@/store/system/menu.ts'
import IconPicker from '@/components/icon/picker'
import ButtonTable from './components/ButtonTable.tsx'
import { useStyle } from './style.ts'

6
src/pages/system/roles/index.tsx

@ -1,6 +1,6 @@
import Switch from '@/components/switch'
import { IMenu } from '@/types/menus'
import { IMenu } from '@/types/system/menus'
import {
ActionType,
PageContainer,
@ -19,11 +19,11 @@ import {
rolesAtom,
saveOrUpdateRoleAtom,
searchAtom
} from '@/store/role.ts'
} from '@/store/system/role.ts'
import { useTranslation } from '@/i18n.ts'
import { Button, Form, Space, Spin, Table, Tree, Popconfirm } from 'antd'
import { PlusOutlined } from '@ant-design/icons'
import { menuDataAtom } from '@/store/menu.ts'
import { menuDataAtom } from '@/store/system/menu.ts'
import { getTreeCheckedStatus } from '@/utils/tree.ts'
const MenuTree = (props: any) => {

2
src/pages/system/users/index.tsx

@ -19,7 +19,7 @@ import {
userPageAtom,
userSearchAtom,
userSelectedAtom
} from '@/store/user.ts'
} from '@/store/system/user.ts'
import { useMemo, useRef, useState } from 'react'
import Switch from '@/components/switch'
import { DepartmentCascader } from '@/components/department-tree'

8
src/pages/websites/ssl/components/AcmeList.tsx

@ -1,12 +1,12 @@
import { useMemo, useState } from 'react'
import { BetaSchemaForm, ProColumns, ProFormColumnsType, ProTable } from '@ant-design/pro-components'
import { IAcmeAccount } from '@/types/website/acme'
import { useTranslation } from '@/i18n.ts'
import { AcmeAccountTypes, acmeListAtom, acmePageAtom, AcmeType, saveOrUpdateAcmeAtom } from '@/store/websites/acme.ts'
import { useAtom, useAtomValue } from 'jotai'
import { Alert, Button, Form, Popconfirm } from 'antd'
import { KeyTypeEnum, KeyTypes } from '@/store/websites/ssl.ts'
import { deleteDNSAtom } from '@/store/websites/dns.ts'
import { WebSite } from '@/types'
const AcmeList = () => {
@ -18,7 +18,7 @@ const AcmeList = () => {
const { mutate: deleteDNS, isPending: isDeleting } = useAtomValue(deleteDNSAtom)
const [ open, setOpen ] = useState(false)
const columns = useMemo<ProColumns<IAcmeAccount>[]>(() => {
const columns = useMemo<ProColumns<WebSite.IAcmeAccount>[]>(() => {
return [
{
title: 'ID',
@ -95,7 +95,7 @@ const AcmeList = () => {
return (
<>
<Alert message={t('website.ssl.acme.tip', 'Acme账户用于申请免费证书')}/>
<ProTable<IAcmeAccount>
<ProTable<WebSite.IAcmeAccount>
cardProps={{
bodyStyle: {
padding: 0,
@ -139,7 +139,7 @@ const AcmeList = () => {
}}
/>
<BetaSchemaForm<IAcmeAccount>
<BetaSchemaForm<WebSite.IAcmeAccount>
shouldUpdate={false}
width={600}
form={form}

8
src/pages/websites/ssl/components/CAList.tsx

@ -1,12 +1,12 @@
import { useMemo, useState } from 'react'
import { BetaSchemaForm, ProColumns, ProFormColumnsType, ProTable } from '@ant-design/pro-components'
import { ICA, } from '@/types/website/ca'
import { useTranslation } from '@/i18n.ts'
import { deleteCaAtom } from '@/store/websites/ca.ts'
import { useAtom, useAtomValue } from 'jotai'
import { Button, Form, Popconfirm } from 'antd'
import { KeyTypeEnum, KeyTypes } from '@/store/websites/ssl.ts'
import { caListAtom, caPageAtom, saveOrUpdateCaAtom } from '@/store/websites/ca.ts'
import { WebSite } from '@/types'
const CAList = () => {
@ -18,7 +18,7 @@ const CAList = () => {
const { mutate: deleteCA, isPending: isDeleting } = useAtomValue(deleteCaAtom)
const [ open, setOpen ] = useState(false)
const columns = useMemo<ProColumns<ICA>[]>(() => {
const columns = useMemo<ProColumns<WebSite.ICA>[]>(() => {
return [
{
title: 'ID',
@ -145,7 +145,7 @@ const CAList = () => {
return (
<>
<ProTable<ICA>
<ProTable<WebSite.ICA>
cardProps={{
bodyStyle: {
padding: 0,
@ -189,7 +189,7 @@ const CAList = () => {
}}
/>
<BetaSchemaForm<ICA>
<BetaSchemaForm<WebSite.ICA>
shouldUpdate={false}
width={600}
form={form}

8
src/pages/websites/ssl/components/DNSList.tsx

@ -11,7 +11,7 @@ import {
DNSTypes,
saveOrUpdateDNSAtom
} from '@/store/websites/dns.ts'
import { IDnsAccount } from '@/types/website/dns'
import { WebSite } from '@/types'
const getKeyColumn = (type: string, t) => {
const columns: ProColumns<IDnsAccount>[] = []
@ -155,7 +155,7 @@ const DNSList = () => {
const { mutate: deleteDNS, isPending: isDeleting } = useAtomValue(deleteDNSAtom)
const [ open, setOpen ] = useState(false)
const columns = useMemo<ProColumns<IDnsAccount>[]>(() => {
const columns = useMemo<ProColumns<WebSite.IDnsAccount>[]>(() => {
return [
{
title: 'ID',
@ -221,7 +221,7 @@ const DNSList = () => {
return (
<>
<ProTable<IDnsAccount>
<ProTable<WebSite.IDnsAccount>
cardProps={{
bodyStyle: {
padding: 0,
@ -264,7 +264,7 @@ const DNSList = () => {
}}
/>
<BetaSchemaForm<IDnsAccount>
<BetaSchemaForm<WebSite.IDnsAccount>
shouldUpdate={false}
width={600}
form={form}

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

@ -15,13 +15,13 @@ import { memo, useMemo, useState } from 'react'
import { useTranslation } from '@/i18n.ts'
import { Button, Form, Popconfirm } from 'antd'
import { PlusOutlined } from '@ant-design/icons'
import { ISSL } from '@/types/website/ssl'
import DrawerPicker from '@/components/drawer-picker/DrawerPicker.tsx'
import AcmeList from './components/AcmeList.tsx'
import { acmeListAtom, AcmeType, getAcmeAccountTypeName } from '@/store/websites/acme.ts'
import { dnsListAtom, getDNSTypeName } from '@/store/websites/dns.ts'
import DNSList from './components/DNSList.tsx'
import CAList from '@/pages/websites/ssl/components/CAList.tsx'
import { WebSite } from '@/types'
const SSL = () => {
@ -38,7 +38,7 @@ const SSL = () => {
const [ open, setOpen ] = useState(false)
const columns = useMemo<ProColumns<ISSL>[]>(() => {
const columns = useMemo<ProColumns<WebSite.ISSL>[]>(() => {
return [
{
title: 'ID',
@ -216,7 +216,7 @@ const SSL = () => {
return (
<ListPageLayout>
<ProTable<ISSL>
<ProTable<WebSite.ISSL>
headerTitle={t('website.ssl.title', '证书列表')}
search={false}
loading={isLoading || isFetching}
@ -303,7 +303,7 @@ const SSL = () => {
>
</ProTable>
<BetaSchemaForm<ISSL>
<BetaSchemaForm<WebSite.ISSL>
shouldUpdate={false}
width={600}
form={form}

2
src/routes.tsx

@ -27,7 +27,7 @@ import RootLayout from './layout/RootLayout'
import { IRootContext, MenuItem } from './global'
import { DevTools } from 'jotai-devtools'
import { useAtomValue } from 'jotai'
import { userMenuDataAtom } from '@/store/user.ts'
import { userMenuDataAtom } from '@/store/system/user.ts'
const PageRootLayout = () => {
return <PageStoreProvider>

24
src/service/system.ts

@ -1,42 +1,38 @@
import { IPageResult } from '@/global'
import { IUser, IUserInfo } from '@/types/user'
import request from '../request.ts'
import { LoginRequest, LoginResponse } from '@/types/login'
import { createCURD } from '@/service/base.ts'
import { IMenu } from '@/types/menus'
import { IRole } from '@/types/roles'
import { IDepartment } from '@/types/department'
import { System } from '@/types'
const systemServ = {
dept: {
...createCURD<any, IDepartment>('/sys/dept'),
...createCURD<any, System.IDepartment>('/sys/dept'),
tree: () => {
return request.get<{ tree: IDepartment }>('/sys/dept/tree')
return request.get<{ tree: System.IDepartment }>('/sys/dept/tree')
}
},
menus: {
...createCURD<any, IMenu>('/sys/menu')
...createCURD<any, System.IMenu>('/sys/menu')
},
login: (data: LoginRequest) => {
return request.post<LoginResponse>('/sys/login', data)
login: (data: System.LoginRequest) => {
return request.post<System.LoginResponse>('/sys/login', data)
},
logout:()=>{
//
},
user: {
...createCURD<any, IUser>('/sys/user'),
...createCURD<any, System.IUser>('/sys/user'),
current: () => {
return request.get<IUserInfo>('/sys/user/info')
return request.get<System.IUserInfo>('/sys/user/info')
},
menus: () => {
return request.get<IPageResult<IMenu[]>>('/sys/user/menus')
return request.get<IPageResult<System.IMenu[]>>('/sys/user/menus')
},
resetPassword: (id: number) => {
return request.post<any>(`/sys/user/reset/password`, { id })
}
},
role: {
...createCURD<any, IRole>('/sys/role')
...createCURD<any, System.IRole>('/sys/role')
},
logs: {
login: {

13
src/service/websites.ts

@ -1,21 +1,18 @@
import { createCURD } from '@/service/base.ts'
import { ISSL } from '@/types/website/ssl'
import { IAcmeAccount } from '@/types/website/acme'
import { IDnsAccount } from '@/types/website/dns'
import { ICA } from '@/types/website/ca'
import { WebSite } from '@/types'
const websitesServ = {
ssl: {
...createCURD<any, ISSL>('/website/ssl')
...createCURD<any, WebSite.ISSL>('/website/ssl')
},
acme:{
...createCURD<any, IAcmeAccount>('/website/acme')
...createCURD<any, WebSite.IAcmeAccount>('/website/acme')
},
dns:{
...createCURD<any, IDnsAccount>('/website/dns')
...createCURD<any, WebSite.IDnsAccount>('/website/dns')
},
ca:{
...createCURD<any, ICA>('/website/ca')
...createCURD<any, WebSite.ICA>('/website/ca')
}
}

10
src/store/department.ts → src/store/system/department.ts

@ -1,10 +1,10 @@
import { atomWithMutation, atomWithQuery, queryClientAtom } from 'jotai-tanstack-query'
import systemServ from '@/service/system.ts'
import { IApiResult, IPage } from '@/global'
import { IDepartment } from '@/types/department'
import { atom, createStore } from 'jotai'
import { t } from 'i18next'
import { message } from 'antd'
import { System } from '@/types'
const store = createStore()
@ -18,11 +18,11 @@ export const defaultDepart = {
manager_user_id: 0,
phone: '',
sort: 0,
} as IDepartment
} as System.IDepartment
export const batchIdsAtom = atom<number[]>([])
export const selectedDepartAtom = atom<IDepartment>({} as IDepartment)
export const selectedDepartAtom = atom<System.IDepartment>({} as System.IDepartment)
export const departTreeAtom = atomWithQuery(() => {
@ -37,11 +37,11 @@ export const departTreeAtom = atomWithQuery(() => {
}
})
export const saveOrUpdateDepartAtom = atomWithMutation<IApiResult, IDepartment>((get) => {
export const saveOrUpdateDepartAtom = atomWithMutation<IApiResult, System.IDepartment>((get) => {
return {
mutationKey: [ 'saveOrUpdateDepart' ],
mutationFn: async (data: IDepartment) => {
mutationFn: async (data: System.IDepartment) => {
if (data.id) {
return await systemServ.dept.update(data)
}

0
src/store/logs.ts → src/store/system/logs.ts

7
src/store/menu.ts → src/store/system/menu.ts

@ -1,10 +1,11 @@
import systemServ from '@/service/system.ts'
import { IApiResult, IPage, MenuItem } from '@/global'
import { IMenu } from '@/types/menus'
import { atomWithMutation, atomWithQuery, queryClientAtom } from 'jotai-tanstack-query'
import { atom, createStore } from 'jotai'
import { message } from 'antd'
import { t } from '@/i18n.ts'
import { System } from '@/types'
export const defaultMenu = {
@ -49,11 +50,11 @@ export const byIdMenuAtom = atomWithQuery((get) => ({
}))
export const saveOrUpdateMenuAtom = atomWithMutation<IApiResult, IMenu>((get) => {
export const saveOrUpdateMenuAtom = atomWithMutation<IApiResult, System.IMenu>((get) => {
return {
mutationKey: [ 'updateMenu', get(selectedMenuIdAtom) ],
mutationFn: async (data: IMenu) => {
mutationFn: async (data: System.IMenu) => {
if (data.id === 0) {
return await systemServ.menus.add(data)
}

6
src/store/role.ts → src/store/system/role.ts

@ -1,11 +1,11 @@
import { convertToBool } from '@/utils'
import { atom } from 'jotai/index'
import { IRole } from '@/types/roles'
import { atomWithMutation, atomWithQuery, queryClientAtom } from 'jotai-tanstack-query'
import { IApiResult, IPage } from '@/global'
import systemServ from '@/service/system.ts'
import { message } from 'antd'
import { t } from '@/i18n.ts'
import { System } from '@/types'
type SearchParams = IPage & {
key?: string
@ -15,7 +15,7 @@ export const idAtom = atom(0)
export const roleIdsAtom = atom<number[]>([])
export const roleAtom = atom<IRole>(undefined as unknown as IRole)
export const roleAtom = atom<System.IRole>(undefined as unknown as System.IRole)
export const searchAtom = atom<SearchParams>({
key: ''
@ -47,7 +47,7 @@ export const rolesAtom = atomWithQuery((get) => {
//saveOrUpdateRoleAtom
export const saveOrUpdateRoleAtom = atomWithMutation<IApiResult, IRole>((get) => {
export const saveOrUpdateRoleAtom = atomWithMutation<IApiResult, System.IRole>((get) => {
return {
mutationKey: [ 'updateMenu' ],

20
src/store/user.ts → src/store/system/user.ts

@ -1,14 +1,12 @@
import { appAtom, setToken } from '@/store/system.ts'
import { IMenu } from '@/types/menus'
import { IUser, IUserInfo } from '@/types/user'
import { atom } from 'jotai/index'
import { IApiResult, IAuth, IPage, IPageResult, MenuItem } from '@/global'
import { LoginRequest } from '@/types/login'
import { atomWithMutation, atomWithQuery, queryClientAtom } from 'jotai-tanstack-query'
import systemServ from '@/service/system.ts'
import { formatMenuData, isDev } from '@/utils'
import { message } from 'antd'
import { t } from 'i18next'
import { System } from '@/types'
export const authAtom = atom<IAuth>({
isLogin: false,
@ -20,11 +18,11 @@ const devLogin = {
password: 'kk123456',
code: '123456'
}
export const loginFormAtom = atom<LoginRequest>({
export const loginFormAtom = atom<System.LoginRequest>({
...(isDev ? devLogin : {})
} as LoginRequest)
} as System.LoginRequest)
export const loginAtom = atomWithMutation<any, LoginRequest>((get) => ({
export const loginAtom = atomWithMutation<any, System.LoginRequest>((get) => ({
mutationKey: [ 'login' ],
mutationFn: async (params) => {
return await systemServ.login(params)
@ -46,7 +44,7 @@ export const logoutAtom = atomWithMutation(() => ({
},
}))
export const currentUserAtom = atomWithQuery<IApiResult<IUserInfo>, any, IUserInfo>((get) => {
export const currentUserAtom = atomWithQuery<IApiResult<System.IUserInfo>, any, System.IUserInfo>((get) => {
return {
queryKey: [ 'user_info', get(appAtom).token ],
queryFn: async () => {
@ -58,7 +56,7 @@ export const currentUserAtom = atomWithQuery<IApiResult<IUserInfo>, any, IUserIn
}
})
export const userMenuDataAtom = atomWithQuery<IApiResult<IPageResult<IMenu[]>>, any, MenuItem[]>((get) => ({
export const userMenuDataAtom = atomWithQuery<IApiResult<IPageResult<System.IMenu[]>>, any, MenuItem[]>((get) => ({
enabled: false,
queryKey: [ 'user_menus', get(appAtom).token ],
queryFn: async () => {
@ -102,16 +100,16 @@ export const userListAtom = atomWithQuery((get) => {
})
// user selected
export const userSelectedAtom = atom<IUser>({} as IUser)
export const userSelectedAtom = atom<System.IUser>({} as System.IUser)
export const defaultUserData = {
id: 0,
dept_id: 0,
role_id: 0,
} as IUser
} as System.IUser
//save or update user
export const saveOrUpdateUserAtom = atomWithMutation<IApiResult, IUser>((get) => ({
export const saveOrUpdateUserAtom = atomWithMutation<IApiResult, System.IUser>((get) => ({
mutationKey: [ 'save_user' ],
mutationFn: async (params) => {
params.status = params.status ? '1' : '0'

6
src/store/websites/acme.ts

@ -1,10 +1,10 @@
import { atomWithMutation, atomWithQuery } from 'jotai-tanstack-query'
import { IAcmeAccount } from '@/types/website/acme'
import websitesServ from '@/service/websites.ts'
import { message } from 'antd'
import { t } from 'i18next'
import { IApiResult, IPage } from '@/global'
import { atom } from 'jotai'
import { WebSite } from '@/types'
export enum AcmeType {
LetsEncrypt = 'letsencrypt',
@ -43,9 +43,9 @@ export const acmeListAtom = atomWithQuery(get => ({
}))
//saveOrUpdate
export const saveOrUpdateAcmeAtom = atomWithMutation<any, IAcmeAccount>(get => ({
export const saveOrUpdateAcmeAtom = atomWithMutation<any, WebSite.IAcmeAccount>(get => ({
mutationKey: [ 'saveOrUpdateAcme' ],
mutationFn: async (data: IAcmeAccount) => {
mutationFn: async (data: WebSite.IAcmeAccount) => {
if (data.id > 0) {
return await websitesServ.acme.update(data)
}

6
src/store/websites/ca.ts

@ -4,7 +4,7 @@ import { atomWithMutation, atomWithQuery } from 'jotai-tanstack-query'
import websitesServ from '@/service/websites.ts'
import { message, } from 'antd'
import { t } from 'i18next'
import { ICA } from '@/types/website/ca'
import { WebSite } from '@/types'
export const caPageAtom = atom<IPage>({
page: 1, pageSize: 10,
@ -22,9 +22,9 @@ export const caListAtom = atomWithQuery(get => ({
}))
//saveOrUpdate
export const saveOrUpdateCaAtom = atomWithMutation<any, ICA, IApiResult>(get => ({
export const saveOrUpdateCaAtom = atomWithMutation<any, WebSite.ICA, IApiResult>(get => ({
mutationKey: [ 'saveOrUpdateCA' ],
mutationFn: async (data: ICA) => {
mutationFn: async (data: WebSite.ICA) => {
if (data.id > 0) {
return await websitesServ.ca.update(data)
}

6
src/store/websites/dns.ts

@ -4,7 +4,7 @@ import { IApiResult, IPage } from '@/global'
import { atomWithMutation, atomWithQuery } from 'jotai-tanstack-query'
import websitesServ from '@/service/websites.ts'
import { message } from 'antd'
import { IDnsAccount } from '@/types/website/dns'
import { WebSite } from '@/types'
export const DNSTypeEnum = {
AliYun: 'AliYun',
@ -73,9 +73,9 @@ export const dnsListAtom = atomWithQuery(get => ({
}))
//saveOrUpdate
export const saveOrUpdateDNSAtom = atomWithMutation<any, IDnsAccount>(get => ({
export const saveOrUpdateDNSAtom = atomWithMutation<any, WebSite.IDnsAccount>(get => ({
mutationKey: [ 'saveOrUpdatedDNS' ],
mutationFn: async (data: IDnsAccount) => {
mutationFn: async (data: WebSite.IDnsAccount) => {
if (data.id > 0) {
return await websitesServ.dns.update(data)
}

5
src/store/websites/ssl.ts

@ -59,11 +59,6 @@ export const saveOrUpdateSslAtom = atomWithMutation<IApiResult, ISSL>(get => ({
return await websitesServ.ssl.update(data)
}
},
// onError: (error: any) => {
// const msg = error?.data?.message ||t('message.saveFailed', '保存失败')
// message.error(msg)
// return error
// },
onSuccess: (res) => {
const isAdd = !!res.data?.id
message.success(t(isAdd ? 'message.saveSuccess' : 'message.editSuccess', '保存成功'))

14
src/types/index.d.ts

@ -0,0 +1,14 @@
export namespace System {
export { IDepartment } from './system/department'
export { IUser, IUserInfo } from './system/user'
export { LoginRequest, LoginResponse } from './system/login'
export { IRole } from './system/roles'
export { IMenu } from './system/menus'
}
export namespace WebSite {
export { IAcmeAccount } from './website/acme'
export { ICA } from './website/ca'
export { IDnsAccount } from './website/dns'
export { ISSL, ProviderType, SSLSearchParam } from './website/ssl'
}

5
src/types/index.ts

@ -1,5 +0,0 @@
export * from './department'
export * from './user'
export * from './login'
export * from './roles'
export * from './menus'

30
src/types/roles.d.ts

@ -1,30 +0,0 @@
export interface IRole {
id: number,
sort: number,
code: string,
name: string,
description: string,
sequence: number,
status: string | boolean,
menu_ids: number[]
}
export interface RoleRequest extends IRole {
}
export interface RoleListResponse {
key: string,
order: string,
prop: string,
page: number,
pageSize: number
}
export interface RoleListResponse {
page: number,
pageSize: number,
total: number,
rows: IRole[]
}

0
src/types/department.d.ts → src/types/system/department.d.ts

10
src/types/login.d.ts → src/types/system/login.d.ts

@ -1,12 +1,4 @@
export interface LoginLogRequest {
key: string,
start: string,
end: string,
order: string,
prop: string,
page: number,
pageSize: number
}
export interface LoginRequest {
'mfa_status': boolean;

0
src/types/logs.d.ts → src/types/system/logs.d.ts

36
src/types/menus.d.ts → src/types/system/menus.d.ts

@ -1,4 +1,3 @@
import { ReactNode } from 'react'
export interface MenuButton {
code: string,
@ -6,7 +5,7 @@ export interface MenuButton {
}
interface Meta {
export interface Meta {
}
export interface IMenu {
@ -18,7 +17,7 @@ export interface IMenu {
name: string,
title: string,
component: string,
icon: string | ReactNode,
icon: string | any,
description: string,
sequence: number,
type: string,
@ -33,34 +32,3 @@ export interface IMenu {
children: IMenu[]
}
export interface MenuRequest extends IMenu {
}
export interface MenuResponse {
id: number,
}
export interface MenuDropRequest {
source: number,
target: number,
action: string
}
export interface MenuListRequest {
order: string,
prop: string,
page: number,
pageSize: number
}
export interface MenuListResponse {
page: number,
pageSize: number,
total: number,
rows: IMenu[]
}

10
src/types/system/roles.d.ts

@ -0,0 +1,10 @@
export interface IRole {
id: number,
sort: number,
code: string,
name: string,
description: string,
sequence: number,
status: string | boolean,
menu_ids: number[]
}

0
src/types/user.d.ts → src/types/system/user.d.ts

2
src/utils/index.ts

@ -1,4 +1,4 @@
import { IMenu } from '@/types/menus'
import { IMenu } from '@/types/system/menus'
import { FiledNames, FlattenData, MenuItem, TreeItem } from '@/global'
import { getIcon } from '@/components/icon'
import { TreeDataNode } from 'antd'

2
src/utils/uuid.ts

@ -1,5 +1,3 @@
import { MenuItem } from '@/global'
import { TreeDataNode } from 'antd'
export function generateUUID() {
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {

Loading…
Cancel
Save