Skip to content

Commit 5729dc1

Browse files
author
sunxiaoyu
committed
add upload method && fix modal icon bug
1 parent aa793d1 commit 5729dc1

8 files changed

Lines changed: 29 additions & 27 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "santd",
3-
"version": "0.3.3",
3+
"version": "0.3.4",
44
"description": "san UI design",
55
"scripts": {
66
"start": "cross-env NODE_ENV=development node scripts/preview.js",

src/modal/Dialog.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import KeyCode from '../core/util/keyCode';
1111
import {on, addClass, removeClass, getScrollBarSize} from '../core/util/dom';
1212
import TransitionEvents from '../core/util/css-animation/Event';
1313
import button from '../button';
14-
import icon from '../icon';
1514

1615
export const filters = {
1716
css(style) {
@@ -128,11 +127,7 @@ export default san.defineComponent({
128127
<sentinel s-ref="sentinelStart" type="sentinelStart"/>
129128
<div class="${prefixCls}-content">
130129
<button s-if="{{closable}}" aria-label="Close" class="${prefixCls}-close" on-click="close">
131-
<slot name="closeIcon">
132-
<span class="${prefixCls}-close-x">
133-
<s-icon class="${prefixCls}-close-icon" type="close"/>
134-
</span>
135-
</slot>
130+
<slot name="closeIcon"/>
136131
</button>
137132
<div s-if="{{title}}" s-ref="header" class="${prefixCls}-header">
138133
<slot name="title">
@@ -156,8 +151,7 @@ export default san.defineComponent({
156151
},
157152
components: {
158153
'sentinel': sentinel,
159-
's-button': button,
160-
's-icon': icon
154+
's-button': button
161155
},
162156
filters: {
163157
...filters

src/modal/Modal.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import san, {DataTypes} from 'san';
88
import {classCreator} from '../core/util';
99
import Dialog from './Dialog';
1010
import button from '../button';
11+
import icon from '../icon';
1112
import localeReceiver from '../localeprovider/receiver';
1213

1314
const prefixCls = classCreator('modal')();
@@ -26,7 +27,8 @@ export default san.defineComponent({
2627
},
2728

2829
components: {
29-
's-button': button
30+
's-button': button,
31+
's-icon': icon
3032
},
3133

3234
computed: {
@@ -70,7 +72,11 @@ export default san.defineComponent({
7072
on-afterClose="afterClose"
7173
>
7274
<slot/>
73-
<slot name="closeIcon" slot="closeIcon"/>
75+
<slot name="closeIcon" slot="closeIcon">
76+
<span class="${prefixCls}-close-x">
77+
<s-icon class="${prefixCls}-close-icon" type="close"/>
78+
</span>
79+
</slot>
7480
<slot name="footer" slot="footer">
7581
<s-button s-bind="{{cancelButtonProps}}"
7682
on-click="handleCancel"

src/tree/tree.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ export default san.defineComponent({
123123
// 如果有父子关联,拿到整个链上的数据
124124
if (!checkStrictly) {
125125
let allKeys = this.getAllCheckedKeys(this.treeNodes, checkedKeys.concat());
126-
this.data.set('allCheckedKeys', allKeys.checkedKeys);
127-
this.data.set('allHalfCheckedKeys', allKeys.halfCheckedKeys);
126+
checkedKeys = allKeys.checkedKeys;
127+
halfCheckedKeys = allKeys.halfCheckedKeys.filter(key => !checkedKeys.includes(key));
128+
this.data.set('allCheckedKeys', checkedKeys);
129+
this.data.set('allHalfCheckedKeys', halfCheckedKeys);
128130
}
129131
// 没有关联的话直接返回当前数据
130132
else {
@@ -300,17 +302,11 @@ export default san.defineComponent({
300302
let halfCheckedKeys = checkStrictly ? [] : this.data.get('allHalfCheckedKeys');
301303
let allKeys = this.getChangedCheckedKeys(this.treeNodes, key, checked, checkedKeys, halfCheckedKeys, checkStrictly);
302304

303-
// 非受控状态下,所有数据都走内部的allCheckedKeys和allHalfCheckedKeys
304-
if (!('checkedKeys' in this.data.get())) {
305-
checkedKeys = allKeys.checkedKeys;
306-
halfCheckedKeys = allKeys.halfCheckedKeys;
307-
this.data.set('allCheckedKeys', checkedKeys);
308-
this.data.set('allHalfCheckedKeys', halfCheckedKeys);
309-
}
310-
// 受控状态不保存数据,由外部传入的checkedKeys经过处理后拿到
311-
else {
312-
checkedKeys = allKeys.checkedKeys;
313-
}
305+
checkedKeys = allKeys.checkedKeys;
306+
halfCheckedKeys = allKeys.halfCheckedKeys;
307+
this.data.set('allCheckedKeys', checkedKeys);
308+
this.data.set('allHalfCheckedKeys', halfCheckedKeys);
309+
314310
this.updateTreeNodes();
315311
if (payload.value.event === 'check') {
316312
this.fire('check', {checkedKeys: checkedKeys, info: payload.value});

src/upload/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
| --- | --- | --- | --- |
55
| accept | 接受上传的文件类型, 详见 [input accept Attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-accept) | string ||
66
| action | 必选参数, 上传的地址 | string ||
7+
| method | 上传请求的 http method | string | 'post' |
78
| directory | 支持上传文件夹([caniuse](https://caniuse.com/#feat=input-file-directory)| boolean | false |
89
| beforeUpload | 上传文件之前的钩子,参数为上传的文件,若返回 `false` 则停止上传。支持返回一个 Promise 对象,Promise 对象 reject 时则停止上传,resolve 时开始上传( resolve 传入 `File``Blob` 对象则上传 resolve 传入对象)。注意:IE9 不支持该方法。 | (file, fileList) => boolean \| Promise ||
910
| customRequest | 通过覆盖默认的上传行为,可以自定义自己的上传实现 | function ||

src/upload/src/ajaxUploader.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export default san.defineComponent({
2828
beforeUpload: DataTypes.func,
2929
customRequest: DataTypes.func,
3030
withCredentials: DataTypes.bool,
31-
openFileDialogOnClick: DataTypes.bool
31+
openFileDialogOnClick: DataTypes.bool,
32+
method: DataTypes.oneOf(['POST', 'PUT', 'post', 'put'])
3233
},
3334
initData() {
3435
return {
@@ -114,6 +115,7 @@ export default san.defineComponent({
114115
filename: this.data.get('name'),
115116
file,
116117
data,
118+
method: this.data.get('method'),
117119
headers: this.data.get('headers'),
118120
withCredentials: this.data.get('withCredentials'),
119121
onProgress: e => {

src/upload/src/request.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ export default function upload(option) {
6969

7070
option.onSuccess(getBody(xhr), xhr);
7171
};
72+
let method = option.method || 'post';
7273

7374

74-
xhr.open('post', option.action, true);
75+
xhr.open(method, option.action, true);
7576

7677
// Has to be after `.open()`. See https://github.com/enyo/dropzone/issues/179
7778
if (option.withCredentials && 'withCredentials' in xhr) {

src/upload/upload.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const uploadButtonTemplate = `
3333
headers="{{headers}}"
3434
multiple="{{multiple}}"
3535
name="{{name}}"
36+
method="{{method}}"
3637
openFileDialogOnClick="{{openFileDialogOnClick}}"
3738
beforeUpload="{{beforeUploadFunc(beforeUpload, fileList)}}"
3839
s-ref="button"
@@ -95,7 +96,8 @@ export default san.defineComponent({
9596
disabled: false,
9697
openFileDialogOnClick: true,
9798
dragState: 'drop',
98-
showButton: true
99+
showButton: true,
100+
method: 'post'
99101
};
100102
},
101103

0 commit comments

Comments
 (0)