Skip to content

Commit 350737b

Browse files
committed
fix: 修复modal微信端无动效问题
1 parent 8e79807 commit 350737b

File tree

6 files changed

+125
-26
lines changed

6 files changed

+125
-26
lines changed

compiled/alipay/src/Modal/props.ts

+12
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ export interface IModalProps extends IBaseProps {
3737
* @description 过渡动画时长,单位毫秒
3838
*/
3939
duration: number;
40+
/**
41+
* @description 是否开启过渡动画
42+
*/
43+
animation: boolean;
44+
/**
45+
* @description 弹窗层级
46+
*/
47+
zIndex: number;
4048
/**
4149
* @description 标题
4250
*/
@@ -103,6 +111,8 @@ export const ModalDefaultProps: Partial<IModalProps> = {
103111
closable: true,
104112
type: 'default',
105113
duration: 200,
114+
animation: true,
115+
zIndex: 998,
106116
};
107117

108118
export const ModalFunctionalProps: Partial<IModalProps> = {
@@ -114,6 +124,8 @@ export const ModalFunctionalProps: Partial<IModalProps> = {
114124
type: 'default',
115125
closable: true,
116126
duration: 200,
127+
animation: true,
128+
zIndex: 998,
117129
title: '',
118130
content: '',
119131
visible: false,

compiled/wechat/src/Modal/props.js

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ export var ModalDefaultProps = {
44
closable: true,
55
type: 'default',
66
duration: 200,
7+
animation: true,
8+
zIndex: 998,
79
};
810
export var ModalFunctionalProps = {
911
bodyClassName: '',
@@ -14,6 +16,8 @@ export var ModalFunctionalProps = {
1416
type: 'default',
1517
closable: true,
1618
duration: 200,
19+
animation: true,
20+
zIndex: 998,
1721
title: '',
1822
content: '',
1923
visible: false,

src/Modal/index.axml.tsx

+24-26
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,32 @@ import AntPopup from '../Popup/index.axml';
33
import AntButton from '../Button/index.axml';
44
import AntIcon from '../Icon/index.axml';
55
import { IModalProps } from './props';
6-
import { TSXMLProps, InternalData } from 'tsxml';
6+
import { TSXMLProps } from 'tsxml';
77
import utils from './index.sjs';
88

9-
export default (
10-
{
11-
className,
12-
style,
13-
maskClassName,
14-
maskStyle,
15-
visible,
16-
duration,
17-
destroyOnClose,
18-
bodyClassName,
19-
bodyStyle,
20-
title,
21-
content,
22-
type,
23-
primaryButtonText,
24-
primaryButtonStyle,
25-
secondaryButtonText,
26-
secondaryButtonStyle,
27-
cancelButtonText,
28-
cancelButtonStyle,
29-
closable,
30-
}: TSXMLProps<IModalProps>,
31-
32-
{ animation, zIndex }: InternalData
33-
) => (
9+
export default ({
10+
className,
11+
style,
12+
maskClassName,
13+
maskStyle,
14+
visible,
15+
duration,
16+
destroyOnClose,
17+
bodyClassName,
18+
bodyStyle,
19+
title,
20+
content,
21+
type,
22+
primaryButtonText,
23+
primaryButtonStyle,
24+
secondaryButtonText,
25+
secondaryButtonStyle,
26+
cancelButtonText,
27+
cancelButtonStyle,
28+
closable,
29+
animation,
30+
zIndex,
31+
}: TSXMLProps<IModalProps>) => (
3432
<Component>
3533
<AntPopup
3634
className={`ant-modal ${className || ''}`}

src/Modal/props.ts

+12
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ export interface IModalProps extends IBaseProps {
3737
* @description 过渡动画时长,单位毫秒
3838
*/
3939
duration: number;
40+
/**
41+
* @description 是否开启过渡动画
42+
*/
43+
animation: boolean;
44+
/**
45+
* @description 弹窗层级
46+
*/
47+
zIndex: number;
4048
/**
4149
* @description 标题
4250
*/
@@ -103,6 +111,8 @@ export const ModalDefaultProps: Partial<IModalProps> = {
103111
closable: true,
104112
type: 'default',
105113
duration: 200,
114+
animation: true,
115+
zIndex: 998,
106116
};
107117

108118
export const ModalFunctionalProps: Partial<IModalProps> = {
@@ -114,6 +124,8 @@ export const ModalFunctionalProps: Partial<IModalProps> = {
114124
type: 'default',
115125
closable: true,
116126
duration: 200,
127+
animation: true,
128+
zIndex: 998,
117129
title: '',
118130
content: '',
119131
visible: false,

tests/alipay/Modal/__tests__/index.test.ts

+51
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,57 @@
11
import { getInstance } from 'tests/utils';
22
import { describe, it, expect, vi } from 'vitest';
33

4+
describe('init', () => {
5+
it('测试默认值', () => {
6+
const instance = getInstance('Modal', {});
7+
8+
const {
9+
bodyClassName,
10+
bodyStyle,
11+
maskClassName,
12+
maskStyle,
13+
maskClosable,
14+
type,
15+
closable,
16+
duration,
17+
animation,
18+
zIndex,
19+
title,
20+
content,
21+
visible,
22+
destroyOnClose,
23+
primaryButtonText,
24+
secondaryButtonText,
25+
cancelButtonText,
26+
primaryButtonStyle,
27+
secondaryButtonStyle,
28+
cancelButtonStyle,
29+
} = instance.getConfig().props;
30+
expect({
31+
bodyClassName,
32+
bodyStyle,
33+
maskClassName,
34+
maskStyle,
35+
maskClosable,
36+
type,
37+
closable,
38+
duration,
39+
animation,
40+
zIndex,
41+
title,
42+
content,
43+
visible,
44+
destroyOnClose,
45+
primaryButtonText,
46+
secondaryButtonText,
47+
cancelButtonText,
48+
primaryButtonStyle,
49+
secondaryButtonStyle,
50+
cancelButtonStyle,
51+
}).toMatchFileSnapshot('snapshot/alipay_config_props.txt');
52+
});
53+
});
54+
455
describe('modal onClose', () => {
556
it('modal onClose', () => {
657
const onClose = vi.fn();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"animation": true,
3+
"bodyClassName": "",
4+
"bodyStyle": "",
5+
"cancelButtonStyle": "",
6+
"cancelButtonText": "",
7+
"closable": true,
8+
"content": "",
9+
"destroyOnClose": false,
10+
"duration": 200,
11+
"maskClassName": "",
12+
"maskClosable": true,
13+
"maskStyle": "",
14+
"primaryButtonStyle": "",
15+
"primaryButtonText": "",
16+
"secondaryButtonStyle": "",
17+
"secondaryButtonText": "",
18+
"title": "",
19+
"type": "default",
20+
"visible": false,
21+
"zIndex": 998,
22+
}

0 commit comments

Comments
 (0)