diff --git a/README.md b/README.md index 7386ccc..d5c9340 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,10 @@ ![Instructions.gif](https://s1.ax1x.com/2020/08/19/dQ8R3t.gif) +### v1.5.0 + +- 退出当前插件时,停止查询 + ### v1.4.2 - 去掉平台限制 @@ -25,11 +29,11 @@ ### v1.3.9 -- 我的自选基金新增支持s前缀搜索过滤自选基金,如s001071 +- 我的自选基金新增支持 s 前缀搜索过滤自选基金,如 s001071 ### v1.3.8 -- 更换使用说明gif链接 +- 更换使用说明 gif 链接 ### v1.3.7 diff --git a/package.json b/package.json index e587324..117cf33 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "utools-fund", - "version": "v1.4.2", + "version": "v1.5.0", "description": "自选基金助手", "main": "main.ts", "scripts": { diff --git a/src/features/fundMy.ts b/src/features/fundMy.ts index cee4173..694c2a3 100644 --- a/src/features/fundMy.ts +++ b/src/features/fundMy.ts @@ -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); }, diff --git a/src/types/utools.d.ts b/src/types/utools.d.ts index a7125be..3cb29a1 100644 --- a/src/types/utools.d.ts +++ b/src/types/utools.d.ts @@ -6,6 +6,11 @@ import { StreamProtocolResponse } from 'electron'; * @description 文档链接: https://u.tools/docs/developer/api.html */ export interface UTools { + /** + * 是否魔改版标识 + */ + isMagicRevision: boolean; + // 事件相关API /** * @description 当插件装载成功,uTools将会主动调用这个方法(生命周期内仅调用一次)