Skip to content

Commit

Permalink
feat(韭菜之家>数据中心): 新增牛熊风向标统计数据
Browse files Browse the repository at this point in the history
  • Loading branch information
giscafer committed Oct 1, 2021
1 parent 5d2bd88 commit 3eacb65
Show file tree
Hide file tree
Showing 25 changed files with 17,115 additions and 14,721 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ChangeLog

## [2.0.0]

feat: 韭菜之家> 数据统计>牛熊风向标

## [1.9.9]

fix: 修复雪球 cookie 问题
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ Leek box - VSCode can also see the real-time data of stock & fund, do the most u

</div>

**论坛**交流:[韭菜盒子社区](https://support.qq.com/products/302926)**电报群** [邀请链接](https://t.me/joinchat/VKxykRyeRNcibg7I-ykZMg) 和每个人一起沟通交流

## Table of contents

- [leek-fund(韭菜盒子)](#leek-fund韭菜盒子)
Expand Down Expand Up @@ -91,11 +89,6 @@ Leek box - VSCode can also see the real-time data of stock & fund, do the most u

<img width="300" alt="微信公众号" src="https://raw.sevencdn.com/LeekHub/leek-fund/master/screenshot/wechat-qr1.jpg">

其他交流方式:

- **论坛**交流:[韭菜盒子社区](https://support.qq.com/products/302926)
- **电报群** [邀请链接](https://t.me/joinchat/VKxykRyeRNcibg7I-ykZMg)

## 赞助支持一下!

[Buy me a coffee](https://github.com/giscafer/buy-me-a-coffee/blob/master/README.md)
Expand Down
22 changes: 22 additions & 0 deletions demo/iframe-test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>iframe dom 操作测试</title>
</head>
<body>
<script src="https://cdn.staticfile.org/jquery/2.0.0/jquery.min.js"></script>
<iframe
id="iframeWraper"
src="https://emdatah5.eastmoney.com/dc/nxfxb/index"
frameborder="0"
frameborder="0"
style="width: 100%; height: 900px"
></iframe>
<script>
$('#iframeWraper').contents().find('.common-header2');
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Leek box - VSCode can also see the real-time data of stock & fund, do the most u
[![Installs](https://img.shields.io/visual-studio-marketplace/i/giscafer.leek-fund.svg?style=for-the-badge)](https://marketplace.visualstudio.com/items?itemName=giscafer.leek-fund)
[![Rating](https://img.shields.io/visual-studio-marketplace/stars/giscafer.leek-fund.svg?style=for-the-badge)](https://marketplace.visualstudio.com/items?itemName=giscafer.leek-fund)

**论坛**交流:[韭菜盒子社区](https://support.qq.com/products/302926)**电报群:** [邀请链接](https://t.me/joinchat/VKxykRyeRNcibg7I-ykZMg) 和每个人一起沟通交流
<!-- **论坛**交流:[韭菜盒子社区](https://support.qq.com/products/302926),**电报群:** [邀请链接](https://t.me/joinchat/VKxykRyeRNcibg7I-ykZMg) 和每个人一起沟通交流 -->

## Table of contents

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "leek-fund",
"displayName": "韭菜盒子",
"description": "韭菜盒子,VSCode 里也可以看股票 & 基金实时数据,做最好用的投资插件",
"version": "1.9.9",
"version": "2.0.0",
"author": "giscafer <giscafer@outlook.com>",
"repository": {
"type": "git",
Expand Down
23,792 changes: 12,499 additions & 11,293 deletions src/data/fundSuggestData.ts

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion template-packages/leek-center/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"@ant-design/icons": "^4.3.0",
"@ant-design/pro-card": "1.14.4",
"@babel/core": "7.12.3",
"@pmmmwh/react-refresh-webpack-plugin": "0.4.2",
"@svgr/webpack": "5.4.0",
Expand All @@ -17,13 +18,14 @@
"@types/react-router-dom": "^5.1.7",
"@typescript-eslint/eslint-plugin": "^4.5.0",
"@typescript-eslint/parser": "^4.5.0",
"antd": "^4.10.0",
"antd": "4.14.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.0",
"babel-loader": "8.1.0",
"babel-plugin-named-asset-import": "^0.3.7",
"babel-preset-react-app": "^10.0.0",
"bfj": "^7.0.2",
"bizcharts": "^4.1.12",
"camelcase": "^6.1.0",
"case-sensitive-paths-webpack-plugin": "2.3.0",
"css-loader": "4.3.0",
Expand Down Expand Up @@ -62,6 +64,7 @@
"postcss-preset-env": "6.7.0",
"postcss-safe-parser": "5.0.2",
"prompts": "2.4.0",
"rc-resize-observer": "^1.0.1",
"react": "^17.0.1",
"react-app-polyfill": "^2.0.0",
"react-dev-utils": "^11.0.1",
Expand Down
4 changes: 2 additions & 2 deletions template-packages/leek-center/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ function App() {
{routes.map((routeConfig) => (
<Route
key={
Array.isArray(routeConfig.path)
(Array.isArray(routeConfig.path)
? routeConfig.path.join(',')
: routeConfig.path
: routeConfig.path) as any
}
{...routeConfig}
></Route>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function FlashNewsList({
const newsList = store.news.newsList.filter((news) =>
filterNews(newsFilter, news)
);
console.log('newsList: ', newsList);
// console.log('newsList: ', newsList);
if (!newsList.length) {
return (
<div style={{ padding: '100px 0' }} className="empty">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ export default function LFooter() {
align="end"
split={<Divider type="vertical" />}
>
<Button
{/* <Button
onClick={() => {
postMessage('executeCommand', 'leek-fund.tucaoForum');
}}
type="link"
>
韭菜盒子社区
</Button>
</Button> */}
<Button
onClick={() => {
postMessage('executeCommand', 'leek-fund.viewFundFlow');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.stock-info {
&-panel {
padding: 8px 12px;
color: var(--vscode-foreground, #ccc);
}
&-header {
&__hd {
Expand Down Expand Up @@ -62,7 +63,7 @@

@keyframes current-price-show {
0% {
opacity: .3;
opacity: 0.3;
}
100% {
opacity: 1;
Expand Down
3 changes: 2 additions & 1 deletion template-packages/leek-center/src/router-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import MyStock from '@/view/my-stocks';
import DataCenter from '@/view/DataCenter';
import DataCenter from '@/view/data-center';
import FlashNewsView from '@/view/flash-news';
import { RouteProps } from 'react-router-dom';

Expand All @@ -13,6 +13,7 @@ const routes: RouteProps[] = [
path: '/data-center',
component: DataCenter,
},

{
path: '/news',
component: FlashNewsView,
Expand Down
1 change: 1 addition & 0 deletions template-packages/leek-center/src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const formatNumber = (

export async function fetchTryHandler<S>(fn: (...args: any[]) => Promise<S>, ...args: any[]) {
let result: S | undefined = void 0;

try {
if (!fn) return result;
result = await fn.apply(void 0, args);
Expand Down
3 changes: 0 additions & 3 deletions template-packages/leek-center/src/view/DataCenter.tsx

This file was deleted.

51 changes: 51 additions & 0 deletions template-packages/leek-center/src/view/data-center/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Layout, Menu } from 'antd';
import { ReactElement } from 'react';
import { Link, Route, Switch, Redirect } from 'react-router-dom';
import NxfxbPage from './nxfxb';
import OtherPage from './other';
const { Content, Sider } = Layout;

export default function DataCenter({ children }: { children: ReactElement }) {
return (
<Layout>
<Sider
style={{
overflow: 'auto',
height: 'calc(100vh - 86px)',
position: 'fixed',
left: 0,
}}
>
<Menu
theme="dark"
style={{
height: 'calc(100vh - 86px)',
}}
>
<Menu.Item key="nxfxb">
<Link to="/data-center/nxfxb">牛熊风向标</Link>
</Menu.Item>
<Menu.Item key="other">
<Link to="/data-center/other">欢迎PR</Link>
</Menu.Item>
</Menu>
</Sider>
<Content
id="flashNewsContent"
style={{
height: 'calc(100vh - 86px)',
position: 'fixed',
left: 220,
width: 'calc(100vw - 220px)',
overflowY: 'auto',
}}
>
<Switch>
<Route exact path="/data-center/nxfxb" component={NxfxbPage} />
<Route exact path="/data-center/other" component={OtherPage} />
<Redirect from="/data-center" to="/data-center/nxfxb"></Redirect>
</Switch>
</Content>
</Layout>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import {
Annotation,
Axis,
Chart,
Interaction,
Interval,
Legend,
Tooltip,
} from 'bizcharts';
import { useMemo } from 'react';

function dataConvert(obj: any = {}) {
return [
{ type: '涨停', value: obj.t, marked: false },
{ type: '涨停~5%', value: obj.rp10, marked: false },
{ type: '5%~1%', value: obj.rp5, marked: false },
{ type: '1%~0%', value: obj.rp01, marked: false },
{ type: '平盘', value: obj.rp0, marked: true },
{ type: '0%~-1%', value: obj.rn01, marked: true },
{ type: '-1%~-5%', value: obj.rn1, marked: true },
{ type: '-5%~跌停', value: obj.rn5, marked: true },
{ type: '跌停', value: obj.b, marked: true },
];
}

const scale = {
value: {
alias: '涨跌分布统计',
nice: true,
formatter: (val: string) => {
return `${val} 家`;
},
},
};

const axisCfg = {
axis: false,
title: {
style: {
fontSize: '14',
fill: '#ff5957',
fontWeight: 'bold',
},
},
};

function UpDownChart({ data }: { data: Record<string, any> }) {
const barData = useMemo(() => {
return dataConvert(data);
}, [data]);
return (
<Chart padding={[60]} autoFit height={400} data={barData} scale={scale}>
<Axis name="type" />
<Axis name="value" {...(axisCfg as any)} visible={false} line={false} />
<Interaction type="active-region" />

<Tooltip showCrosshairs showMarkers={false} />
<Interval
position="type*value"
color={[
'type*value*marked',
(type: number, value: number | string, marked: boolean) => {
return marked ? '#36c361' : '#ff5957';
},
]}
label={[
'type*value',
(type: number, value: any) => {
return {
style: { color: '#fff' },
content: (originData: any) => {
/* if (originData.type === '涨停') {
return null;
} */
return `${value} 家`;
},
};
},
]}
/>
<Legend visible={false} />
{/* <Annotation.DataMarker {...(dataMarkerCfg as any)} /> */}
</Chart>
);
}

export default UpDownChart;
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React, { useMemo } from 'react';
import { Statistic, StatisticCard } from '@ant-design/pro-card';
import { omit, pick, sum } from 'lodash';

const { Divider } = StatisticCard;

const UpDownStatistic = ({ data = {} }: { data: Record<string, any> }) => {
const total = useMemo(() => {
return sum(Object.values(pick(data, ['up', 'down', 'r0'])));
}, [data]);
return (
<StatisticCard.Group>
<StatisticCard
statistic={{
title: '全部',
tip: '当天开盘上市公司数量',
value: total,
}}
/>
<Divider />
<StatisticCard
statistic={{
title: '上涨',
value: data?.up,
valueStyle: { color: '#f22323' },
}}
/>
<StatisticCard
statistic={{
title: '涨停',
value: data?.t,
valueStyle: { color: '#f22323' },
description: (
<Statistic title="自然涨停" value={data?.tn} trend="up" />
),
}}
/>
<StatisticCard
statistic={{
title: '下跌',
value: data?.down,
suffix: '',
valueStyle: { color: '#00A000' },
}}
/>
<StatisticCard
statistic={{
title: '跌停',
value: data?.b,
suffix: '',
valueStyle: { color: '#00A000' },
}}
/>
</StatisticCard.Group>
);
};

export default UpDownStatistic;
Loading

0 comments on commit 3eacb65

Please sign in to comment.