Skip to content

Commit a93d7ed

Browse files
- 海外基金NaN问题优化
- 新增基金详情 ( 未输入份额时,enter 打开基金详情,基金详情,enter 关闭, ← → 切换导航,↑ ↓ 切换基金 )
1 parent dadb6a2 commit a93d7ed

File tree

8 files changed

+32
-27
lines changed

8 files changed

+32
-27
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
- 自选基金助手,数据来源于天天基金
44
- 支持新增删除自选基金,可填入持有份额,实时计算当天收益
5+
- 我的自选基金页面 => ctrl + insert 跳转添加基金页,可根据拼音,中文,基金代码等搜索
6+
- 我的自选基金页面 => 输入份额,选择基金,enter 保存
7+
- 我的自选基金页面 => ctrl + delete 删除选中的基金
8+
- 我的自选基金页面 => 未输入份额时,enter 打开基金详情
9+
- 基金详情页面 => enter 关闭, ← → 切换导航,↑ ↓ 切换基金
510

611
#### 源码
712

@@ -15,9 +20,10 @@
1520

1621
![Instructions.gif](https://s1.ax1x.com/2020/08/19/dQ8R3t.gif)
1722

18-
### v1.7.0
23+
### v1.7.1
1924

20-
- 新增历史净值,持仓明细等(未输入份额时,enter打开基金详情)
25+
- 海外基金NaN问题优化
26+
- 新增基金详情 ( 未输入份额时,enter 打开基金详情,基金详情,enter 关闭, ← → 切换导航,↑ ↓ 切换基金 )
2127

2228
### v1.6.2
2329

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "utools-fund",
3-
"version": "1.7.0",
3+
"version": "1.7.1",
44
"description": "自选基金助手",
55
"main": "main.ts",
66
"scripts": {
54.6 KB
Binary file not shown.
27.5 KB
Binary file not shown.

src/assets/html/fundDetail/fundDetail.css

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/html/fundDetail/fundDetail.html

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,6 @@
4444

4545
<body style="margin:0">
4646
<div id="app"></div>
47-
<script src="../../js/mousetrap.min.js"></script>
48-
<script>
49-
(function () {
50-
Mousetrap.bind('enter', () => {
51-
window.close();
52-
});
53-
})();
54-
</script>
5547
<script src="fundDetail.js"></script>
5648
</body>
5749

src/assets/html/fundDetail/fundDetail.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/features/fundMy.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const getMyFundDetails = async () => {
2929
return;
3030
}
3131
let lastTime = fundValuationDetail.Expansion.GZTIME;
32-
let nowJJJZ = Number(fundValuationDetail.Expansion.GZ);
32+
let nowJJJZ = Number(fundValuationDetail.Expansion.GZ || '0');
3333
let isValuation = true;
3434
const searchFundResult = await get<ISearchFundResult>(`http://fundsuggest.eastmoney.com/FundSearch/api/FundSearchAPI.ashx?m=1&key=${oldData.id}`);
3535
if (searchFundResult.ErrCode !== 0) {
@@ -43,14 +43,14 @@ const getMyFundDetails = async () => {
4343
if (lastTime.includes(searchFundDetail.FundBaseInfo.FSRQ)) {
4444
// console.log(`净值:`, searchFundDetail.FundBaseInfo);
4545
lastTime = searchFundDetail.FundBaseInfo.FSRQ;
46-
nowJJJZ = Number(searchFundDetail.FundBaseInfo.DWJZ);
46+
nowJJJZ = Number(searchFundDetail.FundBaseInfo.DWJZ || '0');
4747
isValuation = false;
4848
}
4949
}
5050
db.data = {
5151
...oldData,
52-
yesJJJZ: Number(fundValuationDetail.Expansion.DWJZ),
53-
nowJJJZ: Number(nowJJJZ),
52+
yesJJJZ: Number(fundValuationDetail.Expansion.DWJZ || '0'),
53+
nowJJJZ: Number(nowJJJZ || '0'),
5454
lastTime,
5555
isValuation,
5656
};
@@ -70,7 +70,7 @@ const fundDetailsToCbList = (dbList: DBItem<IFundEnt>[], searchWord = '') => {
7070
let sumIncome = 0;
7171
let cbList = dbList.map(db => {
7272
const fund = db.data;
73-
const rate = fund.nowJJJZ / fund.yesJJJZ - 1;
73+
const rate = fund.yesJJJZ === 0 ? 0 : fund.nowJJJZ / fund.yesJJJZ - 1;
7474
const income = fund.holdCount > 0 ? rate * fund.holdCount * fund.yesJJJZ : 0;
7575
sumIncome += Math.round(income * 100) / 100;
7676
const cb: CallbackListItem = {
@@ -190,9 +190,15 @@ const unregisterShortCut = async () => {
190190
// Mousetrap.unbind(['up', 'down', 'mod+del', 'mod+ins']);
191191
};
192192
const showFundDetail = async (fundEnt: Partial<IFundEnt>) => {
193-
const fundCode = fundEnt.id;
194-
const fundName = fundEnt.name;
195-
const url = `/assets/html/fundDetail/fundDetail.html?fundCode=${fundCode}&fundName=${encodeURIComponent(fundName)}`;
193+
const dbList = FundDBHelper.getAll();
194+
const fundList = dbList.map(db => {
195+
return {
196+
fundcode: db.data.id,
197+
name: db.data.name,
198+
};
199+
});
200+
const fundIndex = fundList.findIndex(x => x.fundcode === fundEnt.id);
201+
const url = `/assets/html/fundDetail/fundDetail.html?fundList=${encodeURIComponent(JSON.stringify(fundList))}&fundIndex=${fundIndex}`;
196202
// const title = `${fundName}(${fundCode})`;
197203
const fundDetailUbWindow = utools.createBrowserWindow(
198204
url,

0 commit comments

Comments
 (0)