2026-03-29 13:26:23 +08:00

30 lines
929 B
JavaScript

import fs from 'fs';
import path from 'path';
import configUtil from '../utils/config.js';
import service from '../core/BaseService.js';
const __dirname = path.dirname(decodeURIComponent(new URL(import.meta.url).pathname.replace(/^\//, '')));
const configPath = path.join(__dirname, '../config.json');
class BindService extends service {
constructor() {
super();
this.generateCode = this.generateCode.bind(this); // 确保上下文绑定
this.tokenInfo = this.tokenInfo.bind(this); // 确保上下文绑定
}
generateCode(data) {
const {app} = this;
this.app.randomCode = data;
this.app.emit('generateCode', data);
}
tokenInfo(data) {
const {app} = this;
app.config.token = data.jwtToken;
app.config.refreshToken = data.refreshToken;
app.config.tokenExpireTime = data.tokenExpireTime;
configUtil.write(app.config);
app.isBind = true;
}
};
export default BindService;