解决Bug

This commit is contained in:
2026-02-11 01:19:50 +08:00
parent b6184b4fec
commit 50ddf01e7c
4 changed files with 1634 additions and 35 deletions

1363
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,24 +1,43 @@
<template>
<!-- 管理后台入口:直接加载 AdminLayout使用 CRMEB 内部路由系统 -->
<AdminLayout />
<view class="admin-home-page">
<AdminLayout>
<view class="home-content">
<text class="welcome-text">管理后台首页</text>
</view>
</AdminLayout>
</view>
</template>
<script setup lang="uts">
/**
* 管理后台入口页面
*
* 架构说明:
* 1. 此页面是 pages.json 中配置的主入口
* 2. 直接加载 AdminLayout 组件作为容器
* 3. AdminLayout 内部使用 CRMEB 路由系统管理所有子页面
* 4. 不需要额外的业务逻辑,保持简洁
*
* 路由流程:
* pages.json → homePage/index.uvue → AdminLayout → 内部路由切换
*/
import AdminLayout from '@/layouts/admin/AdminLayout.uvue'
import { ref } from 'vue'
import AdminLayout from '@/layouts/admin/AdminLayout'
const title = ref<string>('管理后台首页')
onLoad((options: OnLoadOptions) => {
console.log('首页加载完成')
})
onShow(() => {
console.log('首页显示')
})
</script>
<style scoped>
/* 无需额外样式,完全由 AdminLayout 控制布局 */
<style scoped lang="scss">
.admin-home-page {
width: 100%;
min-height: 100vh;
}
.home-content {
padding: 20px;
background-color: #f5f7fa;
}
.welcome-text {
font-size: 20px;
font-weight: 600;
color: #1a1a1a;
}
</style>

View File

@@ -31,6 +31,178 @@ const resizeObservers = new Map();
let chinaMapLoaded = false;
let chinaMapLoading = false;
// 内置的简化中国地图数据50个主要城市或地区的边界
const SIMPLIFIED_CHINA_MAP = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": { "name": "南海诸岛", "cp": [113.5439, 3.5951], "childNum": 0 },
"geometry": { "type": "MultiPolygon", "coordinates": [[[[113.5439, 3.5951], [113.5439, 3.5951]]]] }
},
{
"type": "Feature",
"properties": { "name": "北京", "cp": [116.4074, 39.9042], "childNum": 16 },
"geometry": { "type": "Polygon", "coordinates": [[[116, 39.5], [117, 39.5], [117, 40.5], [116, 40.5], [116, 39.5]]] }
},
{
"type": "Feature",
"properties": { "name": "天津", "cp": [117.2, 39.0842], "childNum": 16 },
"geometry": { "type": "Polygon", "coordinates": [[[116.7, 38.7], [117.7, 38.7], [117.7, 39.5], [116.7, 39.5], [116.7, 38.7]]] }
},
{
"type": "Feature",
"properties": { "name": "河北", "cp": [114.5149, 38.0428], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[113.5, 37.5], [119.5, 37.5], [119.5, 42.5], [113.5, 42.5], [113.5, 37.5]]] }
},
{
"type": "Feature",
"properties": { "name": "山西", "cp": [112.5489, 37.8739], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[110.5, 35], [114.5, 35], [114.5, 40.5], [110.5, 40.5], [110.5, 35]]] }
},
{
"type": "Feature",
"properties": { "name": "内蒙古", "cp": [111.7558, 40.8183], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[97, 37], [126, 37], [126, 54], [97, 54], [97, 37]]] }
},
{
"type": "Feature",
"properties": { "name": "辽宁", "cp": [123.4328, 41.8045], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[118.5, 40], [126.5, 40], [126.5, 45], [118.5, 45], [118.5, 40]]] }
},
{
"type": "Feature",
"properties": { "name": "吉林", "cp": [125.3235, 43.8957], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[121, 41.5], [130, 41.5], [130, 48.5], [121, 48.5], [121, 41.5]]] }
},
{
"type": "Feature",
"properties": { "name": "黑龙江", "cp": [126.6424, 45.7568], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[121, 43.5], [135, 43.5], [135, 55], [121, 55], [121, 43.5]]] }
},
{
"type": "Feature",
"properties": { "name": "上海", "cp": [121.4737, 31.2304], "childNum": 16 },
"geometry": { "type": "Polygon", "coordinates": [[[120.8, 30.7], [122, 30.7], [122, 31.9], [120.8, 31.9], [120.8, 30.7]]] }
},
{
"type": "Feature",
"properties": { "name": "江苏", "cp": [118.7969, 32.9387], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[118, 31], [122, 31], [122, 34.5], [118, 34.5], [118, 31]]] }
},
{
"type": "Feature",
"properties": { "name": "浙江", "cp": [120.1551, 30.2741], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[118.5, 28], [123, 28], [123, 31.5], [118.5, 31.5], [118.5, 28]]] }
},
{
"type": "Feature",
"properties": { "name": "安徽", "cp": [117.2272, 31.8654], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[114.5, 29.5], [119.5, 29.5], [119.5, 34.5], [114.5, 34.5], [114.5, 29.5]]] }
},
{
"type": "Feature",
"properties": { "name": "福建", "cp": [119.295492, 26.0745], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[118.5, 23.5], [121.5, 23.5], [121.5, 28], [118.5, 28], [118.5, 23.5]]] }
},
{
"type": "Feature",
"properties": { "name": "江西", "cp": [115.8581, 28.6832], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[113, 24], [118, 24], [118, 30], [113, 30], [113, 24]]] }
},
{
"type": "Feature",
"properties": { "name": "山东", "cp": [117.1205, 36.6519], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[114, 34.5], [122, 34.5], [122, 38], [114, 38], [114, 34.5]]] }
},
{
"type": "Feature",
"properties": { "name": "河南", "cp": [113.6254, 34.7466], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[111.5, 32], [117, 32], [117, 36.5], [111.5, 36.5], [111.5, 32]]] }
},
{
"type": "Feature",
"properties": { "name": "湖北", "cp": [114.3055, 30.5928], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[108, 28.5], [116, 28.5], [116, 33], [108, 33], [108, 28.5]]] }
},
{
"type": "Feature",
"properties": { "name": "湖南", "cp": [112.9388, 28.2282], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[108.5, 24.5], [114, 24.5], [114, 30], [108.5, 30], [108.5, 24.5]]] }
},
{
"type": "Feature",
"properties": { "name": "广东", "cp": [113.2644, 23.1291], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[112, 20.5], [116, 20.5], [116, 25], [112, 25], [112, 20.5]]] }
},
{
"type": "Feature",
"properties": { "name": "广西", "cp": [108.3661, 22.8170], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[104.5, 20.5], [112, 20.5], [112, 26.5], [104.5, 26.5], [104.5, 20.5]]] }
},
{
"type": "Feature",
"properties": { "name": "四川", "cp": [104.0665, 30.5702], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[100, 26], [108, 26], [108, 35], [100, 35], [100, 26]]] }
},
{
"type": "Feature",
"properties": { "name": "贵州", "cp": [106.7135, 26.5783], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[103.5, 24.5], [109.5, 24.5], [109.5, 29.5], [103.5, 29.5], [103.5, 24.5]]] }
},
{
"type": "Feature",
"properties": { "name": "云南", "cp": [102.7103, 24.8801], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[97.5, 21], [106.5, 21], [106.5, 30], [97.5, 30], [97.5, 21]]] }
},
{
"type": "Feature",
"properties": { "name": "陕西", "cp": [108.9402, 34.3416], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[105.5, 31.5], [111.5, 31.5], [111.5, 39], [105.5, 39], [105.5, 31.5]]] }
},
{
"type": "Feature",
"properties": { "name": "甘肃", "cp": [103.8343, 35.0080], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[92, 32], [108, 32], [108, 42], [92, 42], [92, 32]]] }
},
{
"type": "Feature",
"properties": { "name": "青海", "cp": [101.7782, 36.6171], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[89, 31.5], [104.5, 31.5], [104.5, 39.5], [89, 39.5], [89, 31.5]]] }
},
{
"type": "Feature",
"properties": { "name": "宁夏", "cp": [106.2586, 38.4680], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[104.5, 35.5], [107.5, 35.5], [107.5, 40], [104.5, 40], [104.5, 35.5]]] }
},
{
"type": "Feature",
"properties": { "name": "新疆", "cp": [87.6278, 43.7929], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[73, 26], [104, 26], [104, 49], [73, 49], [73, 26]]] }
},
{
"type": "Feature",
"properties": { "name": "西藏", "cp": [88.0959, 29.6470], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[78, 26], [99, 26], [99, 36.5], [78, 36.5], [78, 26]]] }
},
{
"type": "Feature",
"properties": { "name": "台湾", "cp": [120.9605, 23.6978], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[120.1, 22.5], [121.5, 22.5], [121.5, 25], [120.1, 25], [120.1, 22.5]]] }
},
{
"type": "Feature",
"properties": { "name": "香港", "cp": [114.1694, 22.3193], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[113.8, 22], [114.5, 22], [114.5, 22.6], [113.8, 22.6], [113.8, 22]]] }
},
{
"type": "Feature",
"properties": { "name": "澳门", "cp": [113.5439, 22.2987], "childNum": 0 },
"geometry": { "type": "Polygon", "coordinates": [[[113.3, 22.1], [113.7, 22.1], [113.7, 22.5], [113.3, 22.5], [113.3, 22.1]]] }
}
]
};
// 加载并注册中国地图
async function loadChinaMap() {
if (chinaMapLoaded) {
@@ -57,28 +229,63 @@ async function loadChinaMap() {
chinaMapLoading = true;
try {
// 从在线 CDN 加载中国地图 GeoJSON 数据
// 使用 ECharts 官方示例数据源
const response = await fetch('https://geo.datav.aliyun.com/areas_v3/bound/100000_full.json');
if (!response.ok) {
// 如果第一个源失败,尝试备用源
const backupResponse = await fetch('https://echarts.apache.org/examples/data/map/china.json');
if (!backupResponse.ok) {
throw new Error('Failed to load China map data');
// 首先尝试从在线 CDN 加载中国地图 GeoJSON 数据
let geoJson = null;
let loaded = false;
try {
const response = await fetch('https://geo.datav.aliyun.com/areas_v3/bound/100000_full.json', {
timeout: 5000
});
if (response.ok) {
geoJson = await response.json();
loaded = true;
console.log('[EChartsView] 从阿里云 CDN 加载中国地图数据成功');
}
const geoJson = await backupResponse.json();
echarts.registerMap('china', geoJson);
} else {
const geoJson = await response.json();
echarts.registerMap('china', geoJson);
} catch (e) {
console.warn('[EChartsView] 从阿里云 CDN 加载失败,尝试备用源...', e);
}
chinaMapLoaded = true;
console.log('[EChartsView] 中国地图数据已加载并注册');
// 如果第一个源失败,尝试备用源
if (!loaded) {
try {
const backupResponse = await fetch('https://echarts.apache.org/examples/data/map/china.json', {
timeout: 5000
});
if (backupResponse.ok) {
geoJson = await backupResponse.json();
loaded = true;
console.log('[EChartsView] 从 ECharts 官方源加载中国地图数据成功');
}
} catch (e) {
console.warn('[EChartsView] 从备用源加载也失败,使用内置简化地图', e);
}
}
// 如果网络加载都失败,使用内置的简化地图
if (!loaded) {
geoJson = SIMPLIFIED_CHINA_MAP;
console.log('[EChartsView] 使用内置简化中国地图数据');
}
// 注册地图
if (geoJson) {
echarts.registerMap('china', geoJson);
chinaMapLoaded = true;
console.log('[EChartsView] 中国地图数据已注册');
} else {
throw new Error('Failed to load or create China map data');
}
} catch (error) {
console.error('[EChartsView] 加载中国地图数据失败:', error);
// 即使加载失败,也标记为已尝试,避免重复请求
chinaMapLoaded = false;
// 降级方案:使用简化地图
try {
echarts.registerMap('china', SIMPLIFIED_CHINA_MAP);
chinaMapLoaded = true;
console.log('[EChartsView] 已使用内置简化地图作为降级方案');
} catch (furtherError) {
console.error('[EChartsView] 即使使用简化地图也失败:', furtherError);
}
} finally {
chinaMapLoading = false;
}

12
vite.config.js Normal file
View File

@@ -0,0 +1,12 @@
import { defineConfig } from 'vite'
import { fileURLToPath, URL } from 'node:url'
import uni from '@dcloudio/vite-plugin-uni'
export default defineConfig({
plugins: [uni()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./', import.meta.url))
}
}
})