update at 2026-02-13 22:45:23

This commit is contained in:
douboer@gmail.com
2026-02-13 22:45:23 +08:00
parent bf2930c4a5
commit ad9cf079b2
3 changed files with 375 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
当前目录已从骨架升级为可用版,支持以下能力:
- 顶部 Logo / 主题 / 上传 / 导出区域
- 启动默认加载:`data/sankey.xlsx`(位于小程序包内 `miniapp/data/sankey.xlsx`
- 启动默认加载:优先读取 `data/sankey.xlsx`(位于小程序包内 `miniapp/data/sankey.xlsx`,若开发者工具环境限制读取则自动回退到内置同内容 JSON
- 文件上传与解析:`csv / xls / xlsx`
- 默认列映射:
- 源数据列优先匹配 `data/value/数据/值`

View File

@@ -0,0 +1,349 @@
{
"headers": [
"source",
"target",
"value"
],
"rows": [
[
"Agricultural 'waste'",
"Bio-conversion",
"124.729"
],
[
"Bio-conversion",
"水电",
"0.597"
],
[
"Bio-conversion",
"Losses",
"26.862"
],
[
"Bio-conversion",
"Solid",
"280.322"
],
[
"Bio-conversion",
"汽油",
"81.144"
],
[
"Biofuel imports",
"水电",
"35"
],
[
"Biomass imports",
"Solid",
"35"
],
[
"Coal imports",
"Coal",
"11.606"
],
[
"Coal reserves",
"Coal",
"63.965"
],
[
"Coal",
"Solid",
"75.571"
],
[
"District heating",
"Industry",
"10.639"
],
[
"District heating",
"Heating and cooling - commercial",
"22.505"
],
[
"District heating",
"Heating and cooling - homes",
"46.184"
],
[
"Electricity grid",
"Over generation / exports",
"104.453"
],
[
"Electricity grid",
"Heating and cooling - homes",
"113.726"
],
[
"Electricity grid",
"H2 conversion",
"27.14"
],
[
"Electricity grid",
"Industry",
"342.165"
],
[
"Electricity grid",
"Road transport",
"37.797"
],
[
"Electricity grid",
"Agriculture",
"4.412"
],
[
"Electricity grid",
"Heating and cooling - commercial",
"40.858"
],
[
"Electricity grid",
"Losses",
"56.691"
],
[
"Electricity grid",
"Rail transport",
"7.863"
],
[
"Electricity grid",
"Lighting & appliances - commercial",
"90.008"
],
[
"Electricity grid",
"Lighting & appliances - homes",
"93.494"
],
[
"汽油 imports",
"N汽油",
"40.719"
],
[
"汽油 reserves",
"N汽油",
"82.233"
],
[
"汽油",
"Heating and cooling - commercial",
"0.129"
],
[
"汽油",
"Losses",
"1.401"
],
[
"汽油",
"Thermal generation",
"151.891"
],
[
"汽油",
"Agriculture",
"2.096"
],
[
"汽油",
"Industry",
"48.58"
],
[
"Geothermal",
"Electricity grid",
"7.013"
],
[
"H2 conversion",
"H2",
"20.897"
],
[
"H2 conversion",
"Losses",
"6.242"
],
[
"H2",
"Road transport",
"20.897"
],
[
"Hydro",
"Electricity grid",
"6.995"
],
[
"水电",
"Industry",
"121.066"
],
[
"水电",
"International shipping",
"128.69"
],
[
"水电",
"Road transport",
"135.835"
],
[
"水电",
"Domestic aviation",
"14.458"
],
[
"水电",
"International aviation",
"206.267"
],
[
"水电",
"Agriculture",
"3.64"
],
[
"水电",
"National navigation",
"33.218"
],
[
"水电",
"Rail transport",
"4.413"
],
[
"Marine algae",
"Bio-conversion",
"4.375"
],
[
"N汽油",
"汽油",
"122.952"
],
[
"Nuclear",
"Thermal generation",
"839.978"
],
[
"Oil imports",
"Oil",
"504.287"
],
[
"Oil reserves",
"Oil",
"107.703"
],
[
"Oil",
"水电",
"611.99"
],
[
"Other waste",
"Solid",
"56.587"
],
[
"Other waste",
"Bio-conversion",
"77.81"
],
[
"Pumped heat",
"Heating and cooling - homes",
"193.026"
],
[
"Pumped heat",
"Heating and cooling - commercial",
"70.672"
],
[
"太阳能 PV",
"Electricity grid",
"59.901"
],
[
"太阳能 Thermal",
"Heating and cooling - homes",
"19.263"
],
[
"太阳能",
"太阳能 Thermal",
"19.263"
],
[
"太阳能",
"太阳能 PV",
"59.901"
],
[
"Solid",
"Agriculture",
"0.882"
],
[
"Solid",
"Thermal generation",
"400.12"
],
[
"Solid",
"Industry",
"46.477"
],
[
"Thermal generation",
"Electricity grid",
"525.531"
],
[
"Thermal generation",
"Losses",
"787.129"
],
[
"Thermal generation",
"District heating",
"79.329"
],
[
"Tidal",
"Electricity grid",
"9.452"
],
[
"UK land based bioenergy",
"Bio-conversion",
"182.01"
],
[
"Wave",
"Electricity grid",
"19.013"
],
[
"Wind",
"Electricity grid",
"289.366"
]
]
}

View File

@@ -1,4 +1,5 @@
const { parseTableByFileName, buildSankeyData } = require('../../utils/sankey');
const defaultSankeyTable = require('../../data/sankey.default.json');
/**
* 将表头标准化,便于做中英文别名匹配。
@@ -130,7 +131,12 @@ const TARGET_ALIGN_OPTIONS = [
{ value: 'bottom', label: '底部' }
];
const DEFAULT_SANKEY_FILE_NAME = 'data/sankey.xlsx';
const DEFAULT_SANKEY_FILE_PATHS = ['/data/sankey.xlsx', 'data/sankey.xlsx'];
const DEFAULT_SANKEY_FILE_PATHS = [
'/data/sankey.xlsx',
'/miniapp/data/sankey.xlsx',
'data/sankey.xlsx',
'miniapp/data/sankey.xlsx'
];
/**
* 数值限制,避免 UI 参数导致布局异常。
@@ -658,16 +664,31 @@ Page({
*/
loadDefaultSankeyFile() {
const that = this;
const tryReadByIndex = (index, lastErrorMessage) => {
if (index >= DEFAULT_SANKEY_FILE_PATHS.length) {
const applyBuiltInTableFallback = (reasonText) => {
const hasRows =
defaultSankeyTable &&
Array.isArray(defaultSankeyTable.headers) &&
Array.isArray(defaultSankeyTable.rows) &&
defaultSankeyTable.rows.length > 0;
if (!hasRows) {
that.setData({
uploadMessage: '点击上传或将csv/xls文件拖到这里上传',
parseError: `默认文件加载失败: ${lastErrorMessage || `未找到 ${DEFAULT_SANKEY_FILE_NAME}`}`
parseError: `默认文件加载失败: ${reasonText || `未找到 ${DEFAULT_SANKEY_FILE_NAME}`}`
});
that.refreshInfoLogs();
return;
}
that.applyParsedTable(defaultSankeyTable, `${DEFAULT_SANKEY_FILE_NAME}(内置回退)`);
};
const tryReadByIndex = (index, lastErrorMessage) => {
if (index >= DEFAULT_SANKEY_FILE_PATHS.length) {
applyBuiltInTableFallback(lastErrorMessage);
return;
}
const candidatePath = DEFAULT_SANKEY_FILE_PATHS[index];
wx.getFileSystemManager().readFile({
filePath: candidatePath,