diff --git a/fis-conf.js b/fis-conf.js index 1c2ea2810..0390528bb 100644 --- a/fis-conf.js +++ b/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': [ diff --git a/src/components/condition-builder/Field.tsx b/src/components/condition-builder/Field.tsx index 49e1af4d8..93588bbfa 100644 --- a/src/components/condition-builder/Field.tsx +++ b/src/components/condition-builder/Field.tsx @@ -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 { diff --git a/src/renderers/Form/City.tsx b/src/renderers/Form/City.tsx index de634198b..4a0174a42 100644 --- a/src/renderers/Form/City.tsx +++ b/src/renderers/Form/City.tsx @@ -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; + city: { + [propName: number]: Array; + }; + district: { + [propName: number]: + | { + [propName: number]: Array; + } + | Array; + }; + [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 ? (
).map(item => ({ + options={(db.district[provinceCode] as Array).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 ? ( ).map( + options={(db.district[provinceCode][cityCode] as Array).map( item => ({ label: db[item], value: item @@ -336,6 +378,8 @@ export class CityPicker extends React.Component< /> ) : null}
+ ) : ( + ); } }