(
97 | (props, ref) => {
98 | const {
99 | // affect outter ...
100 | className,
101 |
102 | // affect inner
103 | component: Component,
104 | viewBox,
105 | spin,
106 | rotate,
107 |
108 | tabIndex,
109 | onClick,
110 |
111 | // children
112 | children,
113 | ...restProps
114 | } = props;
115 |
116 | console.warn(
117 | Boolean(Component || children),
118 | 'Should have `component` prop or `children`.',
119 | );
120 |
121 | useInsertStyles();
122 |
123 | const { prefixCls = 'anticon' } = React.useContext(IconContext);
124 |
125 | const classString = classNames(prefixCls, className);
126 |
127 | const svgClassString = classNames({
128 | [`${prefixCls}-spin`]: !!spin,
129 | });
130 |
131 | const svgStyle = rotate
132 | ? {
133 | msTransform: `rotate(${rotate}deg)`,
134 | transform: `rotate(${rotate}deg)`,
135 | }
136 | : undefined;
137 |
138 | const innerSvgProps: CustomIconComponentProps = {
139 | ...svgBaseProps,
140 | className: svgClassString,
141 | style: svgStyle,
142 | viewBox,
143 | };
144 |
145 | if (!viewBox) {
146 | delete innerSvgProps.viewBox;
147 | }
148 |
149 | // component > children
150 | const renderInnerNode = () => {
151 | if (Component) {
152 | return {children};
153 | }
154 |
155 | if (children) {
156 | console.warn(
157 | Boolean(viewBox) ||
158 | (React.Children.count(children) === 1 &&
159 | React.isValidElement(children) &&
160 | React.Children.only(children).type === 'use'),
161 | 'Make sure that you provide correct `viewBox`' +
162 | ' prop (default `0 0 1024 1024`) to the icon.',
163 | );
164 |
165 | return (
166 |
169 | );
170 | }
171 |
172 | return null;
173 | };
174 |
175 | let iconTabIndex = tabIndex;
176 | if (iconTabIndex === undefined && onClick) {
177 | iconTabIndex = -1;
178 | }
179 |
180 | return (
181 |
189 | {renderInnerNode()}
190 |
191 | );
192 | },
193 | );
194 |
195 | Icon.displayName = 'UmiAntdMobileIcon';
196 |
197 | export default Icon;
198 |
--------------------------------------------------------------------------------
/README-zh_CN.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | UmiJS
20 |
21 |
22 |
23 | Ant Design Mobile
24 |
25 |
26 |
27 |
28 |
29 |
30 |
umi-antd-mobile 移动应用
31 |
32 |
33 | [](https://umijs.org/zh-CN)
34 | [](https://mobile.ant.design)
35 | [](https://github.com/hqwlkj/umi-antd-mobile)
36 |
37 | [English](./README.md) · 中文
38 |
39 |
40 |
41 |
42 |
43 | # 快速上手
44 |
45 | ## 环境准备
46 |
47 | 首先得有 [node](https://nodejs.org/en/),并确保 node 版本是 10.13 或以上。(mac 下推荐使用 [nvm](https://github.com/creationix/nvm) 来管理 node 版本)
48 |
49 | ```bash
50 | $ node -v
51 | v10.13.0
52 | ```
53 |
54 | 推荐使用 yarn 管理 npm 依赖,并[使用国内源](https://github.com/yiminghe/tyarn)(阿里用户使用内网源)。
55 |
56 | ```bash
57 |
58 | # 国内源
59 | $ npm i yarn tyarn -g
60 |
61 | # 后面文档里的 yarn 换成 tyarn
62 | $ tyarn -v
63 |
64 | # 阿里内网源
65 | $ tnpm i yarn @ali/yarn -g
66 |
67 | # 后面文档里的 yarn 换成 ayarn
68 | $ ayarn -v
69 | ```
70 |
71 |
72 | ## 开始使用
73 |
74 | clone项目
75 |
76 | ```bash
77 | $ git clone --depth=1 https://github.com/hqwlkj/umi-antd-mobile.git my-project
78 |
79 | $ cd my-project
80 | ```
81 |
82 | 安装项目依赖
83 |
84 | ```bash
85 | $ yarn
86 | ```
87 |
88 | 本地启动
89 |
90 | ```bash
91 | $ yarn start
92 | ```
93 |
94 | ## 部署发布
95 |
96 | ### 构建
97 |
98 | ```bash
99 | $ yarn build
100 |
101 | ✔ Webpack
102 | Compiled successfully in 17.17s
103 |
104 | DONE Compiled successfully in 17167ms 8:26:25 PM
105 |
106 | Build success.
107 | ✨ Done in 20.79s.
108 | ```
109 |
110 | 构建产物默认生成到 `./dist` 下,然后通过 tree 命令查看,
111 |
112 | ```bash
113 | tree ./dist
114 |
115 | ./dist
116 | ├── index.html
117 | ├── umi.css
118 | └── umi.js
119 | ```
120 |
121 | ### 本地验证
122 |
123 | 发布之前,可以通过 `serve` 做本地验证,
124 |
125 | ```bash
126 | $ yarn global add serve
127 | $ serve ./dist
128 |
129 | ┌────────────────────────────────────────────────────┐
130 | │ │
131 | │ Serving! │
132 | │ │
133 | │ - Local: http://localhost:5000 │
134 | │ - On Your Network: http://192.168.12.34:5000 │
135 | │ │
136 | │ Copied local address to clipboard! │
137 | │ │
138 | └────────────────────────────────────────────────────┘
139 | ```
140 |
141 | 访问 [http://localhost:5000](http://localhost:5000),正常情况下应该是和执行 `yarn start` 时是一致的。
142 |
143 | ### 部署
144 |
145 | 本地验证完,就可以部署了。你需要把 `dist` 目录部署到服务器上。
146 |
147 | 更多关于 **umijs** 的相关配置,请查阅 [umijs官方文档](https://umijs.org/zh-CN/config)
148 |
149 | 更多关于 **antd-mobile** 的相关组件使用说明,请查阅 [Ant Design Mobile官方文档](https://mobile.ant.design/zh/components/button)
150 |
151 |
152 | ## 预览效果图
153 |
154 |
155 |
156 | https://github.com/hqwlkj/umi-antd-mobile/assets/12181423/e7fc06ba-f835-4f7c-a412-a7e0b9664095
157 |
158 | 目前还是一个测试demo,所以图片就是一个截屏图,大家先将就看看 😂😂😂
159 |
160 | ## 内置 Layout
161 |
162 | 在 `src/layouts`中配置了两个常用的 `layout` 组件。
163 |
164 | >1、`tab-bar` layout 主要用于根据配置的 `routes` 动态生成带有 Tabbar 的页面(如示例效果图);同时可以根据浏览器地址栏的地址选择对于的 TabItem;
165 |
166 | >2、 `basic` layout 主要用于普通的路由使用;目前没有做过多的封装;
167 |
168 | **这里的layout需要重新再构思一下;也希望社区能提供更好的建议**
169 |
170 |
171 | ## FAQ
172 | >1. 如何更换自动生成的 `TabBar` 图标?
173 |
174 | ```text
175 | 由于 `umijs` 的路由配置中没有支持 icon 属性可以为一个图标,所以需要自己进行处理,处理的方式如下:
176 |
177 | 在配置 `routes` 时,将`icon`设置为 `antd-mobile-icons` 中的图标名称;
178 | 然后在 `src/layouts/tab-bar/index.tsx` 中的 `renderTabItemIcon` 函数中对应进行修改。
179 |
180 | ```
181 |
182 | >2. 整理中 😄😄
183 |
184 |
185 |
186 | ## 参与贡献
187 |
188 | 我们非常欢迎你的贡献,你可以通过以下方式和我一起共建 :smiley::
189 |
190 | - 通过 [Issue](https://github.com/hqwlkj/umi-antd-mobile/issues) 报告 bug 或进行咨询。
191 | - 提交 [Pull Request](https://github.com/hqwlkj/umi-antd-mobile/pulls) 改进代码。
192 |
193 |
194 |
195 | ## LICENSE
196 |
197 | [MIT](https://github.com/hqwlkj/umi-antd-mobile/blob/master/LICENSE.md)
198 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | UmiJS
20 |
21 |
22 |
23 | Ant Design Mobile
24 |
25 |
26 |
27 |
28 |
29 |
30 |
umi-antd-mobile Mobile Application
31 |
32 |
33 | [](https://umijs.org/zh-CN)
34 | [](https://mobile.ant.design)
35 | [](https://github.com/hqwlkj/umi-antd-mobile)
36 |
37 | English · [中文](./README-zh_CN.md)
38 |
39 |
40 |
41 |
42 |
43 | # Getting Started
44 |
45 | ## Environment Setup
46 |
47 | First, make sure you have [node](https://nodejs.org), and ensure the node version is 10.13 or above (it is recommended to use [nvm](https://github.com/nvm-sh/nvm) to manage node versions on Mac).
48 |
49 | ```bash
50 | $ node -v
51 | v10.13.0
52 | ```
53 |
54 | It is recommended to use yarn to manage npm dependencies and [use a domestic source](https://yarnpkg.com).
55 |
56 | ```bash
57 | # Domestic source
58 | $ npm i yarn tyarn -g
59 |
60 | # Use tyarn instead of yarn in the following documents
61 | $ tyarn -v
62 |
63 | # Alibaba internal source
64 | $ tnpm i yarn @ali/yarn -g
65 |
66 | # Use ayarn instead of yarn in the following documents
67 | $ ayarn -v
68 | ```
69 |
70 | ## Getting Started
71 |
72 | Clone the project
73 |
74 | ```bash
75 | $ git clone --depth=1 https://github.com/hqwlkj/umi-antd-mobile.git my-project
76 |
77 | $ cd my-project
78 | ```
79 |
80 | Install project dependencies
81 |
82 | ```bash
83 | $ yarn
84 | ```
85 |
86 | Start locally
87 |
88 | ```bash
89 | $ yarn start
90 | ```
91 |
92 | ## Deployment
93 |
94 | ### Build
95 |
96 | ```bash
97 | $ yarn build
98 |
99 | ✔ Webpack
100 | Compiled successfully in 17.17s
101 |
102 | DONE Compiled successfully in 17167ms 8:26:25 PM
103 |
104 | Build success.
105 | ✨ Done in 20.79s.
106 | ```
107 |
108 | The build output is generated by default to `./dist`. Use the tree command to view it.
109 |
110 | ```bash
111 | tree ./dist
112 |
113 | ./dist
114 | ├── index.html
115 | ├── umi.css
116 | └── umi.js
117 | ```
118 |
119 | ### Local Verification
120 |
121 | Before deploying, you can use `serve` for local verification.
122 |
123 | ```bash
124 | $ yarn global add serve
125 | $ serve ./dist
126 |
127 | ┌────────────────────────────────────────────────────┐
128 | │ │
129 | │ Serving! │
130 | │ │
131 | │ - Local: http://localhost:5000 │
132 | │ - On Your Network: http://192.168.12.34:5000 │
133 | │ │
134 | │ Copied local address to clipboard! │
135 | │ │
136 | └────────────────────────────────────────────────────┘
137 | ```
138 |
139 | Visit [http://localhost:5000](http://localhost:5000), it should be consistent with executing `yarn start`.
140 |
141 | ### Deployment
142 |
143 | After local verification, you can deploy. You need to deploy the `dist` directory to the server.
144 |
145 | For more configuration related to umijs, please refer to the [umijs official documentation](https://umijs.org).
146 |
147 | For more usage instructions on antd-mobile components, please refer to the [Ant Design Mobile official documentation](https://mobile.ant.design).
148 |
149 | ## Preview Effect Diagram
150 |
151 |
152 |
153 | https://github.com/hqwlkj/umi-antd-mobile/assets/12181423/e7fc06ba-f835-4f7c-a412-a7e0b9664095
154 |
155 | Currently, it is still a test demo, so the pictures are just screenshots.
156 |
157 | ## Built-in Layout
158 |
159 | There are two commonly used `layout` components configured in `src/layouts`.
160 |
161 | > 1. The `tab-bar` layout is mainly used to dynamically generate pages with Tabbar based on the configured `routes` (as shown in the example effect diagram); it can also select the corresponding TabItem based on the address in the browser's address bar.
162 | > 2. The `basic` layout is mainly used for ordinary routing; currently, it is not extensively wrapped.
163 |
164 | These layouts need to be rethought; community suggestions are welcome.
165 |
166 | ## FAQ
167 |
168 | > 1. How to change the automatically generated `TabBar` icon?
169 |
170 | Since the `umijs` route configuration does not support the icon attribute as an icon, you need to handle it yourself as follows:
171 |
172 | When configuring `routes`, set `icon` to the icon name in `antd-mobile-icons`; then modify it in the `renderTabItemIcon` function in `src/layouts/tab-bar/index.tsx`.
173 |
174 | ## Contributing
175 |
176 | We welcome your contributions. You can contribute in the following ways:
177 |
178 | * Report bugs or make inquiries through [Issues](https://github.com/hqwlkj/umi-antd-mobile/issues).
179 | * Submit [Pull Requests](https://github.com/hqwlkj/umi-antd-mobile/pulls) to improve the code.
180 |
181 | ## LICENSE
182 |
183 | [MIT](https://github.com/hqwlkj/umi-antd-mobile/blob/master/LICENSE)
184 |
185 | ---
186 |
--------------------------------------------------------------------------------
/src/pages/account/index.tsx:
--------------------------------------------------------------------------------
1 | import {
2 | Avatar,
3 | Badge,
4 | DotLoading,
5 | List,
6 | NavBar,
7 | PullToRefresh,
8 | Space,
9 | } from 'antd-mobile';
10 | import {
11 | AlipayCircleFill,
12 | AntOutline,
13 | BankcardOutline,
14 | CheckShieldOutline,
15 | ContentOutline,
16 | CouponOutline,
17 | FileOutline,
18 | FireFill,
19 | GiftOutline,
20 | HandPayCircleOutline,
21 | HistogramOutline,
22 | KoubeiFill,
23 | MoreOutline,
24 | PayCircleOutline,
25 | PieOutline,
26 | ReceiptOutline,
27 | SetOutline,
28 | UserCircleOutline,
29 | } from 'antd-mobile-icons';
30 | import styles from './index.less';
31 | import { useState } from 'react';
32 | import { sleep } from 'antd-mobile/es/utils/sleep';
33 |
34 | export default () => {
35 | const listData = [
36 | [
37 | {
38 | icon: ,
39 | title: (
40 |
41 | 支付宝会员 {' '}
42 |
45 | {' '}
46 | 钻石会员
47 |
48 | }
49 | />
50 |
51 | ),
52 | extra: '',
53 | },
54 | {
55 | icon: ,
56 | title: '用户保护中心',
57 | extra: '',
58 | },
59 | {
60 | icon: ,
61 | title: '商家服务',
62 | extra: '',
63 | },
64 | ],
65 | [
66 | {
67 | icon: ,
68 | title: '账单',
69 | extra: '',
70 | },
71 | {
72 | icon: ,
73 | title: '总资产',
74 | extra: 免费升级账户保障,
75 | },
76 | {
77 | icon: ,
78 | title: '余额',
79 | extra: 5.00,
80 | },
81 | {
82 | icon: ,
83 | title: '余额宝',
84 | extra: '',
85 | },
86 | {
87 | icon: ,
88 | title: '花呗',
89 | extra: '',
90 | },
91 | {
92 | icon: ,
93 | title: '余利宝',
94 | extra: '',
95 | },
96 | {
97 | icon: ,
98 | title: '银行卡',
99 | extra: '',
100 | },
101 | ],
102 | [
103 | {
104 | icon: ,
105 | title: '芝麻信用',
106 | extra: (
107 |
108 | 有芝麻粒待积攒
109 |
110 | ),
111 | },
112 | {
113 | icon: ,
114 | title: '蚂蚁保',
115 | extra: '',
116 | },
117 | {
118 | icon: ,
119 | title: '相互宝',
120 | extra: '',
121 | },
122 | {
123 | icon: ,
124 | title: '网商贷',
125 | extra: '',
126 | },
127 | {
128 | icon: ,
129 | title: '网商银行',
130 | extra: '',
131 | },
132 | ],
133 | [
134 | {
135 | icon: ,
136 | title: '我的公益',
137 | extra: '',
138 | },
139 | ],
140 | ];
141 |
142 | const right = (
143 |
144 |
145 |
146 |
147 |
148 |
149 | );
150 |
151 | const getNextData = () => {
152 | let current = 1;
153 | const ret: string[] = [];
154 | for (let i = 0; i < 18; i++) {
155 | ret.unshift(current.toString());
156 | current++;
157 | }
158 | return ret;
159 | };
160 |
161 | const [data, setData] = useState(() => getNextData());
162 |
163 | return (
164 |
165 |
我的}
169 | />
170 |
171 |
{
173 | switch (status) {
174 | case 'pulling':
175 | return (
176 |
177 |
178 |
179 | );
180 | case 'canRelease':
181 | return (
182 |
186 | );
187 | case 'refreshing':
188 | return (
189 |
190 |
191 |
192 | );
193 | case 'complete':
194 | return '';
195 | default:
196 | return '';
197 | }
198 | }}
199 | onRefresh={async () => {
200 | await sleep(2000);
201 | setData([...getNextData(), ...data]);
202 | }}
203 | >
204 |
205 |
206 |
213 | }
214 | description="deserunt@ali.com"
215 | onClick={() => {}}
216 | >
217 | Novalee Spicer
218 |
219 |
220 |
221 | {listData.map((group, i) => {
222 | return (
223 |
224 |
225 | {group.map((item, j) => (
226 | {}}
230 | extra={item.extra}
231 | >
232 | {item.title}
233 |
234 | ))}
235 |
236 |
237 | );
238 | })}
239 |
240 |
241 |
242 | );
243 | };
244 |
--------------------------------------------------------------------------------
/src/pages/home/index.tsx:
--------------------------------------------------------------------------------
1 | import { history } from '@umijs/max';
2 | import {
3 | Button,
4 | Grid,
5 | Popover,
6 | Space,
7 | Swiper,
8 | Switch,
9 | Toast,
10 | } from 'antd-mobile';
11 | import {
12 | AddCircleOutline,
13 | AntOutline,
14 | DownOutline,
15 | FolderOutline,
16 | ReceivePaymentOutline,
17 | RightOutline,
18 | ScanningOutline,
19 | SearchOutline,
20 | TravelOutline,
21 | UploadOutline,
22 | UserContactOutline,
23 | } from 'antd-mobile-icons';
24 | import { useLayoutEffect, useState } from 'react';
25 | import styles from './index.less';
26 |
27 | export default function IndexPage() {
28 | const colors = ['#ace0ff', '#bcffbd', '#e4fabd', '#ffcfac'];
29 | const items = colors.map((color, index) => (
30 |
31 | {
35 | Toast.show(`你点击了卡片 ${index + 1}`);
36 | }}
37 | >
38 | {index + 1}
39 |
40 |
41 | ));
42 | const [enableDarkMode, setEnableDarkMode] = useState(false);
43 |
44 | useLayoutEffect(() => {
45 | document.documentElement.setAttribute(
46 | 'data-prefers-color-scheme',
47 | enableDarkMode ? 'dark' : 'light',
48 | );
49 | }, [enableDarkMode]);
50 |
51 | return (
52 |
53 |
54 |
55 |
56 |
57 |
58 | 重庆
59 |
60 |
61 |
多云 9℃
62 |
63 |
64 |
65 |
66 |
67 |
68 |
null}
74 | >
75 |
76 |
77 | 重庆市第九人民医院
78 |
79 |
80 |
81 |
82 | 重庆市卫健委发布重要通知
83 |
84 |
85 |
86 |
87 |
搜索
88 |
89 |
90 |
91 |
92 |
95 |
99 |
103 |
107 |
111 |
112 | }
113 | placement="topRight"
114 | mode="dark"
115 | trigger="click"
116 | >
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 | 扫一扫
126 |
127 |
128 |
129 | 收付款
130 |
131 |
132 |
133 | 出行
134 |
135 |
136 |
137 | 卡包
138 |
139 |
140 |
141 |
142 |
143 | {[
144 | '饿了么',
145 | '消费金',
146 | '市民中心',
147 | '芭芭农场',
148 | '蚂蚁森林',
149 | '转账',
150 | '汇率换算',
151 | '余额宝',
152 | '蚂蚁新村',
153 | '生活缴费',
154 | '花呗',
155 | '健康码',
156 | '运动',
157 | '我的小程序',
158 | '更多',
159 | ].map((text, index) => (
160 | history.push('/detail')}
164 | >
165 |
166 | {text}
167 |
168 | ))}
169 |
170 |
171 |
172 |
173 |
174 | 余额宝:余额宝收益到账啦 7分钟前
175 |
176 |
177 | 蚂蚁财富:你的基金收益已更新 15分钟前
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 | {items}
187 |
188 |
189 |
190 |
191 |
201 |
211 |
221 |
231 |
232 |
233 |
234 |
235 | Dark Mode
236 | {
239 | setEnableDarkMode(v);
240 | }}
241 | />
242 |
243 |
244 |
245 | );
246 | }
247 |
--------------------------------------------------------------------------------