Skip to content

Commit

Permalink
Merge pull request #22 from biaov/hotfix/20231023/permission
Browse files Browse the repository at this point in the history
修复控制台权限详情不能访问的问题
  • Loading branch information
biaov authored Oct 23, 2023
2 parents c8c2778 + a69f57c commit b1c31e0
Show file tree
Hide file tree
Showing 32 changed files with 466 additions and 454 deletions.
6 changes: 3 additions & 3 deletions admin/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"editor.formatOnSave": true
}
{
"editor.formatOnSave": true
}
6 changes: 3 additions & 3 deletions admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

## 安装依赖

```Basic
```sh
npm i
```

## 运行项目

```Basic
```sh
npm start
```

## 打包项目

```Basic
```sh
npm run build
```

Expand Down
20 changes: 10 additions & 10 deletions admin/public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 17 additions & 17 deletions admin/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React from 'react'
import { ConfigProvider } from 'antd'
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'
import zhCN from 'antd/locale/zh_CN'
import 'antd/dist/reset.css'
import RouterView from '@/router'

dayjs.locale('zh-cn')

const App: React.FC = () => (
<ConfigProvider locale={zhCN}>
<RouterView />
</ConfigProvider>
)

export default App
import React from 'react'
import { ConfigProvider } from 'antd'
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'
import zhCN from 'antd/locale/zh_CN'
import 'antd/dist/reset.css'
import RouterView from '@/router'

dayjs.locale('zh-cn')

const App: React.FC = () => (
<ConfigProvider locale={zhCN}>
<RouterView />
</ConfigProvider>
)

export default App
36 changes: 18 additions & 18 deletions admin/src/api/factory.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { service } from '@/utils/request'
import { defaultPageSize } from '@/config'
import { PagingResponse } from './types'

export const restful = (path: string) => ({
paging: <T>(query = {}): Promise<PagingResponse<T>> => service.get(path, { params: { current: 1, pageSize: defaultPageSize, ...query } }),
all: <T>(query = {}) => service.get(path, { params: { ...query, all: true } }) as Promise<T>,
get: <T>(id: number): Promise<T> => service.get(`${path}/${id}`),
create: (data = {}) => service.post(path, data),
delete: (id: number) => service.delete(`${path}/${id}`),
update: (id: number, data = {}) => service.patch(`${path}/${id}`, data),
replace: (id: number, data = {}) => service.put(`${path}/${id}`, data)
})

export const command = (path: string) => ({
get: <T>(query = {}) => service.get(path, { params: query }) as Promise<T>,
post: <T>(data = {}, config = {}) => service.post(path, data, config) as Promise<T>
})
import { service } from '@/utils/request'
import { defaultPageSize } from '@/config'
import { PagingResponse } from './types'

export const restful = (path: string) => ({
paging: <T>(query = {}): Promise<PagingResponse<T>> => service.get(path, { params: { current: 1, pageSize: defaultPageSize, ...query } }),
all: <T>(query = {}) => service.get(path, { params: { ...query, all: true } }) as Promise<T>,
get: <T>(id: number): Promise<T> => service.get(`${path}/${id}`),
create: (data = {}) => service.post(path, data),
delete: (id: number) => service.delete(`${path}/${id}`),
update: (id: number, data = {}) => service.patch(`${path}/${id}`, data),
replace: (id: number, data = {}) => service.put(`${path}/${id}`, data)
})

export const command = (path: string) => ({
get: <T>(query = {}) => service.get(path, { params: query }) as Promise<T>,
post: <T>(data = {}, config = {}) => service.post(path, data, config) as Promise<T>
})
20 changes: 10 additions & 10 deletions admin/src/api/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
interface Meta {
total: number
current: number
pageSize: number
}

export interface PagingResponse<T = Record<string, any>> {
meta: Meta
items: T[]
}
interface Meta {
total: number
current: number
pageSize: number
}

export interface PagingResponse<T = Record<string, any>> {
meta: Meta
items: T[]
}
10 changes: 5 additions & 5 deletions admin/src/components/page-loading/index.module.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.m-loading {
width: 400px;
margin: 0 auto;
padding: 100px;
text-align: center;
.m-loading {
width: 400px;
margin: 0 auto;
padding: 100px;
text-align: center;
}
26 changes: 13 additions & 13 deletions admin/src/components/page-loading/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Spin } from 'antd'
import Styles from './index.module.less'

/**
* 页面加载组件
*/
export default function PageLoadingComponent() {
return (
<div className={Styles['m-loading']}>
<Spin tip="加载中..." spinning={true} />
</div>
)
}
import { Spin } from 'antd'
import Styles from './index.module.less'

/**
* 页面加载组件
*/
export default function PageLoadingComponent() {
return (
<div className={Styles['m-loading']}>
<Spin tip="加载中..." spinning={true} />
</div>
)
}
84 changes: 42 additions & 42 deletions admin/src/components/rich-text/index.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
import { useEffect, useState } from 'react'
import ReactQuill from 'react-quill'
import 'react-quill/dist/quill.snow.css'
import type { Props } from './types'

export default function richTextComponent(props: Partial<Props> = {}) {
const { value = '', onChange } = props
const [richTextValue, setRichTextValue] = useState('')

useEffect(() => {
setRichTextValue(value)
}, [])

const modules = {
toolbar: [
['bold', 'italic', 'underline', 'strike'],
['blockquote', 'code-block'],

[{ header: 1 }, { header: 2 }],
[{ list: 'ordered' }, { list: 'bullet' }],
[{ script: 'sub' }, { script: 'super' }],
[{ indent: '-1' }, { indent: '+1' }],
[{ direction: 'rtl' }],

[{ size: ['small', false, 'large', 'huge'] }],
[{ header: [1, 2, 3, 4, 5, 6, false] }],

[{ color: [] }, { background: [] }],
[{ font: [] }],
[{ align: [] }],

['clean']
]
}

const onChangeRichText = (val: string) => {
setRichTextValue(val)
onChange && onChange(val)
}

return <ReactQuill placeholder="请输入内容" theme="snow" {...{ richTextValue, modules }} style={{ height: '300px', marginBottom: '43px' }} onChange={onChangeRichText} />
}
import { useEffect, useState } from 'react'
import ReactQuill from 'react-quill'
import 'react-quill/dist/quill.snow.css'
import type { Props } from './types'

export default function richTextComponent(props: Partial<Props> = {}) {
const { value = '', onChange } = props
const [richTextValue, setRichTextValue] = useState('')

useEffect(() => {
setRichTextValue(value)
}, [])

const modules = {
toolbar: [
['bold', 'italic', 'underline', 'strike'],
['blockquote', 'code-block'],

[{ header: 1 }, { header: 2 }],
[{ list: 'ordered' }, { list: 'bullet' }],
[{ script: 'sub' }, { script: 'super' }],
[{ indent: '-1' }, { indent: '+1' }],
[{ direction: 'rtl' }],

[{ size: ['small', false, 'large', 'huge'] }],
[{ header: [1, 2, 3, 4, 5, 6, false] }],

[{ color: [] }, { background: [] }],
[{ font: [] }],
[{ align: [] }],

['clean']
]
}

const onChangeRichText = (val: string) => {
setRichTextValue(val)
onChange && onChange(val)
}

return <ReactQuill placeholder="请输入内容" theme="snow" {...{ richTextValue, modules }} style={{ height: '300px', marginBottom: '43px' }} onChange={onChangeRichText} />
}
9 changes: 7 additions & 2 deletions admin/src/config/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,12 @@ export const items = () => [
{
label: '角色权限详情',
key: '/setting/role-permission',
permissions: [],
permissions: [
{
label: '查看角色权限详情',
value: '/setting/role-permission/detail'
}
],
hidden: true
},
{
Expand Down Expand Up @@ -245,5 +250,5 @@ export const itemOptions = items().map(item => ({
export const allPermission = items().map(item => ({
...item,
value: item.key,
children: item.children.filter(chld => !chld.hidden).map(child => ({ ...child, value: child.key, children: child.permissions }))
children: item.children.map(child => ({ ...child, value: child.key, children: child.permissions }))
}))
22 changes: 11 additions & 11 deletions admin/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import ReactDOM from 'react-dom/client'
import { Provider } from 'react-redux'
import App from './App'
import store from './store'
import './styles/index.less'

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<Provider store={store}>
<App />
</Provider>
)
import ReactDOM from 'react-dom/client'
import { Provider } from 'react-redux'
import App from './App'
import store from './store'
import './styles/index.less'

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<Provider store={store}>
<App />
</Provider>
)
2 changes: 1 addition & 1 deletion admin/src/router/guard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const CheckPermission = ({ component, ...rest }: Record<string, unknown>)
const { pathname } = useLocation()

if (permissions) {
const hasPermission = permissions.includes('*') || permissions.includes(`${pathname}/list`) || pathname === '/'
const hasPermission = permissions.includes('*') || permissions.includes(`${pathname}/list`) || permissions.includes(pathname.replace(/\d+/g, 'detail')) || pathname === '/'
if (!hasPermission) return <Navigate to="/403" replace />
}

Expand Down
Loading

0 comments on commit b1c31e0

Please sign in to comment.