Skip to content

Commit

Permalink
feat(leektreeitem): 新增启用高亮选项
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzihao committed Mar 4, 2022
1 parent 918e0ba commit a755700
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions package.json
Expand Up @@ -600,6 +600,11 @@
"type": "boolean",
"default": false,
"description": "默认展开期货"
},
"leek-fund.enableHighlights": {
"type": "number",
"default": -1,
"description": "是否打开涨跌高亮(0关闭,1涨高亮,-1跌高亮)"
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions src/extension.ts
Expand Up @@ -206,6 +206,8 @@ function setGlobalVariable() {

globalState.labelFormat = LeekFundConfig.getConfig('leek-fund.labelFormat');

globalState.enableHighlights = LeekFundConfig.getConfig('leek-fund.enableHighlights', -1);

globalState.immersiveBackground = LeekFundConfig.getConfig('leek-fund.immersiveBackground', true);
}

Expand Down
2 changes: 2 additions & 0 deletions src/globalState.ts
Expand Up @@ -18,6 +18,7 @@ let remindSwitch = 1; // 是否打开提示
let newsIntervalTime = 20000; // 新闻刷新频率(毫秒)
let newsIntervalTimer: NodeJS.Timer | any = null; // 计算器控制
let labelFormat = DEFAULT_LABEL_FORMAT;
let enableHighlights = -1; // 是否打开高亮

let aStockCount = 0;
let usStockCount = 0;
Expand Down Expand Up @@ -53,6 +54,7 @@ export default {
stocksRemind,
remindSwitch,
labelFormat,
enableHighlights,
showStockErrorInfo,
immersiveBackground,
isDevelopment,
Expand Down
9 changes: 8 additions & 1 deletion src/shared/leekTreeItem.ts
Expand Up @@ -163,7 +163,14 @@ export class LeekTreeItem extends TreeItem {
: `${formatTreeText(`${_percent}%`)}${code}」`;
}

this.label = grow ? { label: text, highlights: [[0, text.length]] } : text;
if (globalState.enableHighlights === 0) {
this.label = text;
} else if (globalState.enableHighlights >= 1) {
this.label = grow ? { label: text, highlights: [[0, text.length]] } : text;
} else if (globalState.enableHighlights <= -1) {
this.label = grow ? text : { label: text, highlights: [[0, text.length]] };
}

this.id = info.id || code;

if (this._itemType === TreeItemType.STOCK || this._itemType === TreeItemType.FUND) {
Expand Down

0 comments on commit a755700

Please sign in to comment.