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:
+20
-31
@@ -75,42 +75,31 @@ function ts_code_conv($ts_code){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getStockHist($ts_code,$day_st,$day_end){
|
||||
$mysqli = get_mysqli_connection();
|
||||
$sql = "select trade_date, close from stock_his_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,$row['trade_date']);
|
||||
array_push($idx,$row['close']);
|
||||
array_push($data,array("value"=>array($row['trade_date'],$row['close'])));
|
||||
$tDate=$idx=$data=array();
|
||||
$ds = preg_replace('/\D/', '', $day_st);
|
||||
$de = $day_end ? preg_replace('/\D/', '', $day_end) : date('Ymd');
|
||||
$resp = callDoorcomeApi('stockbasic', ['tscode' => $ts_code, 'start_date' => $ds, 'end_date' => $de]);
|
||||
if ($resp && is_array($resp)) {
|
||||
foreach ($resp as $row) {
|
||||
$d = $row['trade_date'];
|
||||
array_push($tDate, $d);
|
||||
array_push($idx, $row['close']);
|
||||
array_push($data, ["value" => [$d, $row['close']]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#Free result and close connection.
|
||||
$result->free();
|
||||
$mysqli->close();
|
||||
return array('tDate'=>$tDate,'idx'=>$idx,'data'=>$data);
|
||||
return array('tDate'=>$tDate,'idx'=>$idx,'data'=>$data);
|
||||
}
|
||||
|
||||
function tscodeToName($ts_code){
|
||||
$mysqli = get_mysqli_connection();
|
||||
$result = db_query($mysqli, "select name from stock_all_pro where ts_code = ?", [$ts_code]);
|
||||
if($result && $result->num_rows >0) $row = $result->fetch_assoc();
|
||||
$result->free();
|
||||
$mysqli->close();
|
||||
return $row['name'];
|
||||
$resp = callDoorcomeApi('stockinfo', ['tscode' => $ts_code]);
|
||||
if ($resp && isset($resp[0]['name'])) {
|
||||
return $resp[0]['name'];
|
||||
}
|
||||
return $ts_code;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getBasicExtData($ts_code,$item,$day_st,$day_end){
|
||||
|
||||
Reference in New Issue
Block a user