mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-03 12:29:24 +08:00
Merge remote-tracking branch 'baidu/master'
This commit is contained in:
commit
8a68509de6
@ -10,7 +10,7 @@ import hoistNonReactStatic from 'hoist-non-react-statics';
|
||||
import qs from 'qs';
|
||||
import {dataMapping} from './utils/tpl-builtin';
|
||||
import {RendererEnv, RendererProps} from './factory';
|
||||
import {noop, autobind, qsstringify} from './utils/helper';
|
||||
import {noop, autobind, qsstringify, qsparse} from './utils/helper';
|
||||
import {RendererData, Action} from './types';
|
||||
|
||||
export interface ScopedComponentType extends React.Component<RendererProps> {
|
||||
@ -112,7 +112,7 @@ function createScopedTools(
|
||||
let query = null;
|
||||
|
||||
if (~idx2) {
|
||||
const queryObj = qs.parse(
|
||||
const queryObj = qsparse(
|
||||
name
|
||||
.substring(idx2 + 1)
|
||||
.replace(
|
||||
@ -158,7 +158,7 @@ function createScopedTools(
|
||||
const askIdx = name.indexOf('?');
|
||||
if (~askIdx) {
|
||||
const query = name.substring(askIdx + 1);
|
||||
const queryObj = qs.parse(
|
||||
const queryObj = qsparse(
|
||||
query.replace(
|
||||
/\$\{(.*?)\}/,
|
||||
(_, match) => '${' + encodeURIComponent(match) + '}'
|
||||
@ -183,7 +183,7 @@ function createScopedTools(
|
||||
component.receive(values, subPath);
|
||||
} else if (name === 'window' && env && env.updateLocation) {
|
||||
const query = {
|
||||
...(location.search ? qs.parse(location.search.substring(1)) : {}),
|
||||
...(location.search ? qsparse(location.search.substring(1)) : {}),
|
||||
...values
|
||||
};
|
||||
const link = location.pathname + '?' + qsstringify(query);
|
||||
|
@ -151,11 +151,16 @@ export class CustomDaysView extends DaysView {
|
||||
const hours = this.computedTimeOptions(24);
|
||||
const times = this.computedTimeOptions(60);
|
||||
const options = type === 'hours' ? hours : times;
|
||||
const formatMap = {
|
||||
hours: 'HH',
|
||||
minutes: 'mm',
|
||||
seconds: 'ss'
|
||||
};
|
||||
|
||||
inputs.push(
|
||||
<Downshift
|
||||
key={i + 'input'}
|
||||
inputValue={date.format(format)}
|
||||
inputValue={date.format(formatMap[type])}
|
||||
>
|
||||
{({isOpen, getInputProps, openMenu, closeMenu}) => {
|
||||
const inputProps = getInputProps({
|
||||
@ -175,7 +180,7 @@ export class CustomDaysView extends DaysView {
|
||||
<div className={cx('CalendarInputWrapper')}>
|
||||
<input
|
||||
type="text"
|
||||
value={date.format(format)}
|
||||
value={date.format(formatMap[type])}
|
||||
className={cx('CalendarInput')}
|
||||
min={min}
|
||||
max={max}
|
||||
@ -189,7 +194,7 @@ export class CustomDaysView extends DaysView {
|
||||
<div
|
||||
key={option.value}
|
||||
className={cx('CalendarInput-sugsItem', {
|
||||
'is-highlight': option.value === date.format(format)
|
||||
'is-highlight': option.value === date.format(formatMap[type])
|
||||
})}
|
||||
onClick={() => {
|
||||
this.setTime(
|
||||
|
@ -4,7 +4,7 @@ import {RendererStore, IRendererStore, IIRendererStore} from './store/index';
|
||||
import {getEnv, destroy} from 'mobx-state-tree';
|
||||
import {wrapFetcher} from './utils/api';
|
||||
import {normalizeLink} from './utils/normalizeLink';
|
||||
import {findIndex, promisify, string2regExp} from './utils/helper';
|
||||
import {findIndex, promisify, qsparse, string2regExp} from './utils/helper';
|
||||
import {Api, fetcherResult, Payload, SchemaNode, Schema, Action} from './types';
|
||||
import {observer} from 'mobx-react';
|
||||
import Scoped from './Scoped';
|
||||
@ -302,8 +302,8 @@ const defaultOptions: RenderOptions = {
|
||||
if (pathname !== location.pathname || !location.search) {
|
||||
return false;
|
||||
}
|
||||
const query = qs.parse(search.substring(1));
|
||||
const currentQuery = qs.parse(location.search.substring(1));
|
||||
const query = qsparse(search.substring(1));
|
||||
const currentQuery = qsparse(location.search.substring(1));
|
||||
return Object.keys(query).every(key => query[key] === currentQuery[key]);
|
||||
} else if (pathname === location.pathname) {
|
||||
return true;
|
||||
|
@ -19,7 +19,8 @@ import {
|
||||
noop,
|
||||
isVisible,
|
||||
getVariable,
|
||||
qsstringify
|
||||
qsstringify,
|
||||
qsparse
|
||||
} from '../utils/helper';
|
||||
import {observer} from 'mobx-react';
|
||||
import partition from 'lodash/partition';
|
||||
@ -435,14 +436,14 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
||||
|
||||
if (syncLocation && location && (location.query || location.search)) {
|
||||
store.updateQuery(
|
||||
qs.parse(location.search.substring(1)),
|
||||
qsparse(location.search.substring(1)),
|
||||
undefined,
|
||||
pageField,
|
||||
perPageField
|
||||
);
|
||||
} else if (syncLocation && !location && window.location.search) {
|
||||
store.updateQuery(
|
||||
qs.parse(window.location.search.substring(1)) as object,
|
||||
qsparse(window.location.search.substring(1)) as object,
|
||||
undefined,
|
||||
pageField,
|
||||
perPageField
|
||||
@ -517,7 +518,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
||||
) {
|
||||
// 同步地址栏,那么直接检测 query 是否变了,变了就重新拉数据
|
||||
store.updateQuery(
|
||||
qs.parse(props.location.search.substring(1)),
|
||||
qsparse(props.location.search.substring(1)),
|
||||
undefined,
|
||||
props.pageField,
|
||||
props.perPageField
|
||||
@ -804,18 +805,11 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
||||
perPageField,
|
||||
loadDataOnceFetchOnFilter
|
||||
} = this.props;
|
||||
|
||||
values = syncLocation
|
||||
? qs.parse(
|
||||
qsstringify(
|
||||
values,
|
||||
{
|
||||
arrayFormat: 'indices',
|
||||
encodeValuesOnly: true
|
||||
},
|
||||
true
|
||||
)
|
||||
)
|
||||
? qsparse(qsstringify(values, undefined, true))
|
||||
: values;
|
||||
|
||||
store.updateQuery(
|
||||
{
|
||||
...values,
|
||||
|
@ -9,7 +9,13 @@ import find from 'lodash/find';
|
||||
import qs from 'qs';
|
||||
import {Payload} from '../../types';
|
||||
import {buildApi} from '../../utils/api';
|
||||
import {createObject, qsstringify, guid, isEmpty} from '../../utils/helper';
|
||||
import {
|
||||
createObject,
|
||||
qsstringify,
|
||||
guid,
|
||||
isEmpty,
|
||||
qsparse
|
||||
} from '../../utils/helper';
|
||||
import {Icon} from '../../components/icons';
|
||||
import Button from '../../components/Button';
|
||||
import accepts from 'attr-accept';
|
||||
@ -1037,7 +1043,7 @@ export default class ImageControl extends React.Component<
|
||||
|
||||
if (~idx && params) {
|
||||
params = {
|
||||
...qs.parse(api.url.substring(idx + 1)),
|
||||
...qsparse(api.url.substring(idx + 1)),
|
||||
...params
|
||||
};
|
||||
api.url = api.url.substring(0, idx) + '?' + qsstringify(params);
|
||||
@ -1213,8 +1219,7 @@ export default class ImageControl extends React.Component<
|
||||
<Cropper {...crop} ref={this.cropper} src={cropFile.preview} />
|
||||
</Suspense>
|
||||
<div className={cx('ImageControl-croperToolbar')}>
|
||||
{
|
||||
crop.rotatable &&
|
||||
{crop.rotatable && (
|
||||
<a
|
||||
className={cx('ImageControl-cropRotatable')}
|
||||
onClick={this.rotatableCrop}
|
||||
@ -1223,7 +1228,7 @@ export default class ImageControl extends React.Component<
|
||||
>
|
||||
<Icon icon="retry" className="icon" />
|
||||
</a>
|
||||
}
|
||||
)}
|
||||
<a
|
||||
className={cx('ImageControl-cropCancel')}
|
||||
onClick={this.cancelCrop}
|
||||
|
@ -18,7 +18,8 @@ import {
|
||||
SkipOperation,
|
||||
isEmpty,
|
||||
getVariable,
|
||||
isObjectShallowModified
|
||||
isObjectShallowModified,
|
||||
qsparse
|
||||
} from '../../utils/helper';
|
||||
import debouce from 'lodash/debounce';
|
||||
import flatten from 'lodash/flatten';
|
||||
@ -1701,7 +1702,7 @@ export class FormRenderer extends Form {
|
||||
const idx2 = target ? target.indexOf('?') : -1;
|
||||
if (~idx2) {
|
||||
subQuery = dataMapping(
|
||||
qs.parse((target as string).substring(idx2 + 1)),
|
||||
qsparse((target as string).substring(idx2 + 1)),
|
||||
ctx
|
||||
);
|
||||
target = (target as string).substring(0, idx2);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {Instance, types} from 'mobx-state-tree';
|
||||
import qs from 'qs';
|
||||
import {createObject} from '../utils/helper';
|
||||
import {createObject, qsparse} from '../utils/helper';
|
||||
import {ServiceStore} from './service';
|
||||
|
||||
export const RootStore = ServiceStore.named('RootStore')
|
||||
@ -33,9 +33,9 @@ export const RootStore = ServiceStore.named('RootStore')
|
||||
(location && location.query) ||
|
||||
(location &&
|
||||
location.search &&
|
||||
qs.parse(location.search.substring(1))) ||
|
||||
qsparse(location.search.substring(1))) ||
|
||||
(window.location.search &&
|
||||
qs.parse(window.location.search.substring(1)));
|
||||
qsparse(window.location.search.substring(1)));
|
||||
|
||||
self.query = query;
|
||||
}
|
||||
|
@ -10,7 +10,8 @@ import {
|
||||
object2formData,
|
||||
qsstringify,
|
||||
cloneObject,
|
||||
createObject
|
||||
createObject,
|
||||
qsparse
|
||||
} from './helper';
|
||||
|
||||
const rSchema = /(?:^|raw\:)(get|post|put|delete|patch|options|head):/i;
|
||||
@ -75,7 +76,7 @@ export function buildApi(
|
||||
|
||||
if (~idx) {
|
||||
const hashIdx = api.url.indexOf('#');
|
||||
const params = qs.parse(
|
||||
const params = qsparse(
|
||||
api.url.substring(idx + 1, ~hashIdx ? hashIdx : undefined)
|
||||
);
|
||||
api.url =
|
||||
@ -109,7 +110,7 @@ export function buildApi(
|
||||
const idx = api.url.indexOf('?');
|
||||
if (~idx) {
|
||||
let params = (api.query = {
|
||||
...qs.parse(api.url.substring(idx + 1)),
|
||||
...qsparse(api.url.substring(idx + 1)),
|
||||
...data
|
||||
});
|
||||
api.url = api.url.substring(0, idx) + '?' + qsstringify(params);
|
||||
@ -123,7 +124,7 @@ export function buildApi(
|
||||
const idx = api.url.indexOf('?');
|
||||
if (~idx) {
|
||||
let params = (api.query = {
|
||||
...qs.parse(api.url.substring(idx + 1)),
|
||||
...qsparse(api.url.substring(idx + 1)),
|
||||
...api.data
|
||||
});
|
||||
api.url = api.url.substring(0, idx) + '?' + qsstringify(params);
|
||||
|
@ -1319,6 +1319,17 @@ export function qsstringify(
|
||||
return qs.stringify(data, options);
|
||||
}
|
||||
|
||||
export function qsparse(
|
||||
data: string,
|
||||
options: any = {
|
||||
arrayFormat: 'indices',
|
||||
encodeValuesOnly: true,
|
||||
depth: 1000 // 默认是 5, 所以condition-builder只要来个条件组就会导致报错
|
||||
}
|
||||
) {
|
||||
return qs.parse(data, options);
|
||||
}
|
||||
|
||||
export function object2formData(
|
||||
data: any,
|
||||
options: any = {
|
||||
|
Loading…
Reference in New Issue
Block a user