Skip to content

Commit

Permalink
fix: 页面调整
Browse files Browse the repository at this point in the history
  • Loading branch information
yxh01132861 committed Nov 17, 2023
1 parent cd033bf commit e62c988
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default (props: AreaWidgetProps) => {
const [scene] = useScene();
const { position, showBounds } = props;
const style = useStyle();
const [cityName, setCityName] = useState('全国');
const [regionName, setRegionName] = useState('全国');
const [open, setOpen] = useState(false);
const [loading, setLoading] = useState(false);

Expand Down Expand Up @@ -59,7 +59,7 @@ export default (props: AreaWidgetProps) => {
}

if (scene && cityData) {
const data = treeToArr([cityData.cities]).find((item: ICity) => item.name.includes(value.name));
const data = treeToArr([cityData.cities]).find((item: ICity) => item.name === value.name);
if (data) {
scene.setZoomAndCenter(11, [data.lng, data.lat]);
}
Expand All @@ -74,13 +74,13 @@ export default (props: AreaWidgetProps) => {
const onSelectChange = (value: string) => {
const newValue = JSON.parse(value || '');
setOpen(false);
setCityName(newValue.name);
setRegionName(newValue.name);
if (newValue) getBoundsData(newValue);
};

const onClickItem = (v: ICity) => {
setOpen(false);
setCityName(v.name);
setRegionName(v.shortName || v.name);
if (v) getBoundsData(v);
};

Expand Down Expand Up @@ -122,7 +122,7 @@ export default (props: AreaWidgetProps) => {
onClick={() => onClickItem(hot as ICity)}
className={cls(`${CLS_PREFIX}__content-header-item`, style.tabContentItem)}
>
{hot.name}
{hot.shortName}
</div>
);
})}
Expand All @@ -142,14 +142,14 @@ export default (props: AreaWidgetProps) => {
}, [position]);

const onRest = () => {
setCityName('全国');
setRegionName('全国');
setBoundBorder(undefined);
};

const getTitle = () => {
return (
<div className={style.popoverName}>
<div>所在区域:{cityName.replace('市', '').replace('省', '')}</div>
<div>所在区域:{regionName.replace('市', '').replace('省', '')}</div>
<Button type="text" size="small" icon={<CloseOutlined />} onClick={() => onRest()} style={{ marginLeft: 8 }} />
</div>
);
Expand All @@ -170,7 +170,9 @@ export default (props: AreaWidgetProps) => {
<Spin spinning={loading}>
<div className={cls(`${CLS_PREFIX}`, style.popoverContent)}>
<div className={cls(`${CLS_PREFIX}__title`, style.popoverTitle)}>
<div className={cls(`${CLS_PREFIX}__title-name`, style.popoverTitleName)}>{cityName}</div>
<div className={cls(`${CLS_PREFIX}__title-name`, style.popoverTitleName)}>
{regionName.replace('市', '').replace('省', '')}
</div>
<CaretDownOutlined rotate={open ? 180 : 0} />
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ export const POPOVER_PLACEMENT_LEGEND = new Map<string | undefined, TooltipPlace
]);

export const HotCityList = [
{ adcode: '100000', name: '全国', level: 'country' },
{ adcode: '110000', name: '北京', level: 'province' },
{ adcode: '120000', name: '天津', level: 'province' },
{ adcode: '210100', name: '沈阳', level: 'city' },
{ adcode: '210200', name: '大连', level: 'city' },
{ adcode: '310000', name: '上海', level: 'province' },
{ adcode: '320100', name: '南京', level: 'city' },
{ adcode: '320500', name: '苏州', level: 'city' },
{ adcode: '330100', name: '杭州', level: 'city' },
{ adcode: '370200', name: '青岛', level: 'city' },
{ adcode: '410100', name: '郑州', level: 'city' },
{ adcode: '420100', name: '武汉', level: 'city' },
{ adcode: '430100', name: '长沙', level: 'city' },
{ adcode: '440100', name: '广州', level: 'city' },
{ adcode: '440300', name: '深圳', level: 'city' },
{ adcode: '500000', name: '重庆', level: 'province' },
{ adcode: '510100', name: '成都', level: 'city' },
{ adcode: '610100', name: '西安', level: 'city' },
{ adcode: '810000', name: '香港', level: 'province' },
{ adcode: '820000', name: '澳门', level: 'province' },
{ adcode: '100000', shortName: '全国', name: '全国', level: 'country' },
{ adcode: '110000', shortName: '北京', name: '北京市', level: 'province' },
{ adcode: '120000', shortName: '天津', name: '天津市', level: 'province' },
{ adcode: '210100', shortName: '沈阳', name: '沈阳市', level: 'city' },
{ adcode: '210200', shortName: '大连', name: '大连市', level: 'city' },
{ adcode: '310000', shortName: '上海', name: '上海市', level: 'province' },
{ adcode: '320100', shortName: '南京', name: '南京市', level: 'city' },
{ adcode: '320500', shortName: '苏州', name: '苏州市', level: 'city' },
{ adcode: '330100', shortName: '杭州', name: '杭州市', level: 'city' },
{ adcode: '370200', shortName: '青岛', name: '青岛市', level: 'city' },
{ adcode: '410100', shortName: '郑州', name: '郑州市', level: 'city' },
{ adcode: '420100', shortName: '武汉', name: '武汉市', level: 'city' },
{ adcode: '430100', shortName: '长沙', name: '长沙市', level: 'city' },
{ adcode: '440100', shortName: '广州', name: '广州市', level: 'city' },
{ adcode: '440300', shortName: '深圳', name: '深圳市', level: 'city' },
{ adcode: '500000', shortName: '重庆', name: '重庆市', level: 'province' },
{ adcode: '510100', shortName: '成都', name: '成都市', level: 'city' },
{ adcode: '610100', shortName: '西安', name: '西安市', level: 'city' },
{ adcode: '810000', shortName: '香港', name: '香港特别行政区', level: 'province' },
{ adcode: '820000', shortName: '澳门', name: '澳门特别行政区', level: 'province' },
];
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type HotCities = { adcode: string; name: string; level: string };
export type HotCities = { adcode: string; name: string; shortName: string; level: string };

export type ICity = {
lng: number;
Expand Down

0 comments on commit e62c988

Please sign in to comment.