Skip to content

Commit

Permalink
feat: 韭菜中心新增主力资金流向、韭菜盒子社区入口
Browse files Browse the repository at this point in the history
  • Loading branch information
giscafer committed Jan 10, 2021
1 parent b008440 commit c1a6c24
Show file tree
Hide file tree
Showing 11 changed files with 162 additions and 85 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [1.9.1]

- feat: 状态栏新增基金收益统计
- feat: 韭菜中心新增主力资金流向、北向资金流向、韭菜盒子社区入口
- refactor: 资金流向页面重构,增强功能和交互入口

## [1.9.0]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@
},
{
"view": "leekFundView.settings",
"contents": "\n [🏠️ 韭菜之家](command:leek-fund.leekCenterView) \n [🌈个性化设置](command:leek-fund.customSetting)\n[🛠打开配置页](command:leek-fund.openConfigPage)\n[💰打赏作者@giscafer](command:leek-fund.donate)\n 欢迎使用韭菜盒子^_^,[使用手册](https://github.com/giscafer/leek-fund/issues/23);论坛[韭菜盒子社区](https://support.qq.com/products/302926),源码[Github](https://github.com/giscafer/leek-fund),加群交流[微信群](https://github.com/giscafer/leek-fund/issues/19), 电报群[Telegram](https://t.me/joinchat/VKxykRyeRNcibg7I-ykZMg)"
"contents": "\n [🏠️ 韭菜之家](command:leek-fund.leekCenterView) \n [🌈个性化设置](command:leek-fund.customSetting)\n[🛠打开配置页](command:leek-fund.openConfigPage)\n[💰打赏作者@giscafer](command:leek-fund.donate)\n 欢迎使用韭菜盒子^_^,[使用手册](https://github.com/giscafer/leek-fund/issues/23);论坛[韭菜盒子社区](command:leek-fund.tucaoForum),源码[Github](https://github.com/giscafer/leek-fund),加群交流[微信群](https://github.com/giscafer/leek-fund/issues/19), 电报群[Telegram](https://t.me/joinchat/VKxykRyeRNcibg7I-ykZMg)"
}
]
},
Expand Down
10 changes: 6 additions & 4 deletions src/registerCommand.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { commands, ExtensionContext, window } from 'vscode';
import fundSuggestList from './data/fundSuggestData';
import { BinanceProvider } from './explorer/binanceProvider';
import BinanceService from './explorer/binanceService';
import { FundProvider } from './explorer/fundProvider';
import FundService from './explorer/fundService';
import { NewsProvider } from './explorer/newsProvider';
import { NewsService } from './explorer/newsService';
import { StockProvider } from './explorer/stockProvider';
import StockService from './explorer/stockService';
import globalState from './globalState';
import FlashNewsDaemon from './output/flash-news/FlashNewsDaemon';
import { LeekFundConfig } from './shared/leekConfig';
import { LeekTreeItem } from './shared/leekTreeItem';
import checkForUpdate from './shared/update';
Expand All @@ -18,14 +21,12 @@ import fundHistory from './webview/fundHistory';
import fundPosition from './webview/fundPosition';
import fundRank from './webview/fundRank';
import fundTrend from './webview/fundTrend';
import leekCenterView from './webview/leekCenterView';
import openNews from './webview/news';
import setAmount from './webview/setAmount';
import stockTrend from './webview/stockTrend';
import stockTrendPic from './webview/stockTrendPic';
import leekCenterView from './webview/leekCenterView';
import { BinanceProvider } from './explorer/binanceProvider';
import BinanceService from './explorer/binanceService';
import FlashNewsDaemon from './output/flash-news/FlashNewsDaemon';
import tucaoForum from './webview/tucaoForum';

export function registerViewEvent(
context: ExtensionContext,
Expand Down Expand Up @@ -448,6 +449,7 @@ export function registerViewEvent(
);

context.subscriptions.push(commands.registerCommand('leek-fund.donate', () => donate(context)));
context.subscriptions.push(commands.registerCommand('leek-fund.tucaoForum', () => tucaoForum()));

context.subscriptions.push(
commands.registerCommand('leek-fund.toggleRemindSwitch', (on?: number) => {
Expand Down
18 changes: 12 additions & 6 deletions src/webview/fundFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@ import globalState from '../globalState';
import ReusedWebviewPanel from './ReusedWebviewPanel';

function fundFlow(context?: ExtensionContext) {
const panel = ReusedWebviewPanel.create('leek-fund.fundFlow', '资金流向', ViewColumn.One, {
const panel = ReusedWebviewPanel.create('leek-fund.fundFlow', '沪深通资金流向', ViewColumn.One, {
enableScripts: true,
retainContextWhenHidden: true,
});
getWebViewContent(panel);
panel.webview.html = getTemplateFileContent('hsgt.html', panel.webview);
}

function getWebViewContent(panel: WebviewPanel) {
panel.webview.html = getTemplateFileContent(
'hsgt.html',
panel.webview
export function mainFundFlow() {
const panel = ReusedWebviewPanel.create(
'leek-fund.mainFundFlow',
'主力资金流向',
ViewColumn.One,
{
enableScripts: true,
retainContextWhenHidden: true,
}
);
panel.webview.html = getTemplateFileContent('main-flow.html', panel.webview);
}

export default fundFlow;
32 changes: 17 additions & 15 deletions src/webview/leekCenterView.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { commands, Uri, ViewColumn, Webview, window, authentication } from 'vscode';
import { LeekTreeItem } from '../shared/leekTreeItem';
import globalState from '../globalState';
import ReusedWebviewPanel from './ReusedWebviewPanel';
import { getTemplateFileContent, getWebviewResourcesUrl } from '../shared/utils';
import { events } from '../shared/utils';
import { LeekFundConfig } from '../shared/leekConfig';
import StockService from '../explorer/stockService';

import { EventEmitter } from 'events';
import { authentication, Uri, ViewColumn, Webview, window } from 'vscode';
import FundService from '../explorer/fundService';
import fundFlow from './fundFlow';
import StockService from '../explorer/stockService';
import globalState from '../globalState';
import { LeekFundConfig } from '../shared/leekConfig';
import { LeekTreeItem } from '../shared/leekTreeItem';
import { events, getTemplateFileContent, getWebviewResourcesUrl } from '../shared/utils';
import fundFlow, { mainFundFlow } from './fundFlow';
import ReusedWebviewPanel from './ReusedWebviewPanel';
import tucaoForum from './tucaoForum';

let _INITED = false;

Expand All @@ -33,10 +32,7 @@ function leekCenterView(stockService: StockService, fundServices: FundService) {
return getWebviewResourcesUrl(panel.webview, globalState.context.extensionUri, arr);
};

panel.webview.html = getTemplateFileContent(
'stocks-view.html',
panel.webview
);
panel.webview.html = getTemplateFileContent('stocks-view.html', panel.webview);

panel.webview.onDidReceiveMessage((message) => {
panelEvents.emit('onDidReceiveMessage', message);
Expand All @@ -50,9 +46,15 @@ function leekCenterView(stockService: StockService, fundServices: FundService) {
case 'pageReady':
panelEvents.emit('pageReady');
return;
case 'hsgtFund':
case 'hsgtFundFlow':
fundFlow();
return;
case 'mainFundFlow':
mainFundFlow();
return;
case 'tucaoForum':
tucaoForum();
return;
}
}, undefined);

Expand Down
13 changes: 13 additions & 0 deletions src/webview/tucaoForum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ViewColumn } from 'vscode';
import { getTemplateFileContent } from '../shared/utils';
import ReusedWebviewPanel from './ReusedWebviewPanel';

function tucaoForum() {
const panel = ReusedWebviewPanel.create('leek-fund.tucaoForum', '韭菜盒子社区', ViewColumn.One, {
enableScripts: true,
retainContextWhenHidden: true,
});
panel.webview.html = getTemplateFileContent('tucao.html', panel.webview);
}

export default tucaoForum;
4 changes: 1 addition & 3 deletions template/hsgt.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>股票走势</title>
<title>沪深通资金流向</title>
<link
href="https://cdn.bootcdn.net/ajax/libs/element-ui/2.9.2/theme-chalk/index.css"
rel="stylesheet"
Expand All @@ -28,8 +28,6 @@
<script>
document.querySelector('#refreshBtn').onclick = function (e) {
e.preventDefault();
// document.querySelector('#iframeEl').reload();
console.log(iframeEl.src);
iframeEl.src = '';
iframeEl.src = 'https://emrnweb.eastmoney.com/hsgt/home';
};
Expand Down
36 changes: 36 additions & 0 deletions template/main-flow.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>主力资金流向</title>
<link
href="https://cdn.bootcdn.net/ajax/libs/element-ui/2.9.2/theme-chalk/index.css"
rel="stylesheet"
/>
</head>
<body>
<div style="overflow-x: auto; min-width: 800px">
<button
id="refreshBtn"
class="el-button el-button--primary el-button--mini"
style="position: fixed; right: 10px; top: 20px"
>
刷新
</button>
<iframe
id="iframeEl"
src="https://emdatah5.eastmoney.com/dc/zjlx/index"
frameborder="0"
style="width: 100%; height: 900px"
></iframe>
</div>
<script>
document.querySelector('#refreshBtn').onclick = function (e) {
e.preventDefault();
iframeEl.src = '';
iframeEl.src = 'https://emdatah5.eastmoney.com/dc/zjlx/index';
};
</script>
</body>
</html>
66 changes: 14 additions & 52 deletions template/scripts/stocks-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,59 +374,21 @@ vscode.postMessage({
});

// 资金流向跳转
const flowBtn = document.querySelector('#flowBtn');
flowBtn.onclick = function () {
const hstflowBtn = document.querySelector('#hstflowBtn');
const mainflowBtn = document.querySelector('#mainflowBtn');
hstflowBtn.onclick = function () {
vscode.postMessage({
command: 'hsgtFund',
command: 'hsgtFundFlow',
});
};

/**
弹出iframe页面(iframe后面会添加灰色蒙版)
**/
/* function showIframe(url, selector = 'body') {
$(
"<div id='showMobilePreview'>" +
"<div class='mobile_preview_header'><i class='mobile_preview_header_icon'></i></div>" +
"<div class='mobile_preview_frame'><iframe id='YuFrameMobilePreview' name='YuFrameMobilePreview'sandbox='allow-same-origin allow-forms allow-scripts' ></iframe></div>" +
"<div class='mobile_preview_footer'><i class='mobile_preview_footer_icon'></i></div>" +
'</div>'
).prependTo(selector);
$('#YuFrameMobilePreview').attr('src', url);
//添加背景遮罩
$(
"<div id='YuFrameMobilePreviewBg' style='cursor:pointer;width:100%;height:100%;background-color: Gray;display:block;z-index:9998;position:absolute;left:0px;top:0px;filter:Alpha(Opacity=30);opacity: 0.4; '/>"
).prependTo(selector);
//点击背景遮罩移除iframe和背景
$('#YuFrameMobilePreviewBg').click(function () {
$('#showMobilePreview').remove();
$('#YuFrameMobilePreviewBg').remove();
mainflowBtn.onclick = function () {
vscode.postMessage({
command: 'mainFundFlow',
});
}
*/
// 无法伪造iframe代理;

/* function setUserAgent(window, userAgent) {
if (window.navigator.userAgent !== userAgent) {
var userAgentProp = {
get: function () {
return userAgent;
},
};
try {
Object.defineProperty(window.navigator, 'userAgent', userAgentProp);
} catch (e) {
window.navigator = Object.create(navigator, {
userAgent: userAgentProp,
});
}
}
}
setUserAgent(
document.querySelector('#iframeEl').contentWindow,
'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1'
); */

// showIframe('https://support.qq.com/embed/phone/302926', '#gitalk-container');
};
// 社区
document.querySelector('#tucaoBtn').onclick = function () {
vscode.postMessage({
command: 'tucaoForum',
});
};
17 changes: 13 additions & 4 deletions template/stocks-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
rel="stylesheet"
/>
<!-- style assets -->
<link rel="stylesheet" href="styles/stocks-view.css">
<link rel="stylesheet" href="styles/stocks-view.css" />

<style>
a {
Expand All @@ -32,7 +32,8 @@ <h2 id="title">韭菜中心</h2>
style="position: absolute; min-width: 500px; right: 30px; top: 20px"
>
<a
href="https://support.qq.com/products/302926"
id="tucaoBtn"
href="javascript:void(0)"
target="_blank"
style="margin-left: 20px; float: right"
title="论坛交流"
Expand All @@ -42,9 +43,17 @@ <h2 id="title">韭菜中心</h2>
href="javascript:void(0)"
style="margin-left: 20px; float: right"
target="_blank"
id="flowBtn"
id="hstflowBtn"
title="沪深通资金流向"
>🏦资金流向</a
>🏦北向资金流向</a
>
<a
href="javascript:void(0)"
style="margin-left: 20px; float: right"
target="_blank"
id="mainflowBtn"
title="主力资金流向"
>🏦主力资金流向</a
>
</div>
</header>
Expand Down
48 changes: 48 additions & 0 deletions template/tucao.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>韭菜盒子社区</title>
<link
href="https://cdn.bootcdn.net/ajax/libs/element-ui/2.9.2/theme-chalk/index.css"
rel="stylesheet"
/>
<style>
a {
text-decoration: none;
}
</style>
</head>
<body>
<div style="overflow-x: auto; min-width: 800px">
<a
href="https://support.qq.com/products/302926"
class="el-button el-button--primary el-button--mini"
style="position: fixed; right: 10px; top: 10px"
>
浏览器打开
</a>
<button
id="refreshBtn"
class="el-button el-button--primary el-button--mini"
style="position: fixed; right: 120px; top: 10px"
>
刷新
</button>
<iframe
id="iframeEl"
src="https://support.qq.com/products/302926"
frameborder="0"
style="width: 100%; height: 900px"
></iframe>
</div>
<script>
document.querySelector('#refreshBtn').onclick = function (e) {
e.preventDefault();
iframeEl.src = '';
iframeEl.src = 'https://support.qq.com/products/302926';
};
</script>
</body>
</html>

0 comments on commit c1a6c24

Please sign in to comment.