项目改为module

v1
宇天 2020-09-15 19:06:27 +08:00
parent ecce207db2
commit f595a927ce
1 changed files with 39 additions and 26 deletions

View File

@ -4,20 +4,35 @@
* @date 2015-11-25 18:06:14 * @date 2015-11-25 18:06:14
* *
*/ */
'use strict'
require('es.shim') // 加载拓展方法 import 'es.shim' // 加载拓展方法
var init = require('./lib/reg-init') import init from './lib/reg-init'
import http from 'http'
import path from 'path'
import Request from 'http.request'
import Response from 'http.response'
import Smarty from 'smartyx' //模板引擎
import Log from './lib/module/log' //基础日志记录工具
import Email from './lib/module/sendmail' //加载email发送类
import Mysql from 'mysqli' //加载mysql操作类
import Ioredis from 'ioredis'
import sec from 'crypto.js'
import path from 'path'
import url from 'url'
import fs from 'iofs'
import child from 'child_process'
import Controller from './lib/controller'
import routerWare from './lib/middleware/router'
import cookieWare from './lib/middleware/cookie'
import sessionWare from './lib/middleware/session'
import credentialsWare from './lib/middleware/credentials'
var log = console.log var log = console.log
var http = require('http')
var path = require('path')
var Request = require('http.request')
var Response = require('http.response')
var routerWare = require('./lib/middleware/router')
var cookieWare = require('./lib/middleware/cookie')
var sessionWare = require('./lib/middleware/session')
var credentialsWare = require('./lib/middleware/credentials')
function hideProperty(host, name, value) { function hideProperty(host, name, value) {
Object.defineProperty(host, name, { Object.defineProperty(host, name, {
@ -28,7 +43,7 @@ function hideProperty(host, name, value) {
}) })
} }
class Five { export default class Five {
constructor() { constructor() {
hideProperty(this, '__FIVE__', Object.assign({}, init)) hideProperty(this, '__FIVE__', Object.assign({}, init))
hideProperty(this, '__MODULES__', { __error__: null }) hideProperty(this, '__MODULES__', { __error__: null })
@ -36,20 +51,20 @@ class Five {
hideProperty(this, '__INSTANCE__', {}) hideProperty(this, '__INSTANCE__', {})
global.libs = { global.libs = {
Smarty: require('smartyx'), //模板引擎 Smarty, //模板引擎
Log: require('./lib/module/log'), //基础日志记录工具 Log, //基础日志记录工具
Email: require('./lib/module/sendmail'), //加载email发送类 Email, //加载email发送类
Mysql: require('mysqli'), //加载mysql操作类 Mysql, //加载mysql操作类
Ioredis: require('ioredis') Ioredis
} }
global.Util = { global.Util = {
sec: require('crypto.js'), sec,
path: require('path'), path,
url: require('url'), url,
fs: require('iofs'), fs,
child: require('child_process') child
} }
global.Controller = require('./lib/controller') global.Controller = Controller
} }
__init__() { __init__() {
@ -141,7 +156,7 @@ class Five {
return return
} }
try { try {
this.__MODULES__[name] = require(file) this.__MODULES__[name] = import(file)
} catch (err) { } catch (err) {
this.__MODULES__.__error__ = err this.__MODULES__.__error__ = err
} }
@ -198,5 +213,3 @@ class Five {
return server return server
} }
} }
module.exports = Five