Skip to content

Commit

Permalink
Merge pull request #162 from wujunchuan/master
Browse files Browse the repository at this point in the history
feat: 支持显示与隐藏状态栏
  • Loading branch information
giscafer committed Jan 17, 2021
2 parents 4d1ce0b + 43d897b commit 7609fa0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
6 changes: 6 additions & 0 deletions document.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@
// 配置股票跌的颜色,默认为 green
"leek-fund.fallColor": "black"
// 隐藏股市状态栏
"leek-fund.hideStatusBarStock": false
// 隐藏基金状态栏
"leek-fund.hideFundBarItem": false
```

## 状态栏、侧栏模板
Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,16 @@
"default": "#C9AD06",
"description": "股票跌的颜色"
},
"leek-fund.hideFundBarItem": {
"type": "boolean",
"default": false,
"description": "是否隐藏基金状态栏"
},
"leek-fund.hideStatusBarStock": {
"type": "boolean",
"default": false,
"description": "是否隐藏股票状态栏"
},
"leek-fund.newsUserIds": {
"type": "array",
"default": [
Expand Down
22 changes: 18 additions & 4 deletions src/statusbar/statusBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,21 @@ export class StatusBar {
get riseColor(): string {
return LeekFundConfig.getConfig('leek-fund.riseColor');
}

get fallColor(): string {
return LeekFundConfig.getConfig('leek-fund.fallColor');
}

/** 隐藏股市状态栏 */
get hideStatusBarStock(): boolean {
return LeekFundConfig.getConfig('leek-fund.hideStatusBarStock');
}

/** 隐藏基金状态栏 */
get hideFundBarItem(): boolean {
return LeekFundConfig.getConfig('leek-fund.hideFundBarItem');
}

bindEvents() {
events.on('stockListUpdate', () => {
this.refreshStockStatusBar();
Expand All @@ -48,7 +59,7 @@ export class StatusBar {
}

refreshStockStatusBar() {
if (!this.stockService.stockList.length) return;
if (this.hideStatusBarStock || !this.stockService.stockList.length) return;

let sz: LeekTreeItem | null = null;
const statusBarStocks = LeekFundConfig.getConfig('leek-fund.statusBarStock');
Expand Down Expand Up @@ -93,9 +104,8 @@ export class StatusBar {
}

udpateBarInfo(stockBarItem: StatusBarItem, item: LeekTreeItem | null) {
if (!item) {
return;
}
if (!item) return;

const { type, symbol, price, percent, open, yestclose, high, low, updown } = item.info;
const deLow = percent.indexOf('-') === -1;
/* stockBarItem.text = `「${this.stockService.showLabel ? item.info.name : item.id}」${price} ${
Expand All @@ -114,11 +124,15 @@ export class StatusBar {
command: 'leek-fund.changeStatusBarItem',
arguments: [item.id],
};

stockBarItem.show();
return stockBarItem;
}

refreshFundStatusBar() {
// 隐藏基金状态栏
if (this.hideFundBarItem) return;

this.fundBarItem.text = `🐥$(pulse)`;
this.fundBarItem.color = this.riseColor;
this.fundBarItem.tooltip = this.getFundTooltipText();
Expand Down

0 comments on commit 7609fa0

Please sign in to comment.