refactor: 全面代码重构与项目结构整理

安全性:
- 所有SQL查询改用参数化查询(db_query),防止SQL注入
- TUSHARE_API_TOKEN集中到config.php常量,移除硬编码和多份拷贝
- getBasic.inc.php中$_REQUEST输出到JS时添加htmlspecialchars转义

代码组织:
- 21个页面文件移至charts/子目录,根目录仅保留入口文件
- ajax.inc.php拆分:esfTradeDaily/esfListDaily迁至getEstate.inc.php
- getBasic.inc.php拆分:HTML组件函数迁至新建的widgets.inc.php
- 前端依赖去重:移除lib/echarts.min.js、libai/3.4.16.js、research/js/3.4.16.js

规范化:
- AJAX响应格式统一为jsonResponse()标准封装
- 前端全局变量统一为window.chartConfig对象模式
- 修复PHP 8.4 Deprecated警告(getEstateData、getStockHistoryDataByTS参数顺序)
- html/head.php中jQuery/CSS路径改为绝对路径,修复charts/子目录加载问题

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
2026-05-26 08:20:33 +08:00
co-authored by Claude Code
parent 07da6a2ad4
commit 7e57cae242
49 changed files with 848 additions and 733 deletions
+10 -9
View File
@@ -1,3 +1,4 @@
var cfg = window.chartConfig;
// ajax with adj set 1
$(function () {
jQuery.support.cors = true;
@@ -21,15 +22,15 @@ $(function () {
console.log("Get data sucessfully");
var adj = getAdj(data);
//console.log(adj);
console.log(data1[0]['value'][0]);
console.log(data1[0]['value'][1]);
data1 = adjData(adj,data1,'price');
data2 = adjData(adj,data2,'price');
data3 = adjData(adj,data3,'price');
data4 = adjData(adj,data4,'volum');
data5 = adjData(adj,data5,'volum');
console.log(data1[0]['value'][0]);
console.log(data1[0]['value'][1]);
console.log(cfg.data[0]['value'][0]);
console.log(cfg.data[0]['value'][1]);
cfg.data = adjData(adj,cfg.data,'price');
cfg.data2 = adjData(adj,cfg.data2,'price');
cfg.data3 = adjData(adj,cfg.data3,'price');
cfg.data4 = adjData(adj,cfg.data4,'volum');
cfg.data5 = adjData(adj,cfg.data5,'volum');
console.log(cfg.data[0]['value'][0]);
console.log(cfg.data[0]['value'][1]);
//重新执行画图
if (option && typeof option === "object") {
myChart.setOption(option, true);
+11 -10
View File
@@ -1,3 +1,4 @@
var cfg = window.chartConfig;
$(function (){
var dom = document.getElementById("container");
var myChart = echarts.init(dom,'dark');
@@ -5,9 +6,9 @@ $(function (){
var option = null;
option = {
title: {
//text: legend[0]+' V.S '+legend[2],
text: headtxt,
subtext: subtxt,
//text: cfg.legend[0]+' V.S '+cfg.legend[2],
text: cfg.title,
subtext: cfg.subtitle,
textAlign:'center',
left:'50%'
},
@@ -15,7 +16,7 @@ $(function (){
trigger: 'axis'
},
legend: {
data:legend,
data: cfg.legend,
right:'20'
},
grid: {
@@ -36,12 +37,12 @@ $(function (){
},
yAxis: [{
type: 'value',
name:legend[0], //图列
name: cfg.legend[0], //图列
show:true
},
{
type:'value',
name:legend[2]+unit, //图例
name: cfg.legend[2]+cfg.unit, //图例
//scale:true,
boundaryGap:false,
show:true,
@@ -69,19 +70,19 @@ $(function (){
}],
series: [
{
name:legend[0],
name: cfg.legend[0],
type:'line',
yAxisIndex:0,
symbol:'none',
data:data1
data: cfg.data
},
{
name:legend[2],
name: cfg.legend[2],
type:'line',
yAxisIndex:1,
symbol:'none', //数据圆点
smooth:false,
data: data2
data: cfg.data2
}
]
};
+20 -19
View File
@@ -1,15 +1,16 @@
var cfg = window.chartConfig;
var dom = document.getElementById("container");
var myChart = echarts.init(dom,'dark'); //内置主题:dark, grey,bright,light
var app = {};
option = null;
console.log(data1[0]['value'][0]);
console.log(data1[0]['value'][1]);
console.log(cfg.data[0]['value'][0]);
console.log(cfg.data[0]['value'][1]);
option = {
//backgroundColor: '',
title: {
//text: legend[0]+' V.S '+legend[2],
text: headtxt,
subtext: subtxt,
//text: cfg.legend[0]+' V.S '+cfg.legend[2],
text: cfg.title,
subtext: cfg.subtitle,
textAlign:'center',
left:'50%'
},
@@ -18,11 +19,11 @@ option = {
},
legend: [
{
data:[legend[0],legend[1],legend[2]],
data: [cfg.legend[0],cfg.legend[1],cfg.legend[2]],
right:'50',
},
{
data:[legend[3],legend[4]],
data: [cfg.legend[3],cfg.legend[4]],
right:'100',
top:'30',
},
@@ -45,13 +46,13 @@ option = {
},
yAxis: [{
type: 'value',
name:legend[0], //图列
name:cfg.legend[0], //图列
show:true,
scale:true,
},
{
type:'value',
name:unit, //图例
name: cfg.unit, //图例
scale:true, //自动缩放
boundaryGap:false,
show:true,
@@ -85,47 +86,47 @@ option = {
}],
series: [
{
name:legend[0],
name:cfg.legend[0],
type:'line',
yAxisIndex:0,
symbol:'none',
smooth:false,
data: data1,
data: cfg.data,
},
{
name:legend[1],
name:cfg.legend[1],
type:'scatter', //散点图
yAxisIndex:0,
symbolSize: 10,
smooth:false,
data: data2,
data: cfg.data2,
},
{
name:legend[2],
name:cfg.legend[2],
type:'scatter', //散点图
yAxisIndex:0,
symbolSize: 10,
smooth:false,
data: data3
data: cfg.data3
},
{
name:legend[3],
name:cfg.legend[3],
type:'bar',
yAxisIndex:1,
symbolSize: 0,
barWidth: 1,
smooth:false,
data: data4,
data: cfg.data4,
},
{
name:legend[4],
name:cfg.legend[4],
type:'bar',
yAxisIndex:1,
symbolSize: 0,
barWidth: 1,
smooth:false,
data: data5,
data: cfg.data5,
}
]
};
+6 -5
View File
@@ -1,3 +1,4 @@
var cfg = window.chartConfig;
var dom = document.getElementById("container");
var myChart = echarts.init(dom,'dark');
var app = {};
@@ -6,8 +7,8 @@ option = null;
option = {
title: {
//text: legend[0]+' V.S '+legend[2],
text: headtxt,
subtext: subtxt,
text: cfg.title,
subtext: cfg.subtitle,
textAlign:'center',
left:'50%'
},
@@ -15,7 +16,7 @@ option = {
trigger: 'axis'
},
legend: {
data:legend,
data: cfg.legend,
right:'20'
},
grid: {
@@ -74,7 +75,7 @@ option = {
type:'line',
yAxisIndex:0,
symbol:'none',
data:data1,
data: cfg.data,
},
{
name:legend[1],
@@ -82,7 +83,7 @@ option = {
yAxisIndex:1,
symbol:'none', //数据圆点
smooth:false,
data:data2,
data: cfg.data2,
}
]
};
+7 -6
View File
@@ -1,3 +1,4 @@
var cfg = window.chartConfig;
var dom = document.getElementById("container");
var myChart = echarts.init(dom,'dark');
var app = {};
@@ -5,8 +6,8 @@ option = null;
option = {
title: {
//text: legend[0]+' V.S '+legend[2],
text: headtxt,
//text: cfg.legend[0]+' V.S '+cfg.legend[2],
text: cfg.title,
//subtext: subtxt,
textAlign:'center',
left:'50%'
@@ -15,7 +16,7 @@ option = {
trigger: 'axis'
},
legend: {
data:legend,
data:cfg.legend,
right:'20'
},
grid: {
@@ -36,7 +37,7 @@ option = {
},
yAxis: [{
type: 'value',
name:legend[0], //图列
name:cfg.legend[0], //图列
show:true,
scale:true,
//min:190000,
@@ -61,11 +62,11 @@ option = {
}],
series: [
{
name:legend[0],
name:cfg.legend[0],
type:'line',
yAxisIndex:0,
symbol:'none',
data:data1,
data:cfg.data,
itemStyle:{normal:{label:{show:true}}}, //显示数字
}
]