Browse Source

加应用隐藏功能

master
nili 8 months ago
parent
commit
ade250f78a
  1. 2
      dist/index.html
  2. 1
      dist/p__AppManagement.91220ba0.async.js
  3. 1
      dist/p__AppManagement.edc3d5dd.async.js
  4. 1
      dist/p__SuperAdmin.168ca415.async.js
  5. 1
      dist/p__SuperAdmin.5409346e.async.js
  6. 100
      dist/umi.e7092c68.js
  7. 31
      src/app.tsx
  8. 49
      src/pages/AppManagement.tsx
  9. 2
      src/pages/Overview.tsx
  10. 16
      src/pages/SuperAdmin.tsx
  11. 49
      src/requestErrorConfig.ts
  12. 3
      src/services/matrix/typings.d.ts

2
dist/index.html

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

1
dist/p__AppManagement.91220ba0.async.js

File diff suppressed because one or more lines are too long

1
dist/p__AppManagement.edc3d5dd.async.js

@ -1 +0,0 @@
"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__SuperAdmin.168ca415.async.js

File diff suppressed because one or more lines are too long

1
dist/p__SuperAdmin.5409346e.async.js

File diff suppressed because one or more lines are too long

100
dist/umi.5508b12d.js → dist/umi.e7092c68.js

File diff suppressed because one or more lines are too long

31
src/app.tsx

@ -60,20 +60,25 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
request: async () => {
const apps = await appList();
const menuData: MenuDataItem[] = [];
const role = initialState?.currentUser?.role || 100;
apps.data?.forEach((x: any) => {
menuData.push({
path: '/advList/' + x.code,
name: x.name,
access: 'canAdmin',
component: './AdvRecordList',
});
menuData.push({
path: '/app/' + x.code,
name: x.name,
access: 'canDeviceOwner',
component: './DeviceOwnerApp',
});
if (x.hide === 1 && role <= 2) {
} else {
menuData.push({
path: '/advList/' + x.code,
name: x.name,
access: 'canAdmin',
component: './AdvRecordList',
});
}
if (role === 4) {
menuData.push({
path: '/app/' + x.code,
name: x.name,
access: 'canDeviceOwner',
component: './DeviceOwnerApp',
});
}
});
menuData.push({

49
src/pages/AppManagement.tsx

@ -1,12 +1,13 @@
import { PageContainer, ProColumns, ProTable } from '@ant-design/pro-components';
import { useModel } from '@umijs/max';
import { Button, Form, Input, Modal, Popover, QRCode } from 'antd';
import { Button, Form, Input, Modal, Popover, QRCode, Select, Tag } from 'antd';
import { useEffect, useState } from 'react';
import { appList, saveApp } from '@/services/matrix/admin';
const AppManagement = () => {
const [visible, setVisible] = useState(false);
const [editing, setEditing] = useState(false);
const [form] = Form.useForm();
const [appArr, setAppArr] = useState<API.MatrixApp[]>([]);
const { initialState } = useModel('@@initialState');
@ -16,6 +17,7 @@ const AppManagement = () => {
const handleEdit = (record: API.MatrixApp) => {
form.setFieldsValue(record);
setVisible(true);
setEditing(true);
};
const columns: ProColumns<API.MatrixApp>[] = [
@ -49,6 +51,30 @@ const AppManagement = () => {
ellipsis: true,
copyable: true,
},
{
title: '菜单栏中',
dataIndex: 'hide',
renderText: (r: number) => {
if (r === 0) {
return <Tag color="blue"></Tag>;
} else {
return <Tag color="purple"></Tag>;
}
},
},
{
title: '渠道',
dataIndex: 'channel',
renderText: (r: string) => {
switch (r) {
case 'fanmiyou':
return '凡米游';
case 'qiji':
return '奇迹';
}
return r;
},
},
{
title: '操作',
width: 80,
@ -82,6 +108,7 @@ const AppManagement = () => {
const handleNew = () => {
form.resetFields(); // 重置表单字段
setVisible(true);
setEditing(false);
};
const handleSaveApp = async (values: API.MatrixApp) => {
@ -121,6 +148,26 @@ const AppManagement = () => {
<Form.Item label="下载地址" name="url">
<Input />
</Form.Item>
<Form.Item label="菜单栏中" name="hide">
<Select>
<Select.Option key="0" value={0}>
</Select.Option>
<Select.Option key="1" value={1}>
</Select.Option>
</Select>
</Form.Item>
<Form.Item label="渠道" name="channel">
<Select disabled={editing}>
<Select.Option key="fanmiyou" value="fanmiyou">
</Select.Option>
<Select.Option key="qiji" value="qiji">
</Select.Option>
</Select>
</Form.Item>
</Form>
</Modal>
</PageContainer>

2
src/pages/Overview.tsx

@ -36,8 +36,6 @@ const Overview: React.FC = () => {
};
const fetchDaily = async (params: API.IncomeQuery) => {
console.log('fetchDaily');
console.log(params);
const res = await incomeDaily(params);
if (res.data) {
setDaily(res.data);

16
src/pages/SuperAdmin.tsx

@ -208,7 +208,11 @@ const SuperAdmin: React.FC = () => {
const handleSaveMock = async (params: API.AddMockScheduleReq) => {
const { scheduleTime, ...otherValues } = params;
const timestamp = moment(scheduleTime).valueOf(); // 使用 moment.js 将日期转换为时间戳
await addSchedule({ scheduleTime: timestamp, ...otherValues }); // 将时间戳作为参数传递给后端
try {
await addSchedule({ scheduleTime: timestamp, ...otherValues }); // 将时间戳作为参数传递给后端
} catch {
return;
}
message.success('任务提交成功');
fetchScheduleList();
setSVisible(false);
@ -300,16 +304,6 @@ const SuperAdmin: React.FC = () => {
))}
</Select>
</Form.Item>
<Form.Item name="channel" label="渠道">
<Select>
<Select.Option key="fanmiyou" value="fanmiyou">
</Select.Option>
<Select.Option key="qiji" value="qiji">
</Select.Option>
</Select>
</Form.Item>
<Form.Item name="incomeYuan" label="金额(元)">
<Input />
</Form.Item>

49
src/requestErrorConfig.ts

@ -1,11 +1,7 @@
import type { RequestOptions } from '@@/plugin-request/request';
import type { RequestConfig } from '@umijs/max';
import { message, notification } from 'antd';
import { message } from 'antd';
// 错误处理方案: 错误类型
enum ErrorShowType {
SILENT = 0,
}
import type { RequestOptions } from '@@/plugin-request/request';
import type { RequestConfig } from '@umijs/max';
// 与后端约定的响应数据格式
interface ResponseStructure {
data: any;
@ -39,29 +35,7 @@ export const errorConfig: RequestConfig = {
if (error.name === 'BizError') {
const errorInfo: ResponseStructure | undefined = error.info;
if (errorInfo) {
// const { message, code } = errorInfo;
// switch (errorInfo.showType) {
// case ErrorShowType.SILENT:
// // do nothing
// break;
// case ErrorShowType.WARN_MESSAGE:
// message.warning(message);
// break;
// case ErrorShowType.ERROR_MESSAGE:
// message.error(message);
// break;
// case ErrorShowType.NOTIFICATION:
// notification.open({
// description: message,
// message: code,
// });
// break;
// case ErrorShowType.REDIRECT:
// // TODO: redirect
// break;
// default:
message.error(errorInfo.message);
// }
message.error(errorInfo.message);
}
} else if (error.response) {
// Axios 的错误
@ -92,16 +66,13 @@ export const errorConfig: RequestConfig = {
responseInterceptors: [
(response) => {
// 拦截响应数据,进行个性化处理
const { data} = response as unknown as ResponseStructure;
const { code, message } = data;
if (code !== 0) {
const error: any = new Error(message);
error.name = 'BizError';
error.info = data;
throw error; // 抛出自制的错误
const { data} = response as unknown as ResponseStructure; ;
if (data.code !== 0) {
data.success = false;
} else {
return response;
data.success = true;
}
},
return response;
}
],
};

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

@ -1,7 +1,6 @@
declare namespace API {
type AddMockScheduleReq = {
appId?: number;
channel?: string;
incomeYuan?: number;
scheduleTime?: number;
};
@ -191,6 +190,8 @@ declare namespace API {
code?: string;
url?: string;
income?: number;
channel?: string;
hide?: number;
secret?: string;
};

Loading…
Cancel
Save