mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
添加锅巴插件适配
This commit is contained in:
parent
42bad1cb47
commit
7e5f723a82
1 changed files with 24 additions and 3 deletions
|
|
@ -9,12 +9,13 @@ async function User(fastify, options) {
|
|||
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')
|
||||
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().remote
|
||||
guobaAPI = await getAllWebAddress()
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err)
|
||||
guobaLoginService = {
|
||||
signToken: () => {return null}
|
||||
}
|
||||
|
|
@ -87,6 +88,26 @@ async function User(fastify, options) {
|
|||
})
|
||||
return reply
|
||||
})
|
||||
// 获取锅巴登陆链接
|
||||
fastify.post('/guobaLogin', async (request, reply) => {
|
||||
const token = request.cookies.token || request.body?.token || 'unknown'
|
||||
let user = UserInfo(token)
|
||||
if (user && user.autho == 'admin') {
|
||||
try {
|
||||
let { LoginService } = await import('../../../Guoba-Plugin/server/service/both/LoginService.js')
|
||||
const guobaLoginService = new LoginService()
|
||||
const guobaAPI = await guobaLoginService.setQuickLogin(user.user)
|
||||
reply.send({ guoba: guobaAPI })
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err)
|
||||
reply.send({ state: false, error: err })
|
||||
}
|
||||
} else {
|
||||
reply.send({ state: false, error: '用户权限不足' })
|
||||
}
|
||||
return reply
|
||||
})
|
||||
// 获取用户数据
|
||||
fastify.post('/userData', async (request, reply) => {
|
||||
const token = request.cookies.token || request.body?.token || 'unknown'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue