feat: fetchFundPingzhongdata 接口默认缓存时间一个小时
This commit is contained in:
@@ -307,7 +307,7 @@ export const fetchFundData = async (c) => {
|
|||||||
const holdingsPromise = new Promise((resolveH) => {
|
const holdingsPromise = new Promise((resolveH) => {
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const pz = await fetchFundPingzhongdata(c, { cacheTime: 10 * 60 * 1000 });
|
const pz = await fetchFundPingzhongdata(c);
|
||||||
const rawCodes = Array.isArray(pz?.stockCodes) ? pz.stockCodes : [];
|
const rawCodes = Array.isArray(pz?.stockCodes) ? pz.stockCodes : [];
|
||||||
const codes = rawCodes
|
const codes = rawCodes
|
||||||
.map((code) => String(code).slice(0, 6))
|
.map((code) => String(code).slice(0, 6))
|
||||||
@@ -624,7 +624,7 @@ const fetchAndParsePingzhongdata = async (fundCode) => {
|
|||||||
* 获取并解析「基金走势图/资产等」数据(pingzhongdata)
|
* 获取并解析「基金走势图/资产等」数据(pingzhongdata)
|
||||||
* 来源:https://fund.eastmoney.com/pingzhongdata/${fundCode}.js
|
* 来源:https://fund.eastmoney.com/pingzhongdata/${fundCode}.js
|
||||||
*/
|
*/
|
||||||
export const fetchFundPingzhongdata = async (fundCode, { cacheTime = 10 * 60 * 1000 } = {}) => {
|
export const fetchFundPingzhongdata = async (fundCode, { cacheTime = 60 * 60 * 1000 } = {}) => {
|
||||||
if (!fundCode) throw new Error('fundCode 不能为空');
|
if (!fundCode) throw new Error('fundCode 不能为空');
|
||||||
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
||||||
throw new Error('无浏览器环境');
|
throw new Error('无浏览器环境');
|
||||||
@@ -728,7 +728,7 @@ export const fetchFundHistory = async (code, range = '1m') => {
|
|||||||
|
|
||||||
// 业绩走势统一走 pingzhongdata.Data_netWorthTrend
|
// 业绩走势统一走 pingzhongdata.Data_netWorthTrend
|
||||||
try {
|
try {
|
||||||
const pz = await fetchFundPingzhongdata(code, { cacheTime: 10 * 60 * 1000 });
|
const pz = await fetchFundPingzhongdata(code);
|
||||||
const trend = pz?.Data_netWorthTrend;
|
const trend = pz?.Data_netWorthTrend;
|
||||||
if (Array.isArray(trend) && trend.length) {
|
if (Array.isArray(trend) && trend.length) {
|
||||||
const startMs = start.startOf('day').valueOf();
|
const startMs = start.startOf('day').valueOf();
|
||||||
|
|||||||
Reference in New Issue
Block a user