Skip to content

Commit

Permalink
卡片页面更新
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoubichuan committed Dec 16, 2023
1 parent 8ead40e commit 85eed7c
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/global.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if (pwa) {
worker.postMessage({ type: 'skip-waiting' }, [channel.port2]);
});
// Refresh current page to use the updated HTML and other assets after SW has skiped waiting
window.location.reload(true);
window.location.reload();
return true;
};
const key = `open${Date.now()}`;
Expand Down
1 change: 0 additions & 1 deletion src/pages/Admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export default (): React.ReactNode => {
<a href="https://pro.ant.design/docs/block-cn" target="_blank" rel="noopener noreferrer">
use block
</a>
</p>
</PageHeaderWrapper>
);
Expand Down
8 changes: 4 additions & 4 deletions src/pages/list/card-list/data.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export type Member = {
avatar: string;
images: array;
name: string;
id: string;
};

export type CardListItemDataType = {
id: string;
owner: string;
title: string;
avatar: string;
author: string;
images: array;
cover: string;
status: 'normal' | 'exception' | 'active' | 'success';
percent: number;
Expand All @@ -18,7 +18,7 @@ export type CardListItemDataType = {
updatedAt: number;
createdAt: number;
subDescription: string;
description: string;
descript: string;
activeUser: number;
newUser: number;
star: number;
Expand Down
50 changes: 9 additions & 41 deletions src/pages/list/card-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,20 @@ import { useRequest } from 'umi';
import { queryFakeList } from './service';
import type { CardListItemDataType } from './data.d';
import styles from './style.less';

import classNames from 'classnames';
const { Paragraph } = Typography;

const CardList = () => {
const { data, loading } = useRequest(() => {
return queryFakeList({
count: 8,
current: 1,
pageSize: 10,
});
});

const list = data?.list || [];

const content = (
<div className={styles.pageHeaderContent}>
<p>
段落示意:蚂蚁金服务设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,
提供跨越设计与开发的体验解决方案。
</p>
<div className={styles.contentLink}>
<a>
<img alt="" src="https://gw.alipayobjects.com/zos/rmsportal/MjEImQtenlyueSmVEfUD.svg" />{' '}
快速开始
</a>
<a>
<img alt="" src="https://gw.alipayobjects.com/zos/rmsportal/NbuDUAuBlIApFuDvWiND.svg" />{' '}
产品简介
</a>
<a>
<img alt="" src="https://gw.alipayobjects.com/zos/rmsportal/ohOEPSYdDTNnyMbGuyLb.svg" />{' '}
产品文档
</a>
</div>
</div>
);

const extraContent = (
<div className={styles.extraImg}>
<img
alt="这是一个标题"
src="https://gw.alipayobjects.com/zos/rmsportal/RzwpdLnhmvDJToTdfDPe.png"
/>
</div>
);
const list: any = data || [];
const nullData: Partial<CardListItemDataType> = {};
return (
<PageContainer content={content} extraContent={extraContent}>
<PageContainer className={classNames('pro-container', styles['pro-container'])}>
<div className={styles.cardList}>
<List<Partial<CardListItemDataType>>
rowKey="id"
Expand All @@ -72,14 +40,14 @@ const CardList = () => {
<Card
hoverable
className={styles.card}
actions={[<a key="option1">操作一</a>, <a key="option2">操作二</a>]}
actions={[<a key="option1">编辑</a>, <a key="option2">查看详情</a>]}
>
<Card.Meta
avatar={<img alt="" className={styles.cardAvatar} src={item.avatar} />}
title={<a>{item.title}</a>}
avatar={<img alt="" className={styles.cardAvatar} src={item.images[0]} />}
title={<a>{item.author}</a>}
description={
<Paragraph className={styles.item} ellipsis={{ rows: 3 }}>
{item.description}
{item.descript}
</Paragraph>
}
/>
Expand Down
5 changes: 3 additions & 2 deletions src/pages/list/card-list/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { request } from 'umi';
import type { CardListItemDataType } from './data.d';

export async function queryFakeList(params: {
count: number;
current: number;
pageSize: number;
}): Promise<{ data: { list: CardListItemDataType[] } }> {
return request('/api/card_fake_list', {
return request('/api/list/data/1', {
params,
});
}
16 changes: 16 additions & 0 deletions src/pages/list/card-list/style.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
@import '~antd/es/style/themes/default.less';
@import './utils/utils.less';
.pro-container {
display: flex;
flex-direction: column;
height: calc(100vh - 48px);
margin: 0 !important;

:global {
.ant-pro-grid-content {
flex: 1;
overflow-y: auto;
.ant-pro-page-container-children-content {
margin: 0;
}
}
}
}
.cardList {
margin: 24px 0;
.card {
:global {
.ant-card-meta-title {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/list/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ const TableList: React.FC = () => {
valueType: 'option',
fixed: 'right',
width: 160,
render: (_, record) => [
render: (_, record: any) => [
<a
key="add"
onClick={async () => {
const copyParams = {};
const copyParams: any = {};
templateData
.filter((item: any) => item.create)
.forEach((field: any) => {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/list/search/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { PageContainer } from '@ant-design/pro-layout';
import { Input } from 'antd';
import type { FC } from 'react';
import React, { useState, useRef, useEffect } from 'react';
import { useState, useEffect } from 'react';
import { history } from 'umi';
import { list, addList, updateList, removeList, exportList, getTemplate } from './service';
import { list } from './service';

type SearchProps = {
match: {
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"allowJs": true,
"skipLibCheck": true,
Expand Down

0 comments on commit 85eed7c

Please sign in to comment.