From 218857e9f887aa090b858c4846bca6c7552c2f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Mon, 28 Sep 2020 10:03:27 +0800 Subject: [PATCH 1/3] 1.0.0 --- index.js | 5 ++--- package.json | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 6e41bda..5a20d93 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,7 @@ /** * 框架核心 - * @authors yutent (yutent@doui.cc) - * @date 2015-11-25 18:06:14 - * + * @author yutent + * @date 2020/09/28 10:01:47 */ import 'es.shim' // 加载拓展方法 diff --git a/package.json b/package.json index e22db17..ebc0794 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "main": "index.js", "dependencies": { "@gm5/session": "^1.0.0", - "@gm5/request": "^1.2.1", + "@gm5/request": "^1.2.3", "@gm5/response": "^1.3.1", "@gm5/controller": "^1.0.0", "@gm5/jwt": "^1.1.0", From 36d28679e8bfc12c0521a5234aa68cd0684598dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Mon, 28 Sep 2020 10:38:47 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/index.js | 2 +- index.js | 1 + package.json | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/index.js b/config/index.js index 4c7577e..d5fb134 100644 --- a/config/index.js +++ b/config/index.js @@ -41,7 +41,7 @@ export default { passwd: '' }, views: { - enabled: true, + enabled: false, dir: '', ext: '.htm' }, diff --git a/index.js b/index.js index 5a20d93..30bcaca 100644 --- a/index.js +++ b/index.js @@ -124,6 +124,7 @@ export default class Five { } this.__MODULES__[name] = import(item).catch(err => { + console.error(err) return { default: null } }) }) diff --git a/package.json b/package.json index ebc0794..08df735 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gm5/core", - "version": "1.0.0", + "version": "1.0.1", "type": "module", "description": "Five.js, 一个轻量级的nodejs mvc框架 旨在简单易用, 5分钟即可上手", "author": "yutent ", From 70a2df558344a0179a426b201aaf07f7c2064932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Wed, 30 Sep 2020 14:25:08 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B7=A8=E5=9F=9F?= =?UTF-8?q?=E9=85=8D=E7=BD=AE;=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Readme.md | 6 +++--- config/index.js | 2 +- index.js | 2 ++ middleware/cors.js | 14 ++++++++++++-- package.json | 2 +- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Readme.md b/Readme.md index 9e8872d..ab77d12 100644 --- a/Readme.md +++ b/Readme.md @@ -65,16 +65,16 @@ import Five from '@gm5/core' var app = new Five() app.set({ website: 'www.your_domain.com' }) -app.set({ domain: 'your_domain.com' }) // 设置域,cookie用到,不设置则同步website +// app.set({ domain: 'your_domain.com' }) // 设置域,cookie用到,不设置则等同于website -app.set({ VIEWS: './views/' }) // [可选], 但是要用到模板渲染页面时, 必须指定 +// app.set({ VIEWS: './views/' }) // [可选], 但是要用到模板渲染页面时, 必须指定 app.preload('./apps/') // [必须], 预加载应用目录 app.listen(3001) // 默认是3000 ``` -其他的配置和功能, 请参考 `文档`。 +其他的配置和功能, 请参考 [文档](https://github.com/bytedo/gmf.core/wiki)。 3. 启动应用。在项目根目录打开终端, 输入以下命令 `five-cli start`, 然后根据提示操作, 即可 diff --git a/config/index.js b/config/index.js index d5fb134..f8509cd 100644 --- a/config/index.js +++ b/config/index.js @@ -49,7 +49,7 @@ export default { enabled: false, credentials: false, origin: [], // ['abc.com', 'a.foo.com'] - maxAge: 0 + maxAge: 14400 }, regexp: { // 常用正则 diff --git a/index.js b/index.js index 30bcaca..43235b7 100644 --- a/index.js +++ b/index.js @@ -38,8 +38,10 @@ export default class Five { __main__() { var { domain, website, session, jwt } = this.__FIVE__ + domain = domain || website session.domain = session.domain || domain + this.set({ domain, session }) // 安装模板引擎 diff --git a/middleware/cors.js b/middleware/cors.js index 878221e..9637246 100644 --- a/middleware/cors.js +++ b/middleware/cors.js @@ -15,11 +15,21 @@ export default function(req, res, next) { var { hostname, host, protocol } = url.parse(origin) if (CORS.origin.length && hostname) { - if (!CORS.origin.includes(hostname)) { + var pass = false + for (let it of CORS.origin) { + if (hostname.endsWith(it)) { + pass = true + break + } + } + if (pass === false) { return res.end('') } } - res.set('Access-Control-Allow-Credentials', 'true') + if (CORS.credentials) { + res.set('Access-Control-Allow-Credentials', 'true') + } + res.set('Access-Control-Allow-Origin', `${protocol}//${host}`) if (headers) { diff --git a/package.json b/package.json index 08df735..00514e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gm5/core", - "version": "1.0.1", + "version": "1.0.2", "type": "module", "description": "Five.js, 一个轻量级的nodejs mvc框架 旨在简单易用, 5分钟即可上手", "author": "yutent ",