123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- // 系统进程ID
- SYSTEM.ID = (Math.ceil(Math.random()*61439+4096)).toString(16).toUpperCase();
- //系统目录配置
- SYSTEM.PATH = {
- App : SYSTEM.ROOTPATH + '/app',
- System : SYSTEM.ROOTPATH + '/system',
- Module : SYSTEM.ROOTPATH + '/system/module',
- CoreLib : SYSTEM.ROOTPATH + '/system/lib/core',
- ExtraLib : SYSTEM.ROOTPATH + '/system/lib/extra',
- CoreHelper : SYSTEM.ROOTPATH + '/system/lib/helper',
- Library : SYSTEM.ROOTPATH + '/lib',
- Helper : SYSTEM.ROOTPATH + '/lib/helper',
- Temp : SYSTEM.ROOTPATH + '/temp',
- Session : SYSTEM.ROOTPATH + '/temp/session',
- Log : SYSTEM.ROOTPATH + '/log'
- }
- //全局扩展库
- const Global = (global as any);
- Global.FILE = require('fs-extra');
- Global.FILE.walkSync = require('klaw-sync');
- Global.PATH = require('path');
- Global.REQUEST = require('request');
- Global.Moment = require('moment');
- //自动载入系统目录运行库
- let CoreLibFiles = FILE.readdirSync(SYSTEM.PATH.CoreLib);
- // console.log(CoreLibFiles)
- CoreLibFiles.forEach((filename:string)=>{
- const nameWithOutMimeType = (filename.split('.')[0]).toUpperCase();
- let coreClass;
- try {
- coreClass = require(SYSTEM.PATH.CoreLib + '/' + filename);
- }catch(e){
- console.log('[Core] Core library file ['+filename+'] load error!');
- console.log(e);
- Global.Tracer.error('[Core] Core library file ['+filename+'] load error!');
- }
- // if(!coreClass) return;
- if(coreClass.hasOwnProperty && coreClass.hasOwnProperty('_name') && coreClass['_name']){
- Global[coreClass['_name']] = coreClass;
- }else{
- Global[nameWithOutMimeType] = coreClass;
- }
- if(typeof coreClass == 'object' && coreClass.hasOwnProperty && coreClass.hasOwnProperty('__construct')) coreClass['__construct']();
- });
- CoreLibFiles = null;
- //检查并自动创建文件目录
- Object.keys(SYSTEM.PATH).forEach((path)=>{
- try{
- FILE.statSync(SYSTEM.PATH[path]);
- }catch(e){
- FILE.mkdirsSync(SYSTEM.PATH[path]);
- }
- });
|