继续适配Trss (#583)

* fix: 修复星火api上下文

* 将无星火ck的情况降低为warn

* feat: 添加星火设定自定义代码功能

* 修复星火api模式的一些问题

* 修复导出配置问题

* feat:添加工具箱快捷登录接口

* 添加工具箱快捷登录指令

* 阻止群聊使用快捷登录

* 添加Azure配置支持,修复重复的配置项冲突

* 移除旧版本渲染和新版本帮助

* 添加工具箱

* 更新工具箱替换原有后台

* 更新工具箱适配代码

* 后台适配Trss

* 修复trss不支持sendPrivateMsg的问题

* 优化路由

* 修复路由

* 适配其他uin

* 添加bing第三方绘图

* 修复bing绘图第三方调用错误

* 添加bing第三方绘图采样配置

* 修复错误

* 添加bing第三方绘图图片大小配置

* 修复视图错误

* 使用ap替换第三方绘图

* 适配trss

* server 适配trss

* 修复错误的后台版本更新

* 添加锅巴用户数据

* 修复server初始化消息错误

* 添加锅巴插件适配

* 更新后台页面

* 添加锅巴代理接口

* 优化锅巴接口代理

* 修复锅巴代理参数

* 删除调试信息

* 修复headers

* 更新后台锅巴插件支持
This commit is contained in:
HalcyonAlcedo 2023-10-16 21:49:00 +08:00 committed by GitHub
parent 6c171b32a1
commit c68a50e8bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 214 additions and 173 deletions

View file

@ -6,12 +6,27 @@ async function User(fastify, options) {
// 登录
fastify.post('/login', async (request, reply) => {
const body = request.body || {}
let guobaLoginService
let guobaAPI = ''
try {
let { LoginService } = await import('../../../Guoba-Plugin/server/service/both/LoginService.js')
let { getAllWebAddress } = await import('../../../Guoba-Plugin/utils/common.js')
guobaLoginService = new LoginService()
guobaAPI = await getAllWebAddress()
}
catch (err) {
console.error(err)
guobaLoginService = {
signToken: () => {return null}
}
}
if (body.qq && body.passwd) {
const token = randomString(32)
if (body.qq == getUin() && await redis.get('CHATGPT:ADMIN_PASSWD') == body.passwd) {
const guobaToken = await guobaLoginService.signToken(body.qq)
AddUser({ user: body.qq, token: token, autho: 'admin' })
reply.setCookie('token', token, { path: '/' })
reply.send({ login: true, autho: 'admin', token: token })
reply.send({ login: true, autho: 'admin', token: token, guobaToken: guobaToken, guoba: guobaAPI })
} else {
const user = await getUserData(body.qq)
if (user.passwd != '' && user.passwd === body.passwd) {
@ -26,9 +41,10 @@ async function User(fastify, options) {
const token = randomString(32)
const opt = await redis.get(`CHATGPT:SERVER_QUICK`)
if (opt && body.otp == opt) {
const guobaToken = await guobaLoginService.signToken(getUin())
AddUser({ user: getUin(), token: token, autho: 'admin' })
reply.setCookie('token', token, { path: '/' })
reply.send({ login: true, autho: 'admin', token: token, user: getUin() })
reply.send({ login: true, autho: 'admin', token: token, user: getUin(), guobaToken: guobaToken, guoba: guobaAPI })
} else {
reply.send({ login: false, err: `快捷登录代码错误,请检查后重试` })
}