Skip to content

Commit

Permalink
大盘行情
Browse files Browse the repository at this point in the history
  • Loading branch information
adams549659584 committed Aug 17, 2020
1 parent cc3fcfc commit 954cbcc
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 6 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
- 自选基金助手,数据来源于天天基金
- 支持新增删除自选基金,可填入持有份额,实时计算当天收益


#### v1.2.0

- 新增大盘行情

#### v1.1.0

- 新增导入导出功能
Expand Down
18 changes: 12 additions & 6 deletions plugin.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
const pluginConfig = {
pluginName: '自选基金助手',
version: 'v1.1.0',
version: 'v1.2.0',
description: '自选基金助手',
author: '罗君',
homepage: 'https://github.com/adams549659584/utools-fund',
Expand All @@ -26,20 +26,26 @@ const pluginConfig = {
code: 'utools_fund_add',
explain: '添加自选基金',
icon: 'assets/img/add.png',
cmds: ['添加自选基金', '继续添加自选基金', '基金', 'fund']
cmds: ['添加自选基金', '继续添加自选基金', '基金', 'fund'],
},
{
code: 'utools_fund_del',
explain: '删除自选基金',
icon: 'assets/img/del.png',
cmds: ['删除自选基金', '继续删除自选基金', '基金', 'fund']
cmds: ['删除自选基金', '继续删除自选基金', '基金', 'fund'],
},
{
code: 'utools_fund_my',
explain: '我的自选基金',
icon: 'assets/img/logo.png',
cmds: ['我的自选基金', '基金', 'fund'],
},
{
code: 'utools_fund_market',
explain: '大盘行情',
icon: 'assets/img/market.png',
cmds: ['大盘行情', '基金', 'fund'],
},
{
code: 'utools_fund_config_export',
explain: '导出我的自选基金',
Expand All @@ -54,10 +60,10 @@ const pluginConfig = {
{
type: 'files',
label: '导入我的自选基金',
match: '/fund_data.json/'
}
match: '/fund_data.json/',
},
],
}
},
],
};
export default pluginConfig;
Binary file added src/assets/img/market.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,33 @@ const fundDetailsToCbList = (dbList: DBItem<IFundEnt>[]) => {
return cbList;
};

const getFundMarketIndexs = async (searchWord = '') => {
const marketResult = await get<{
data: {
total: number;
diff: {
f2: number;
f3: number;
f4: number;
f12: string;
f14: string;
}[];
};
}>(`https://push2.eastmoney.com/api/qt/ulist.np/get?fltt=2&fields=f2,f3,f4,f12,f14&secids=1.000001,1.000300,0.399001,0.399006&_=1597632105416`);
if (searchWord) {
marketResult.data.diff = marketResult.data.diff.filter(x => x.f12.includes(searchWord) || x.f14.includes(searchWord));
}
const cbList = marketResult.data.diff.map(x => {
const cb: CallbackListItem = {
title: x.f14,
description: `涨幅:${x.f3}% 最新:${x.f2}`,
icon: x.f3 >= 0 ? 'assets/img/up.png' : 'assets/img/down.png',
};
return cb;
});
return cbList;
};

const preload: TemplatePlugin = {
utools_fund_add: {
mode: 'list',
Expand Down Expand Up @@ -197,6 +224,20 @@ const preload: TemplatePlugin = {
},
},
},
utools_fund_market: {
mode: 'list',
args: {
placeholder: '大盘指数行情',
enter: async (action, callbackSetList) => {
const cbList = await getFundMarketIndexs();
callbackSetList(cbList);
},
search: async (action, searchWord, callbackSetList) => {
const cbList = await getFundMarketIndexs(searchWord);
callbackSetList(cbList);
},
},
},
utools_fund_config_export: {
mode: 'none',
args: {
Expand Down

0 comments on commit 954cbcc

Please sign in to comment.