| 2 | function Env(t, s) { |
| 3 | return new (class { |
| 4 | constructor(t, s) { |
| 5 | this.userIdx = 1; |
| 6 | this.userList = []; |
| 7 | this.userCount = 0; |
| 8 | this.name = t; |
| 9 | this.notifyStr = []; |
| 10 | this.logSeparator = "\n"; |
| 11 | this.startTime = new Date().getTime(); |
| 12 | Object.assign(this, s); |
| 13 | this.log(`\ud83d\udd14${this.name},\u5f00\u59cb!`); |
| 14 | this.bucket = this.bucket || '' |
| 15 | this.fs = require("fs"); |
| 16 | if (this.isNode() && this.bucket) { |
| 17 | try { |
| 18 | if (!this.fs.existsSync(this.bucket)) { |
| 19 | this.fs.writeFileSync(this.bucket, JSON.stringify({}, null, 2)); |
| 20 | this.log(`📁 已创建 bucket 文件: ${this.bucket}`); |
| 21 | } |
| 22 | } catch (e) { |
| 23 | this.log("❌ 初始化 bucket 失败: " + e.message); |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | async get(key, def = null) { |
| 28 | if (!this.isNode()) return def; |
| 29 | try { |