Skip to content

Commit

Permalink
feat: 右键菜单查看基金持仓信息
Browse files Browse the repository at this point in the history
  • Loading branch information
giscafer committed Aug 15, 2020
1 parent 2fb69b4 commit 7ce50bf
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 18 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# leek-fund

VSCode 插件,在编码的时候随时关注实时股票&基金数据。因接口原因基金数据延迟 `2 分钟` 左右,股票数据是实时
**韭菜盒子**——VSCode 里也可以看股票 & 基金实时数据,做最好用的养基插件

:bangbang: 插件由原来的 “韭菜基金” 改名为 **韭菜盒子**
> 投资其实就是一次心态修炼,稳住心态长期投资都会有收益的!!
安装插件:[VisualStudio | Marketplace](https://marketplace.visualstudio.com/items?itemName=giscafer.leek-fund),VSCode 最低版本要求:`v1.40.0+`

**投资其实就是一次心态修炼,稳住心态长期投资都会有收益的!!**

## 功能介绍

- 基金涨跌
- 股票涨跌A 股、港股、美股)
- 基金涨跌(因接口原因基金数据延迟 `2 分钟` 左右)
- 股票涨跌,支持 A 股、港股、美股(实时数据
- 左侧菜单面板
- 底部状态 bar
- 底部状态栏信息
- 手动刷新
- 自动刷新(每天 9~15 点之间轮询刷新数据)
- 支持升序/降序排序
Expand Down
18 changes: 14 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "leek-fund",
"displayName": "韭菜盒子",
"description": "VSCode 插件(韭菜盒子,VSCode 里也可以看股票 & 基金实时数据",
"version": "1.2.2",
"description": "韭菜盒子,VSCode 里也可以看股票 & 基金实时数据,做最好用的养基插件",
"version": "1.2.3",
"author": "giscafer <giscafer@outlook.com>",
"repository": {
"type": "git",
Expand Down Expand Up @@ -66,7 +66,7 @@
},
{
"command": "fund.trend",
"title": "基金走势图",
"title": "基金走势一览",
"icon": {
"light": "resources/light/trend.svg",
"dark": "resources/dark/trend.svg"
Expand All @@ -92,6 +92,10 @@
"command": "fund.delete",
"title": "删除基金"
},
{
"command": "fund.history",
"title": "持仓信息&历史净值列表"
},
{
"command": "fund.refresh",
"title": "刷新数据",
Expand Down Expand Up @@ -173,9 +177,15 @@
}
],
"view/item/context": [
{
"command": "fund.history",
"when": "view == views.fund",
"group": "fundHistoryGroup"
},
{
"command": "fund.delete",
"when": "view == views.fund"
"when": "view == views.fund",
"group": "fundDelGroup"
},
{
"command": "stock.delete",
Expand Down
69 changes: 62 additions & 7 deletions src/registerEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,9 @@ export function registerViewEvent(
commands.registerCommand(
'leetfund.fundItemClick',
async (code, name, text) => {
const res = await service.getFundHistoryByCode(code);
// 创建webview
const panel = window.createWebviewPanel(
'fundWebview',
'fundWebview.trend',
name,
ViewColumn.One,
{
Expand Down Expand Up @@ -228,6 +227,7 @@ export function registerViewEvent(
}
.fund-sstrend{
width:700px;
background: #f1f0f0;
}
</style>
<body>
Expand All @@ -238,11 +238,12 @@ export function registerViewEvent(
src="http://j4.dfcfw.com/charts/pic6/${code}.png?v=${new Date().getTime()}"
alt=""
/>
</div>
<div class="history">
<p style="text-align: center; font-size:18px; width: 400px;margin: 0 auto;">「${name}」历史净值</p>
<hr />
${res.content}
<p class="title" style="text-align: center; font-size:18px; width: 400px;margin: 20px auto;">历史趋势图</p>
<img
class="fund-sstrend"
src="https://image.sinajs.cn/newchart/v5/fund/nav/ss/${code}.gif"
alt=""
/>
</div>
<script>
var sstrendImgEl = document.querySelector('.fund-sstrend');
Expand All @@ -265,6 +266,60 @@ export function registerViewEvent(
}
)
);
// 基金右键历史信息点击
context.subscriptions.push(
commands.registerCommand('fund.history', async (item) => {
const { code, name } = item.info;
const res = await service.getFundHistoryByCode(code);
// 创建webview
const panel = window.createWebviewPanel(
'fundWebview.history',
name,
ViewColumn.One,
{
enableScripts: true, // 启用JS,默认禁用
}
);
panel.webview.html = `<html>
<style>
.lsjz{
width: 100%;
min-width:600px;
text-align: center;
}
.red{
color:red;
}
.grn{
color:green;
}
.history{padding: 32px 24px;}
.trend{
width: 700px;
margin: 10px auto;
text-align: center;
}
.fund-sstrend{
width:700px;
}
</style>
<body>
<br/>
<p style="text-align: center; font-size:18px; width: 400px;margin: 0 auto;">「${name}」持仓信息</p>
<div class="trend"><img
class="fund-sstrend"
src="http://j6.dfcfw.com/charts/StockPos/${code}.png?rt=${new Date().getTime()}"
alt="「${name}」- ${code}"
/>
</div>
<div class="history">
<p style="text-align: center; font-size:18px; width: 400px;margin: 0 auto;">「${name}」历史净值</p>
<hr />
${res.content}
</div>
</body></html>`;
})
);

commands.registerCommand('fund.rank', async () => {
const list = await service.getRankFund();
Expand Down

0 comments on commit 7ce50bf

Please sign in to comment.