Browse Source

管理员只能给其他账号添加普通权限

master
nili 6 months ago
parent
commit
e5a3eafff8
  1. 2
      dist/index.html
  2. 1
      dist/p__AdminManagement.3d8845fe.async.js
  3. 1
      dist/p__AdminManagement.c8a5c155.async.js
  4. 34
      dist/umi.574c0b88.js
  5. 3
      src/access.ts
  6. 2
      src/app.tsx
  7. 5
      src/pages/AdminManagement.tsx

2
dist/index.html

@ -8,6 +8,6 @@
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script src="/umi.f88ab783.js"></script> <script src="/umi.574c0b88.js"></script>
</body></html> </body></html>

1
dist/p__AdminManagement.3d8845fe.async.js

File diff suppressed because one or more lines are too long

1
dist/p__AdminManagement.c8a5c155.async.js

File diff suppressed because one or more lines are too long

34
dist/umi.f88ab783.js → dist/umi.574c0b88.js

File diff suppressed because one or more lines are too long

3
src/access.ts

@ -3,12 +3,9 @@
* */ * */
export default function access(initialState: { currentUser?: API.MatrixAdmin } | undefined) { export default function access(initialState: { currentUser?: API.MatrixAdmin } | undefined) {
const { currentUser } = initialState ?? {}; const { currentUser } = initialState ?? {};
console.log("access");
console.log(currentUser);
let data = { let data = {
canAdmin: currentUser && currentUser.role && currentUser.role < 3 canAdmin: currentUser && currentUser.role && currentUser.role < 3
}; };
console.log(data);
return data; return data;
} }

2
src/app.tsx

@ -131,7 +131,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
links: isDev links: isDev
? [ ? [
<Link key="openapi" to="/umi/plugin/openapi" target="_blank"> <Link key="openapi" to="/umi/plugin/openapi" target="_blank">
<LinkOutlined /> <LinkOutlined onPointerEnterCapture={undefined} onPointerLeaveCapture={undefined} />
<span>OpenAPI </span> <span>OpenAPI </span>
</Link>, </Link>,
] ]

5
src/pages/AdminManagement.tsx

@ -1,3 +1,4 @@
import { useModel } from '@umijs/max';
import { Button, Form, Input, Modal, Select, Table, Tag } from 'antd'; import { Button, Form, Input, Modal, Select, Table, Tag } from 'antd';
import { ColumnsType } from 'antd/es/table'; import { ColumnsType } from 'antd/es/table';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
@ -9,6 +10,8 @@ const AdminManagement = () => {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const [form] = Form.useForm(); const [form] = Form.useForm();
const [appArr, setAppArr] = useState<API.MatrixApp[]>([]); const [appArr, setAppArr] = useState<API.MatrixApp[]>([]);
const { initialState } = useModel('@@initialState');
const currentUser = initialState?.currentUser;
const getAppNameById = (appId:number) => { const getAppNameById = (appId:number) => {
const app = appArr.find(app => app.id === appId); const app = appArr.find(app => app.id === appId);
@ -144,7 +147,7 @@ const AdminManagement = () => {
</Form.Item> </Form.Item>
<Form.Item label="角色" name="role"> <Form.Item label="角色" name="role">
<Select> <Select>
<Select.Option value={2}></Select.Option> <Select.Option disabled={currentUser?.role && currentUser.role > 1} value={2}></Select.Option>
<Select.Option value={3}></Select.Option> <Select.Option value={3}></Select.Option>
</Select> </Select>
</Form.Item> </Form.Item>

Loading…
Cancel
Save