From 910aadf9f04d0f578513b3533a289894ce125d5f Mon Sep 17 00:00:00 2001 From: liaoxuezhi Date: Mon, 30 Aug 2021 11:17:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E7=BB=84=E7=94=A8=E4=BA=8Ecrud=E8=BF=87=E6=BB=A4=E5=99=A8?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E6=8A=A5=E9=94=99=20(#2470)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Scoped.tsx | 8 ++++---- src/factory.tsx | 6 +++--- src/renderers/CRUD.tsx | 22 ++++++++-------------- src/renderers/Form/InputImage.tsx | 15 ++++++++++----- src/renderers/Form/index.tsx | 5 +++-- src/store/root.ts | 6 +++--- src/utils/api.ts | 9 +++++---- src/utils/helper.ts | 11 +++++++++++ 8 files changed, 47 insertions(+), 35 deletions(-) diff --git a/src/Scoped.tsx b/src/Scoped.tsx index d197df8ab..12cea72c2 100644 --- a/src/Scoped.tsx +++ b/src/Scoped.tsx @@ -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 { @@ -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); diff --git a/src/factory.tsx b/src/factory.tsx index 2d0fcd9c7..b6a53d8d0 100644 --- a/src/factory.tsx +++ b/src/factory.tsx @@ -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; diff --git a/src/renderers/CRUD.tsx b/src/renderers/CRUD.tsx index e94be9f9d..9b6534124 100644 --- a/src/renderers/CRUD.tsx +++ b/src/renderers/CRUD.tsx @@ -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 { 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 { ) { // 同步地址栏,那么直接检测 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 { perPageField, loadDataOnceFetchOnFilter } = this.props; + values = syncLocation - ? qs.parse( - qsstringify( - values, - { - arrayFormat: 'indices', - encodeValuesOnly: true - }, - true - ) - ) + ? qsparse(qsstringify(values, undefined, true)) : values; + store.updateQuery( { ...values, diff --git a/src/renderers/Form/InputImage.tsx b/src/renderers/Form/InputImage.tsx index 03b93fce4..a5228d9b9 100644 --- a/src/renderers/Form/InputImage.tsx +++ b/src/renderers/Form/InputImage.tsx @@ -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<
- { - crop.rotatable && + {crop.rotatable && ( - } + )} Date: Mon, 30 Aug 2021 11:18:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=20input-date=20=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=97=AE=E9=A2=98=20(#2473)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/calendar/DaysView.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/calendar/DaysView.tsx b/src/components/calendar/DaysView.tsx index d4389b80c..73aedb051 100644 --- a/src/components/calendar/DaysView.tsx +++ b/src/components/calendar/DaysView.tsx @@ -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( {({isOpen, getInputProps, openMenu, closeMenu}) => { const inputProps = getInputProps({ @@ -175,7 +180,7 @@ export class CustomDaysView extends DaysView {
{ this.setTime(