Browse Source

Add helper core

HonorLee 6 years ago
parent
commit
be4461995c
2 changed files with 18 additions and 0 deletions
  1. 1 0
      system/core.js
  2. 17 0
      system/lib/core/helper.js

+ 1 - 0
system/core.js

@@ -39,6 +39,7 @@ CoreLibFiles.forEach(function(filename){
     let nameWithOutMimeType = (filename.split('.')[0]).toUpperCase();
     try {
         global[nameWithOutMimeType] = require(Core.Path.CoreLib + '/' + filename);
+        if(typeof global[nameWithOutMimeType] == 'object' && global[nameWithOutMimeType]['__construct']) global[nameWithOutMimeType]['__construct']();
     }catch(e){
         console.log('[Core] Core library file ['+filename+'] load error!');
         Tracer.error('[Core] Core library file ['+filename+'] load error!');

+ 17 - 0
system/lib/core/helper.js

@@ -0,0 +1,17 @@
+module.exports = {
+    __construct:function(){
+        global.H = function(healperName){
+            if(!healperName){
+                LOGGER.error('Helper name undefined!!');
+                return null
+            }
+            try{
+                FILE.statSync(Core.Path.Helper + '/'+healperName+'.js');
+            }catch(e){
+                LOGGER.error('No such helper ['+healperName+']');
+                return null;
+            }
+            return require(Core.Path.Helper + '/'+healperName+'.js');
+        }
+    }
+}