From 24c056faf122b43794b5092dda4ad457620e4078 Mon Sep 17 00:00:00 2001 From: yutent Date: Wed, 1 Nov 2023 14:10:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96session=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 7156fcb..03ac9eb 100644 --- a/index.js +++ b/index.js @@ -80,18 +80,17 @@ export default class Controller { // 会话读写 session(key, val) { - let { enabled } = this.context.get('session') let { ssid } = this.request - if (enabled) { + if (this.context.$$session) { + key += '' + if (arguments.length < 2) { // 这里返回的是Promise对象 return this.context.$$session.get(ssid, key) } - - key += '' this.context.$$session.set(ssid, key, val) } else { - throw Error('Session was disabled.') + throw new Error('Session was disabled.') } } }