refactor: 前端库清理、页面废弃、DB→API 数据源替换
- 删除重复库文件:lib/DataTables-2/、lib/echarts/、libai/、css/fontawesome/ 等 179 个冗余文件 - 下载外部 CDN 到本地:Mermaid、AOS、Google Fonts(Inter/Noto Serif SC/Noto Sans SC) - 所有第三方库统一到 lib/,按库名-版本号命名 - 更新 8 个 research HTML 文件引用路径 - stock_his_pro → /api/stockbasic/(getStockHist、recentPrice) - stock_all_pro → /api/stockinfo/(tscodeToName) - index_hist_pro → /api/indexDatas/(getIndexData) - 新增 callDoorcomeApi() 共享函数 - 被替换表的 DB 查询代码完全删除,无回退 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+13
-26
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
include_once __DIR__."/config.php";
|
||||
include_once __DIR__."/functions.inc.php";
|
||||
/*
|
||||
上证指数:000001.SH
|
||||
深证成指:399001.SZ
|
||||
@@ -7,35 +8,21 @@ include_once __DIR__."/config.php";
|
||||
创业板指:399006.SZ
|
||||
*/
|
||||
function getIndexData($ts_code,$day_st,$day_end){
|
||||
$mysqli = get_mysqli_connection();
|
||||
|
||||
$sql = "select trade_date, close from index_hist_pro where ts_code = ? and trade_date >= ?";
|
||||
$params = [$ts_code, $day_st];
|
||||
if($day_end) {
|
||||
$sql .= " and trade_date <= ?";
|
||||
$params[] = $day_end;
|
||||
}
|
||||
$sql .= " order by trade_date asc";
|
||||
$result = db_query($mysqli, $sql, $params);
|
||||
|
||||
$tDate=$idx=$data=array();
|
||||
|
||||
if($result && $result->num_rows>0) {
|
||||
#$data = $result->fetch_all();
|
||||
while($row=$result->fetch_assoc()){
|
||||
$trade_date=substr($row['trade_date'],0,4).'-'.substr($row['trade_date'],4,2).'-'.substr($row['trade_date'],6,2);
|
||||
$trade_date1=strtotime($row['trade_date']);
|
||||
array_push($tDate,$trade_date);
|
||||
array_push($idx,$row['close']);
|
||||
array_push($data,array("value"=>array($trade_date,round($row['close'],2))));
|
||||
$tDate=$idx=$data=array();
|
||||
$ds = preg_replace('/\D/', '', $day_st);
|
||||
$de = $day_end ? preg_replace('/\D/', '', $day_end) : date('Ymd');
|
||||
$resp = callDoorcomeApi('indexDatas', ['tscode' => $ts_code, 'start_date' => $ds, 'end_date' => $de]);
|
||||
if ($resp && is_array($resp)) {
|
||||
foreach ($resp as $row) {
|
||||
$d = substr($row['trade_date'],0,4).'-'.substr($row['trade_date'],4,2).'-'.substr($row['trade_date'],6,2);
|
||||
array_push($tDate, $d);
|
||||
array_push($idx, $row['close']);
|
||||
array_push($data, ["value" => [$d, round($row['close'], 2)]]);
|
||||
}
|
||||
}
|
||||
return array('tDate'=>$tDate,'idx'=>$idx,'data'=>$data);
|
||||
}
|
||||
#Free result and close connection.
|
||||
|
||||
$result->free();
|
||||
$mysqli->close();
|
||||
return array('tDate'=>$tDate,'idx'=>$idx,'data'=>$data);
|
||||
}
|
||||
/*
|
||||
#LX: 序号 1-6,分别代表基金,QFII, 社保,券商,保险,信托
|
||||
#share: vposition 市值 f10, sahreHDnum 股数 f9
|
||||
|
||||
Reference in New Issue
Block a user