Skip to content

Commit

Permalink
退出当前插件时,停止查询
Browse files Browse the repository at this point in the history
  • Loading branch information
adams549659584 committed Oct 22, 2020
1 parent 99bb91c commit 12b6b1a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

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

### v1.5.0

- 退出当前插件时,停止查询

### v1.4.2

- 去掉平台限制
Expand All @@ -25,11 +29,11 @@

### v1.3.9

- 我的自选基金新增支持s前缀搜索过滤自选基金,如s001071
- 我的自选基金新增支持 s 前缀搜索过滤自选基金,如 s001071

### v1.3.8

- 更换使用说明gif链接
- 更换使用说明 gif 链接

### v1.3.7

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "utools-fund",
"version": "v1.4.2",
"version": "v1.5.0",
"description": "自选基金助手",
"main": "main.ts",
"scripts": {
Expand Down
35 changes: 32 additions & 3 deletions src/features/fundMy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,44 @@ const showFundDetails = async (cb: CallbackSetList, isShowLoading = true) => {
showFundDetails(cb, false);
}, 1000 * 60);
};
utools.onPluginOut(() => {
clearTimeout(QUERY_TIMER);
});

const hanlderUTools = {
get(obj, prop) {
// 是否魔改版标识
if (prop === 'isMagicRevision') {
return true;
}
if (prop === '__event__') {
const val = obj[prop];
// 处理用户退出当前插件,停止查询
if (val.onPluginOut && !val.onPluginOut.isMagicRevision) {
const rawOnPluginOut = val.onPluginOut;
val.onPluginOut = cb => {
console.log(`用户退出插件`);
clearTimeout(QUERY_TIMER);
return rawOnPluginOut(cb);
};
val.onPluginOut.isMagicRevision = true;
}
return val;
}
return obj[prop];
},
// set(obj, prop, value) {
// console.log(`set ${prop} : `, value);
// obj[prop] = value;
// return true;
// },
};

const fundMy: TplFeature = {
mode: 'list',
args: {
placeholder: '输入持有份额,选择对应基金,回车键保存,s前缀搜索',
enter: async (action, callbackSetList) => {
if (!utools.isMagicRevision) {
utools = new Proxy(utools, hanlderUTools);
}
clearTimeout(QUERY_TIMER);
showFundDetails(callbackSetList);
},
Expand Down
5 changes: 5 additions & 0 deletions src/types/utools.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import { StreamProtocolResponse } from 'electron';
* @description 文档链接: https://u.tools/docs/developer/api.html
*/
export interface UTools {
/**
* 是否魔改版标识
*/
isMagicRevision: boolean;

// 事件相关API
/**
* @description 当插件装载成功,uTools将会主动调用这个方法(生命周期内仅调用一次)
Expand Down

0 comments on commit 12b6b1a

Please sign in to comment.