优化session方法

v2
yutent 2023-11-01 14:10:04 +08:00
parent d339d2872d
commit 24c056faf1
1 changed files with 4 additions and 5 deletions

View File

@ -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.')
}
}
}