mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
sdk 版本调整
This commit is contained in:
parent
44d3ac5c53
commit
1fa1a428f4
12
fis-conf.js
12
fis-conf.js
@ -313,7 +313,7 @@ if (fis.project.currentMedia() === 'publish') {
|
||||
env.get('project.ignore').push('sdk/**');
|
||||
env.set('project.files', ['examples/sdk-placeholder.html']);
|
||||
|
||||
env.match('/{examples,scss}/(**)', {
|
||||
env.match('/{examples,scss,src}/(**)', {
|
||||
release: '/$1'
|
||||
});
|
||||
|
||||
@ -354,8 +354,9 @@ if (fis.project.currentMedia() === 'publish') {
|
||||
rExt: '.js'
|
||||
});
|
||||
|
||||
env.match('/examples/sdk-mod.js', {
|
||||
isMod: false
|
||||
env.match('/examples/mod.js', {
|
||||
isMod: false,
|
||||
optimizer: fis.plugin('uglify-js')
|
||||
});
|
||||
|
||||
env.match('*.{js,jsx,ts,tsx}', {
|
||||
@ -388,7 +389,10 @@ if (fis.project.currentMedia() === 'publish') {
|
||||
'!echarts/**',
|
||||
'!papaparse/**',
|
||||
'!docsearch.js/**',
|
||||
'!monaco-editor/**.css'
|
||||
'!monaco-editor/**.css',
|
||||
'!src/components/RichText.tsx',
|
||||
'!src/components/Tinymce.tsx',
|
||||
'!src/lib/renderers/Form/CityDB.js'
|
||||
],
|
||||
|
||||
'rich-text.js': [
|
||||
|
@ -4,7 +4,6 @@ import ListRadios from '../ListRadios';
|
||||
import ResultBox from '../ResultBox';
|
||||
import {ClassNamesFn, ThemeProps, themeable} from '../../theme';
|
||||
import {Icon} from '../icons';
|
||||
import {find} from 'lodash';
|
||||
import {findTree, noop} from '../../utils/helper';
|
||||
|
||||
export interface ConditionFieldProps extends ThemeProps {
|
||||
|
@ -1,8 +1,7 @@
|
||||
import React from 'react';
|
||||
import {FormItem, FormControlProps, FormBaseControl} from './Item';
|
||||
import db, {province, city, district} from './CityDB';
|
||||
import {ClassNamesFn, themeable, ThemeProps} from '../../theme';
|
||||
import {Select} from '../../components';
|
||||
import {Select, Spinner} from '../../components';
|
||||
import {autobind} from '../../utils/helper';
|
||||
import {Option} from './Options';
|
||||
import {localeable, LocaleProps} from '../../locale';
|
||||
@ -71,6 +70,21 @@ export interface CityPickerState {
|
||||
district: string;
|
||||
districtCode: number;
|
||||
street: string;
|
||||
|
||||
db?: {
|
||||
province: Array<string>;
|
||||
city: {
|
||||
[propName: number]: Array<number>;
|
||||
};
|
||||
district: {
|
||||
[propName: number]:
|
||||
| {
|
||||
[propName: number]: Array<number>;
|
||||
}
|
||||
| Array<number>;
|
||||
};
|
||||
[propName: string]: any;
|
||||
};
|
||||
}
|
||||
|
||||
export class CityPicker extends React.Component<
|
||||
@ -86,7 +100,7 @@ export class CityPicker extends React.Component<
|
||||
allowStreet: false
|
||||
};
|
||||
|
||||
state = {
|
||||
state: CityPickerState = {
|
||||
code: 0,
|
||||
province: '',
|
||||
provinceCode: 0,
|
||||
@ -98,17 +112,38 @@ export class CityPicker extends React.Component<
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.syncIn();
|
||||
this.loadDb(() => this.syncIn());
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: CityPickerProps) {
|
||||
const props = this.props;
|
||||
|
||||
if (props.value !== prevProps.value) {
|
||||
this.syncIn(props);
|
||||
this.loadDb(() => this.syncIn(props));
|
||||
}
|
||||
}
|
||||
|
||||
loadDb(callback?: () => void) {
|
||||
if (this.state.db) {
|
||||
callback?.();
|
||||
return;
|
||||
}
|
||||
|
||||
(require as any)(['./CityDB.ts'], (db: any) =>
|
||||
this.setState(
|
||||
{
|
||||
db: {
|
||||
...db.default,
|
||||
province: db.province,
|
||||
city: db.city,
|
||||
district: db.district
|
||||
}
|
||||
},
|
||||
callback
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@autobind
|
||||
handleProvinceChange(option: Option) {
|
||||
this.setState(
|
||||
@ -178,8 +213,13 @@ export class CityPicker extends React.Component<
|
||||
|
||||
@autobind
|
||||
syncIn(props = this.props) {
|
||||
const db = this.state.db!;
|
||||
const {value, delimiter} = props;
|
||||
|
||||
if (!db) {
|
||||
return;
|
||||
}
|
||||
|
||||
const state = {
|
||||
code: 0,
|
||||
province: '',
|
||||
@ -271,13 +311,13 @@ export class CityPicker extends React.Component<
|
||||
translate: __
|
||||
} = this.props;
|
||||
|
||||
const {provinceCode, cityCode, districtCode, street} = this.state;
|
||||
const {provinceCode, cityCode, districtCode, street, db} = this.state;
|
||||
|
||||
return (
|
||||
return db ? (
|
||||
<div className={cx('CityPicker', className)}>
|
||||
<Select
|
||||
disabled={disabled}
|
||||
options={province.map(item => ({
|
||||
options={db.province.map(item => ({
|
||||
label: db[item],
|
||||
value: item
|
||||
}))}
|
||||
@ -287,20 +327,22 @@ export class CityPicker extends React.Component<
|
||||
|
||||
{provinceCode &&
|
||||
allowDistrict &&
|
||||
Array.isArray(district[provinceCode]) ? (
|
||||
Array.isArray(db.district[provinceCode]) ? (
|
||||
<Select
|
||||
disabled={disabled}
|
||||
options={(district[provinceCode] as Array<number>).map(item => ({
|
||||
options={(db.district[provinceCode] as Array<number>).map(item => ({
|
||||
label: db[item],
|
||||
value: item
|
||||
}))}
|
||||
value={districtCode}
|
||||
onChange={this.handleDistrictChange}
|
||||
/>
|
||||
) : allowCity && city[provinceCode] && city[provinceCode].length ? (
|
||||
) : allowCity &&
|
||||
db.city[provinceCode] &&
|
||||
db.city[provinceCode].length ? (
|
||||
<Select
|
||||
disabled={disabled}
|
||||
options={city[provinceCode].map(item => ({
|
||||
options={db.city[provinceCode].map(item => ({
|
||||
label: db[item],
|
||||
value: item
|
||||
}))}
|
||||
@ -311,11 +353,11 @@ export class CityPicker extends React.Component<
|
||||
|
||||
{cityCode &&
|
||||
allowDistrict &&
|
||||
district[provinceCode] &&
|
||||
district[provinceCode][cityCode] ? (
|
||||
db.district[provinceCode] &&
|
||||
db.district[provinceCode][cityCode] ? (
|
||||
<Select
|
||||
disabled={disabled}
|
||||
options={(district[provinceCode][cityCode] as Array<number>).map(
|
||||
options={(db.district[provinceCode][cityCode] as Array<number>).map(
|
||||
item => ({
|
||||
label: db[item],
|
||||
value: item
|
||||
@ -336,6 +378,8 @@ export class CityPicker extends React.Component<
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
) : (
|
||||
<Spinner show size="sm" />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user