瀏覽代碼

完成操作记录页面开发

main
郑州 3 年之前
父節點
當前提交
094ca545be
共有 8 個檔案被更改,包括 100 行新增23 行删除
  1. +0
    -2
      electron/main.js
  2. +2
    -3
      src/components/FileStatus/FileStatus.tsx
  3. +13
    -6
      src/layouts/indexLayout.less
  4. +47
    -11
      src/pages/log/index.tsx
  5. +19
    -0
      src/pages/log/log.less
  6. +16
    -0
      src/services/API.d.ts
  7. +2
    -1
      src/utils/hooks.ts
  8. +1
    -0
      src/utils/request.ts

+ 0
- 2
electron/main.js 查看文件

@@ -145,10 +145,8 @@ ipcMain.handle('open-file-position', (event, message) => {

// 主窗口给消息窗口notifyWindow发送消息
ipcMain.handle('notify', (event, messageObj) => {
// if (!mainWindow.isVisible()) { // 在主窗口不可见时才给消息窗口返送消息
notifyWindow.show();
notifyWindow.webContents.send('on-notify', messageObj);
// }
});
// 消息窗口给主窗口发送重新同步文件的命令
ipcMain.handle('re-sync-file', (event, messageObj) => {


+ 2
- 3
src/components/FileStatus/FileStatus.tsx 查看文件

@@ -140,7 +140,7 @@ function LoadDesc(props: LoadDescProps) {
const [resultText, icon] = useMemo(() => {
if (loadingState === TaskStatus.FINISH) {
return [
'成功!',
`${keywords}成功!`,
<CheckCircleFilled
className={classNames(styles.stateIcon, styles.success)}
/>,
@@ -148,7 +148,7 @@ function LoadDesc(props: LoadDescProps) {
}
if (loadingState === TaskStatus.FAILED) {
return [
'失败!',
`${keywords}失败!`,
<CloseCircleFilled
className={classNames(styles.stateIcon, styles.error)}
/>,
@@ -166,7 +166,6 @@ function LoadDesc(props: LoadDescProps) {
) : (
<>
{icon}
{keywords}
{resultText}
</>
)}


+ 13
- 6
src/layouts/indexLayout.less 查看文件

@@ -1,23 +1,31 @@
.app {
height: 100%;
padding-top: @app-header-height;
overflow: hidden;
}
.main {
display: flex;
flex-direction: row;
// display: flex;
// flex-direction: row;
height: 100%;

.content {
flex: 1;
display: inline-block;
vertical-align: top;
height: 100%;
width: calc(100% - 48px);
background-color: #f6f6f6;
}
}

.nav {
display: inline-block;
vertical-align: top;
width: 48px;
padding: 24px 0 0 8px;
box-shadow: 0.5px 0px 0px 0px #EEF2F5;
box-shadow: 0.5px 0px 0px 0px #eef2f5;
z-index: 1;
height: 100%;
flex: none;
.navItem {
display: block;
width: 32px;
@@ -36,6 +44,5 @@
&.active {
border-color: rgba(120, 80, 255, 0.5);
}
}
}
}

+ 47
- 11
src/pages/log/index.tsx 查看文件

@@ -1,30 +1,45 @@
import React from 'react';
import { Form, Table, Input, Button, Space } from 'antd';
import ProTable, { ProColumns } from '@ant-design/pro-table';
import ProTable, { ProColumns, ProTableProps } from '@ant-design/pro-table';
import styles from './log.less';
import { useCallback } from 'react';
import { fetchApi } from '@/utils/request';
import { DATA } from '@/services/API';
import { throttle } from 'lodash';

enum LogActionType {
Download,
Delete,
Upload,
Download = 'DOWNLOAD',
Delete = 'DELETE',
Upload = 'UPLOAD',
}

const tableColumns: Array<ProColumns<any>> = [
const tableColumns: Array<ProColumns<DATA.LogItem>> = [
{ dataIndex: 'archName', title: '名称' },
{ dataIndex: 'folderName', title: '所属文件夹', search: false },
{ dataIndex: 'size', title: '大小', search: false },
{ dataIndex: 'folderName', title: '所属文件夹', search: false, width: 400 },
// { dataIndex: 'size', title: '大小', search: false },
{
dataIndex: 'actionType',
title: '操作类型',
search: false,
width: 200,
valueEnum: {
[LogActionType.Download]: '下载',
[LogActionType.Delete]: '删除',
[LogActionType.Upload]: '上传',
},
filters: true,
onFilter: (v, record) => record.actionType === v,
},
{ dataIndex: 'operator', title: '操作人', search: false, width: 200 },
{
dataIndex: 'createTime',
valueType: 'dateTime',
width: 200,
title: '操作时间',
search: false,
sorter: (a, b) => a.timestamp - b.timestamp,
defaultSortOrder: 'descend',
},
{ dataIndex: 'operator', title: '操作人' },
{ dataIndex: 'operateTime', title: '操作时间', search: false },
// {
// search: false,
// render() {
@@ -38,14 +53,35 @@ const tableColumns: Array<ProColumns<any>> = [
];

export default function LogView() {
const fetchLog = useCallback(
throttle(async ({ archName }) => {
const res = await fetchApi<DATA.LogItem[]>(
'file/queryProjArchiveLogTbByCondition',
{ archName },
);
if (res.data) {
res.data.forEach((item) => {
item.timestamp = new Date(item.createTime).getTime();
});
}
return {
success: res.requestIsSuccess,
data: res.data || [],
};
}, 5000),
[],
);

return (
<div className={styles.logView}>
<ProTable
<ProTable<DATA.LogItem>
rowKey="id"
className={styles.tableWrapper}
tableClassName={styles.table}
columns={tableColumns}
toolBarRender={false}
pagination={false}
request={fetchLog}
scroll={{ y: 'calc(100% - 47px)' }}
/>
</div>
);


+ 19
- 0
src/pages/log/log.less 查看文件

@@ -2,6 +2,7 @@
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
padding: 12px;
}

@@ -15,10 +16,28 @@
}

.tableWrapper {
height: 100%;
width: 100%;
flex: 1;
display: flex;
flex-direction: column;
:global {
.ant-card {
height: calc(100% - 44px) !important;
}
.ant-card-body,
.ant-table-wrapper,
.ant-spin-nested-loading,
.ant-spin-container,
.ant-table-container {
height: 100%;
}
.ant-table-pagination.ant-pagination {
padding: 0 10px;
}
.ant-table {
height: calc(100% - 56px);
}
.ant-pro-table-search {
flex: none;
background-color: transparent;


+ 16
- 0
src/services/API.d.ts 查看文件

@@ -92,4 +92,20 @@ declare namespace DATA {
*/
notifyMessage: string;
}

export interface LogItem {
actionType: string; // "DOWNLOAD"
archId: string; // "419204528580485120"
archName: string; // "本地上传001"
createTime: string; // "2021-07-14T16:51:33+08:00"
timestamp: number; // 前端自建
createUserId: string; // "330031270501289985"
extension: string; // "txt"
folderName: string; // "财务审批"
id: string; // "421725357130276864"
ipfsCid: string; // "QmeAnrtkYVUMFvD6tY2a2QqE696uKQS4MXFbgj1S1PP7RX"
projId: string; // "330800853156257792"
relativePath: string; // ""
version: number; // 3
}
}

+ 2
- 1
src/utils/hooks.ts 查看文件

@@ -133,7 +133,8 @@ export function useNotificationMessages() {
}),
]);
const finalList = headList.data
?.concat(hisList.data || [])
?.reverse()
.concat((hisList.data || []).reverse())
.reduce((arr, notifyMessage) => {
const message = transformNotifyMessage(notifyMessage);
if (!message) return arr;


+ 1
- 0
src/utils/request.ts 查看文件

@@ -1,3 +1,4 @@
import { API } from '@/services/API';
import { isClient } from '@/services/system';
import { message } from 'antd';
import { request } from 'umi';


Loading…
取消
儲存