Browse Source

应用管理

master
nili 6 months ago
parent
commit
570f262a93
  1. 6
      config/routes.ts
  2. 1
      dist/397.0ef2ea1f.async.js
  3. 2
      dist/index.html
  4. 1
      dist/p__AppManagement.edc3d5dd.async.js
  5. 1
      dist/p__Bind.49c22a98.async.js
  6. 1
      dist/p__Bind.b6ee068f.async.js
  7. 433
      dist/umi.8fc52f76.js
  8. 433
      dist/umi.ce1a56e3.js
  9. 6
      src/app.tsx
  10. 130
      src/pages/AppManagement.tsx
  11. 12
      src/services/matrix/admin.ts
  12. 2
      src/services/matrix/typings.d.ts

6
config/routes.ts

@ -55,6 +55,12 @@ export default [
access: 'canDeviceOwner', access: 'canDeviceOwner',
component: './Bind' component: './Bind'
}, },
{
path: '/appList',
name: '应用管理',
access: 'canAdmin',
component: './AppManagement'
},
{ {
path: '/', path: '/',
redirect: '/welcome', redirect: '/welcome',

1
dist/397.0ef2ea1f.async.js

File diff suppressed because one or more lines are too long

2
dist/index.html

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

1
dist/p__AppManagement.edc3d5dd.async.js

@ -0,0 +1 @@
"use strict";(self.webpackChunkant_design_pro=self.webpackChunkant_design_pro||[]).push([[39],{84702:function(Q,v,e){e.r(v);var j=e(15009),d=e.n(j),P=e(99289),p=e.n(P),A=e(5574),m=e.n(A),x=e(90930),I=e(85601),U=e(35312),s=e(8232),C=e(55241),T=e(10397),B=e(14726),R=e(17788),i=e(96365),E=e(67294),h=e(48357),n=e(85893),W=function(){var b=(0,E.useState)(!1),f=m()(b,2),K=f[0],u=f[1],L=s.Z.useForm(),y=m()(L,1),o=y[0],Z=(0,E.useState)([]),M=m()(Z,2),F=M[0],S=M[1],g=(0,U.useModel)("@@initialState"),c=g.initialState,l=c==null?void 0:c.currentUser,$=l&&l.role&&l.role<2,G=function(r){o.setFieldsValue(r),u(!0)},O=[{title:"\u5E94\u7528\u540D",dataIndex:"name"},{title:"code",dataIndex:"code"},{title:"\u4E0B\u8F7D\u5730\u5740",dataIndex:"url",renderText:function(r){return(0,n.jsx)(C.Z,{overlayInnerStyle:{padding:0},content:(0,n.jsx)(T.Z,{value:r||"",bordered:!1}),children:(0,n.jsx)("a",{children:r})})}}],N=[].concat(O,[{title:"secret",dataIndex:"secret",ellipsis:!0,copyable:!0},{title:"\u64CD\u4F5C",width:80,renderText:function(r){return(0,n.jsx)("a",{onClick:function(){return G(r)},children:"\u7F16\u8F91"},"edit")}}]),V=function(){o.submit()},z=function(){u(!1)},D=function(){var _=p()(d()().mark(function r(){var t;return d()().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,(0,h.ln)();case 2:t=a.sent,t.data&&S(t.data);case 4:case"end":return a.stop()}},r)}));return function(){return _.apply(this,arguments)}}();(0,E.useEffect)(function(){D()},[]);var J=function(){o.resetFields(),u(!0)},X=function(){var _=p()(d()().mark(function r(t){return d()().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,(0,h.XJ)(t);case 3:a.next=8;break;case 5:return a.prev=5,a.t0=a.catch(0),a.abrupt("return");case 8:u(!1),D();case 10:case"end":return a.stop()}},r,null,[[0,5]])}));return function(t){return _.apply(this,arguments)}}();return(0,n.jsxs)(x._z,{children:[l&&l.role&&l.role<2&&(0,n.jsx)(B.ZP,{style:{marginBottom:"20px"},onClick:J,children:"\u65B0\u5EFA\u5E94\u7528"}),(0,n.jsx)(I.Z,{search:!1,columns:$?N:O,dataSource:F}),(0,n.jsx)(R.Z,{title:"\u7F16\u8F91",visible:K,onOk:V,onCancel:z,children:(0,n.jsxs)(s.Z,{form:o,onFinish:X,children:[(0,n.jsx)(s.Z.Item,{name:"id",style:{display:"none"},children:(0,n.jsx)(i.Z,{type:"hidden"})}),(0,n.jsx)(s.Z.Item,{name:"code",style:{display:"none"},children:(0,n.jsx)(i.Z,{type:"hidden"})}),(0,n.jsx)(s.Z.Item,{label:"\u5E94\u7528\u540D",name:"name",children:(0,n.jsx)(i.Z,{})}),(0,n.jsx)(s.Z.Item,{label:"\u4E0B\u8F7D\u5730\u5740",name:"url",children:(0,n.jsx)(i.Z,{})})]})})]})};v.default=W}}]);

1
dist/p__Bind.49c22a98.async.js

File diff suppressed because one or more lines are too long

1
dist/p__Bind.b6ee068f.async.js

@ -0,0 +1 @@
"use strict";(self.webpackChunkant_design_pro=self.webpackChunkant_design_pro||[]).push([[557],{82947:function(l,a){var n={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"}}]},name:"reload",theme:"outlined"};a.Z=n},59605:function(l,a,n){n.r(a);var i=n(90930),s=n(35312),d=n(4393),_=n(10397),t=n(85893),o=function(){var r=(0,s.useModel)("@@initialState"),e=r.initialState,u=e==null?void 0:e.currentUser;return(0,t.jsx)(i._z,{children:(0,t.jsxs)(d.Z,{children:[(0,t.jsx)(_.Z,{style:{margin:"auto"},value:(u==null?void 0:u.name)||""}),(0,t.jsx)("p",{style:{textAlign:"center",marginTop:"20px"},children:"\u8BF7\u4F7F\u7528\u6E38\u620Fapp\u626B\u7801\u7ED1\u5B9A\u8BBE\u5907"})]})})};a.default=o}}]);

433
dist/umi.8fc52f76.js

File diff suppressed because one or more lines are too long

433
dist/umi.ce1a56e3.js

File diff suppressed because one or more lines are too long

6
src/app.tsx

@ -88,6 +88,12 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
access: 'canDeviceOwner', access: 'canDeviceOwner',
}); });
menuData.push({
path: '/appList',
name: '应用列表',
access: 'canAdmin',
});
return menuData; return menuData;
}, },
}, },

130
src/pages/AppManagement.tsx

@ -0,0 +1,130 @@
import { PageContainer, ProColumns, ProTable } from '@ant-design/pro-components';
import { useModel } from '@umijs/max';
import { Button, Form, Input, Modal, Popover, QRCode } from 'antd';
import { useEffect, useState } from 'react';
import { appList, saveApp } from '../services/matrix/admin';
const AppManagement = () => {
const [visible, setVisible] = useState(false);
const [form] = Form.useForm();
const [appArr, setAppArr] = useState<API.MatrixApp[]>([]);
const { initialState } = useModel('@@initialState');
const currentUser = initialState?.currentUser;
const canUpdate = currentUser && currentUser.role && currentUser.role < 2;
const handleEdit = (record: API.MatrixApp) => {
form.setFieldsValue(record);
setVisible(true);
};
const columns: ProColumns<API.MatrixApp>[] = [
{
title: '应用名',
dataIndex: 'name',
},
{
title: 'code',
dataIndex: 'code',
},
{
title: '下载地址',
dataIndex: 'url',
renderText: (url: string) => (
<Popover
overlayInnerStyle={{ padding: 0 }}
content={<QRCode value={url || ''} bordered={false} />}
>
<a>{url}</a>
</Popover>
),
},
];
const columnsWithOperation: ProColumns<API.MatrixApp>[] = [
...columns,
{
title: 'secret',
dataIndex: 'secret',
ellipsis: true,
copyable: true,
},
{
title: '操作',
width: 80,
renderText: (record: API.MatrixApp) => (
<a key="edit" onClick={() => handleEdit(record)}>
</a>
),
},
];
const handleOk = () => {
form.submit();
};
const handleCancel = () => {
setVisible(false);
};
const fetchApp = async () => {
const res = await appList();
if (res.data) {
setAppArr(res.data);
}
};
useEffect(() => {
fetchApp();
}, []);
const handleNew = () => {
form.resetFields(); // 重置表单字段
setVisible(true);
};
const handleSaveApp = async (values: API.MatrixApp) => {
try {
await saveApp(values);
} catch (e) {
return;
}
setVisible(false);
fetchApp();
};
return (
<PageContainer>
{currentUser && currentUser.role && currentUser.role < 2 && (
<Button style={{ marginBottom: '20px' }} onClick={handleNew}>
</Button>
)}
<ProTable
search={false}
columns={canUpdate ? columnsWithOperation : columns}
dataSource={appArr}
/>
<Modal title="编辑" visible={visible} onOk={handleOk} onCancel={handleCancel}>
<Form form={form} onFinish={handleSaveApp}>
<Form.Item name="id" style={{ display: 'none' }}>
<Input type="hidden" />
</Form.Item>
<Form.Item name="code" style={{ display: 'none' }}>
<Input type="hidden" />
</Form.Item>
<Form.Item label="应用名" name="name">
<Input />
</Form.Item>
<Form.Item label="下载地址" name="url">
<Input />
</Form.Item>
</Form>
</Modal>
</PageContainer>
);
};
export default AppManagement;

12
src/services/matrix/admin.ts

@ -106,3 +106,15 @@ export async function saveAdmin(body: API.MatrixAdminBo, options?: { [key: strin
...(options || {}), ...(options || {}),
}); });
} }
/** 此处后端没有提供注释 POST /api/admin/saveApp */
export async function saveApp(body: API.MatrixApp, options?: { [key: string]: any }) {
return request<API.RVoid>('/api/admin/saveApp', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}

2
src/services/matrix/typings.d.ts

@ -17,7 +17,6 @@ declare namespace API {
deviceId?: string; deviceId?: string;
code?: string; code?: string;
createdAt?: string[]; createdAt?: string[];
adminId?: number;
}; };
type AppInfo = { type AppInfo = {
@ -163,7 +162,6 @@ declare namespace API {
code?: string; code?: string;
url?: string; url?: string;
income?: number; income?: number;
channel?: string;
secret?: string; secret?: string;
}; };

Loading…
Cancel
Save