优化session方法
parent
d339d2872d
commit
24c056faf1
9
index.js
9
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.')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue