Skip to content

Commit

Permalink
Merge pull request #396 from James-chok/master
Browse files Browse the repository at this point in the history
fix(stock): 状态栏中的港股显示更新时间
  • Loading branch information
giscafer authored Aug 8, 2023
2 parents 02f91ec + e2b79ce commit a29eb7d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@
"iconv-lite": "^0.6.2",
"lodash.clonedeep": "^4.5.0",
"lodash.throttle": "^4.1.1",
"moment": "^2.29.4",
"public-ip": "^4.0.3",
"ws": "^7.4.1"
},
Expand Down
14 changes: 8 additions & 6 deletions src/explorer/stockService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { LeekTreeItem } from '../shared/leekTreeItem';
import { executeStocksRemind } from '../shared/remindNotification';
import { calcFixedPriceNumber, events, formatNumber, randHeader, sortData } from '../shared/utils';
import { LeekService } from './leekService';
import moment = require('moment');

export default class StockService extends LeekService {
public stockList: Array<LeekTreeItem> = [];
Expand Down Expand Up @@ -37,9 +38,9 @@ export default class StockService extends LeekService {

// 兼容2.1-2.5版本中以大写开头及cnf_开头的期货代码
const transFuture = (code: string) => {
if(/^[A-Z]+/.test(code)){
if (/^[A-Z]+/.test(code)) {
return code.replace(/^[A-Z]+/, (it: string) => `nf_${it}`);
} else if(/cnf_/.test(code)){
} else if (/cnf_/.test(code)) {
return code.replace('cnf_', 'nf_');
}
return code;
Expand Down Expand Up @@ -211,7 +212,7 @@ export default class StockService extends LeekService {
新浪接口对于商品期货的 昨收盘返回 0.0,导致无法计算【昨收盘涨跌幅】,只能计算【结算涨跌幅】。
使用期货的结算价对应 股票通用的 【昨收盘 yestclose】字段以方便计算涨跌幅的显示。
*/
let yestclose = params[8 + 2];
let yestclose = params[8 + 2];
let volume = params[8 + 6]; // 成交量
//股指期货
const stockIndexFuture = /nf_IC/.test(code) // 中证500
Expand All @@ -223,7 +224,7 @@ export default class StockService extends LeekService {
|| /nf_T\d+/.test(code) // 十债
|| /nf_TL/.test(code) // 三十年国债
;
if(stockIndexFuture){
if (stockIndexFuture) {
// 0 开盘 1 最高 2 最低 3 收盘
// ['5372.000', '5585.000', '5343.000', '5581.600',
// 4 成交量 6 持仓量
Expand Down Expand Up @@ -413,6 +414,7 @@ export default class StockService extends LeekService {
volume: formatNumber(quote.volume || 0, 2),
amount: formatNumber(quote.amount || 0, 2),
percent: '',
time: `${moment(quote.time).format('YYYY-MM-DD HH:mm:ss')}`,
};
hkStockCount += 1;
if (stockItem) {
Expand Down Expand Up @@ -495,9 +497,9 @@ export default class StockService extends LeekService {
let market = arr[1];
code = code.toUpperCase();
// 国内交易所
if(market === '85' || market === '88'){
if (market === '85' || market === '88') {
code = 'nf_' + code;
}else if(market === '86'){
} else if (market === '86') {
// 海外交易所
code = 'hf_' + code;
}
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2713,6 +2713,11 @@ modify-values@^1.0.0:
resolved "https://registry.npmjs.org/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022"
integrity sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw==

moment@^2.29.4:
version "2.29.4"
resolved "https://registry.npmmirror.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108"
integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==

[email protected]:
version "2.0.0"
resolved "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
Expand Down

0 comments on commit a29eb7d

Please sign in to comment.