浏览代码

getLibReg 获取全局函数注册信息

luoyifan 3 年之前
父节点
当前提交
649878ffaf
共有 2 个文件被更改,包括 12 次插入3 次删除
  1. 11 2
      src/lib/lib.ts
  2. 1 1
      src/lib/systemLib.ts

+ 11 - 2
src/lib/lib.ts

@@ -2,11 +2,20 @@ import _ from 'lodash'
 import {FunctionRegiste} from "../types"
 import {Scope} from "../Scope"
 
-export const LibList: FunctionRegiste[] = []
+export function getRegList() {
+    let regList = _.get(window, 'yvanLib.regList')
+    if (!regList) {
+        regList = []
+        _.set(window, 'yvanLib.regList', regList)
+    }
+    return regList
+}
 
 export function Lib(registe: FunctionRegiste) {
     return function (target, propertyKey: string, descriptor: PropertyDescriptor) {
-        LibList.push({
+        const libList = getRegList()
+        console.log("libregiste", target[propertyKey], libList.length)
+        libList.push({
             ...registe,
             name: propertyKey,
             target: target[propertyKey]

+ 1 - 1
src/lib/systemLib.ts

@@ -514,7 +514,7 @@ export function confirm(msg, sender?): Promise<void> {
     })
 }
 
-class SystemEventFu {
+export class SystemEventFu {
 
     @Lib({
         title: '弹出确认对话框,回答 YES 之后调用某方法',