Browse Source

refactor: update UI components and styles, adjust configs (#11511)

pull/11512/head
afc163 9 months ago
committed by GitHub
parent
commit
cf2d02a931
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      biome.json
  2. 8
      config/config.ts
  3. 4
      src/loading.tsx
  4. 4
      src/pages/account/center/components/ArticleListContent/index.style.ts
  5. 3
      src/pages/account/center/components/Articles/index.tsx
  6. 7
      src/pages/account/center/index.tsx
  7. 32
      src/pages/dashboard/analysis/components/ProportionSales.tsx
  8. 12
      src/pages/dashboard/analysis/components/SalesCard.tsx
  9. 5
      src/pages/dashboard/analysis/index.tsx
  10. 25
      src/pages/list/basic-list/index.tsx

2
biome.json

@ -14,6 +14,8 @@
"!**/dist/**",
"!**/server/**",
"!**/public/**",
"!**/coverage/**",
"!**/node_modules/**",
"!biome.json"
]
},

8
config/config.ts

@ -45,13 +45,9 @@ export default defineConfig({
* @name
* @description less
* @doc antd的主题设置 https://ant.design/docs/react/customize-theme-cn
* @doc umi theme https://umijs.org/docs/api/config#theme
* @doc umi theme https://umijs.org/docs/api/config#theme
*/
theme: {
// 如果不想要 configProvide 动态设置主题需要把这个设置为 default
// 只有设置为 variable, 才能使用 configProvide 动态设置主色调
'root-entry-name': 'variable',
},
// theme: { '@primary-color': '#1DA57A' }
/**
* @name moment
* @description js的包大小

4
src/loading.tsx

@ -1,5 +1,7 @@
import { Skeleton } from 'antd';
const Loading: React.FC = () => <Skeleton style={{ margin: '24px 40px' }} active />;
const Loading: React.FC = () => (
<Skeleton style={{ margin: '24px 40px' }} active />
);
export default Loading;

4
src/pages/account/center/components/ArticleListContent/index.style.ts

@ -10,8 +10,10 @@ const useStyles = createStyles(({ token }) => {
marginTop: '16px',
color: token.colorTextSecondary,
lineHeight: '22px',
display: 'flex',
gap: '8px',
alignItems: 'center',
'& > em': {
marginLeft: '16px',
color: token.colorTextDisabled,
fontStyle: 'normal',
},

3
src/pages/account/center/components/Articles/index.tsx

@ -31,6 +31,9 @@ const Articles: React.FC = () => {
rowKey="id"
itemLayout="vertical"
dataSource={listData?.list || []}
style={{
margin: '0 -24px',
}}
renderItem={(item) => (
<List.Item
key={item.id}

7
src/pages/account/center/index.tsx

@ -116,7 +116,6 @@ const TagList: React.FC<{
{inputVisible && (
<Input
ref={ref}
type="text"
size="small"
style={{
width: 78,
@ -227,7 +226,7 @@ const Center: React.FC = () => {
loading={loading}
>
{!loading && currentUser && (
<div>
<>
<div className={styles.avatarHolder}>
<img alt="" src={currentUser.avatar} />
<div className={styles.name}>{currentUser.name}</div>
@ -255,14 +254,14 @@ const Center: React.FC = () => {
))}
</Row>
</div>
</div>
</>
)}
</Card>
</Col>
<Col lg={17} md={24}>
<Card
className={styles.tabsCard}
bordered={false}
variant="borderless"
tabList={operationTabList}
activeTabKey={tabKey}
onTabChange={(_tabKey: string) => {

32
src/pages/dashboard/analysis/components/ProportionSales.tsx

@ -1,6 +1,5 @@
import { Pie } from '@ant-design/plots';
import { Card, Radio, Typography } from 'antd';
import type { RadioChangeEvent } from 'antd/es/radio';
import { Card, Segmented, Typography } from 'antd';
import numeral from 'numeral';
import React from 'react';
import type { DataItem } from '../data.d';
@ -18,14 +17,14 @@ const ProportionSales = ({
dropdownGroup: React.ReactNode;
salesType: 'all' | 'online' | 'stores';
salesPieData: DataItem[];
handleChangeSalesType?: (e: RadioChangeEvent) => void;
handleChangeSalesType?: (value: 'all' | 'online' | 'stores') => void;
}) => {
const { styles } = useStyles();
return (
<Card
loading={loading}
className={styles.salesCard}
bordered={false}
variant="borderless"
title="销售额类别占比"
style={{
height: '100%',
@ -33,17 +32,20 @@ const ProportionSales = ({
extra={
<div className={styles.salesCardExtra}>
{dropdownGroup}
<div className={styles.salesTypeRadio}>
<Radio.Group value={salesType} onChange={handleChangeSalesType}>
<Radio.Button value="all"></Radio.Button>
<Radio.Button value="online">线</Radio.Button>
<Radio.Button value="stores"></Radio.Button>
</Radio.Group>
</div>
<Segmented
className={styles.salesTypeRadio}
value={salesType}
onChange={handleChangeSalesType}
options={[
{ label: '全部渠道', value: 'all' },
{ label: '线上', value: 'online' },
{ label: '门店', value: 'stores' },
]}
size="middle"
/>
</div>
}
>
<div>
<Text></Text>
<Pie
height={340}
@ -55,12 +57,10 @@ const ProportionSales = ({
legend={false}
label={{
position: 'spider',
text: (item: { x: number; y: number }) => {
return `${item.x}: ${numeral(item.y).format('0,0')}`;
},
text: (item: { x: number; y: number }) =>
`${item.x}: ${numeral(item.y).format('0,0')}`,
}}
/>
</div>
</Card>
);
};

12
src/pages/dashboard/analysis/components/SalesCard.tsx

@ -39,13 +39,15 @@ const SalesCard = ({
return (
<Card
loading={loading}
bordered={false}
bodyStyle={{
padding: 0,
variant="borderless"
styles={{
body: {
padding: loading ? 24 : 0,
},
}}
>
<div className={styles.salesCard}>
<Tabs
className={styles.salesCard}
tabBarExtraContent={
<div className={styles.salesExtraWrap}>
<div className={styles.salesExtra}>
@ -77,6 +79,7 @@ const SalesCard = ({
<RangePicker
value={rangePickerValue}
onChange={handleRangePickerChange}
variant="filled"
style={{
width: 256,
}}
@ -212,7 +215,6 @@ const SalesCard = ({
},
]}
/>
</div>
</Card>
);
};

5
src/pages/dashboard/analysis/index.tsx

@ -3,7 +3,6 @@ import { GridContent } from '@ant-design/pro-components';
import { useRequest } from '@umijs/max';
import { Col, Dropdown, Row } from 'antd';
import type { RangePickerProps } from 'antd/es/date-picker';
import type { RadioChangeEvent } from 'antd/es/radio';
import type { Dayjs } from 'dayjs';
import type { FC } from 'react';
import { Suspense, useState } from 'react';
@ -90,8 +89,8 @@ const Analysis: FC<AnalysisProps> = () => {
</Dropdown>
</span>
);
const handleChangeSalesType = (e: RadioChangeEvent) => {
setSalesType(e.target.value);
const handleChangeSalesType = (value: SalesType) => {
setSalesType(value);
};
const handleTabChange = (key: string) => {
setCurrentTabKey(key);

25
src/pages/list/basic-list/index.tsx

@ -11,8 +11,8 @@ import {
List,
Modal,
Progress,
Radio,
Row,
Segmented,
} from 'antd';
import dayjs from 'dayjs';
import type { FC } from 'react';
@ -27,8 +27,6 @@ import {
} from './service';
import useStyles from './style.style';
const RadioButton = Radio.Button;
const RadioGroup = Radio.Group;
const { Search } = Input;
const Info: FC<{
title: React.ReactNode;
@ -139,15 +137,20 @@ export const BasicList: FC = () => {
};
const extraContent = (
<div>
<RadioGroup defaultValue="all">
<RadioButton value="all"></RadioButton>
<RadioButton value="progress"></RadioButton>
<RadioButton value="waiting"></RadioButton>
</RadioGroup>
<Segmented
defaultValue="all"
options={[
{ label: '全部', value: 'all' },
{ label: '进行中', value: 'progress' },
{ label: '等待中', value: 'waiting' },
]}
// 如有需要可添加 onChange 事件
/>
<Search
className={styles.extraContentSearch}
placeholder="请输入"
onSearch={() => ({})}
variant="filled"
/>
</div>
);
@ -204,13 +207,15 @@ export const BasicList: FC = () => {
<Card
className={styles.listCard}
bordered={false}
variant="borderless"
title="基本列表"
style={{
marginTop: 24,
}}
bodyStyle={{
styles={{
body: {
padding: '0 32px 40px 32px',
},
}}
extra={extraContent}
>

Loading…
Cancel
Save