feat: 添加中国地图交互功能
- 新增 react-simple-maps 地图库 - 实现中国省级行政区划地图(34 个省份) - 首页集成地图组件,点击省份跳转城市列表 - 悬停显示省份名称,热力图颜色表示内容丰富度 - 重构 stores 导出方式,支持 hooks 模式
This commit is contained in:
44
backend/apps/regions/management/commands/seed_provinces.py
Normal file
44
backend/apps/regions/management/commands/seed_provinces.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from apps.regions.models import Region
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Seed Chinese provinces data'
|
||||
|
||||
# 中国 34 个省级行政区
|
||||
PROVINCES = [
|
||||
# 直辖市
|
||||
'北京市', '天津市', '上海市', '重庆市',
|
||||
# 省
|
||||
'河北省', '山西省', '辽宁省', '吉林省', '黑龙江省',
|
||||
'江苏省', '浙江省', '安徽省', '福建省', '江西省',
|
||||
'山东省', '河南省', '湖北省', '湖南省', '广东省',
|
||||
'海南省', '四川省', '贵州省', '云南省', '陕西省',
|
||||
'甘肃省', '青海省', '台湾省',
|
||||
# 自治区
|
||||
'内蒙古自治区', '广西壮族自治区', '西藏自治区',
|
||||
'宁夏回族自治区', '新疆维吾尔自治区',
|
||||
# 特别行政区
|
||||
'香港特别行政区', '澳门特别行政区',
|
||||
]
|
||||
|
||||
def handle(self, *args, **options):
|
||||
created_count = 0
|
||||
skipped_count = 0
|
||||
|
||||
for province_name in self.PROVINCES:
|
||||
obj, created = Region.objects.get_or_create(
|
||||
name=province_name,
|
||||
level='province',
|
||||
parent=None,
|
||||
)
|
||||
if created:
|
||||
created_count += 1
|
||||
self.stdout.write(self.style.SUCCESS(f'✓ Created: {province_name}'))
|
||||
else:
|
||||
skipped_count += 1
|
||||
self.stdout.write(f'- Skipped (exists): {province_name}')
|
||||
|
||||
self.stdout.write(self.style.SUCCESS(
|
||||
f'\n✅ Done! Created: {created_count}, Skipped: {skipped_count}'
|
||||
))
|
||||
Reference in New Issue
Block a user