-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: 修复星火api上下文 * 将无星火ck的情况降低为warn * feat: 添加星火设定自定义代码功能 * 修复星火api模式的一些问题 * 修复导出配置问题 * feat:添加工具箱快捷登录接口 * 添加工具箱快捷登录指令 * 阻止群聊使用快捷登录 * 添加Azure配置支持,修复重复的配置项冲突 * 移除旧版本渲染和新版本帮助 * 添加工具箱 * 更新工具箱替换原有后台 * 更新工具箱适配代码 * 后台适配Trss * 修复trss不支持sendPrivateMsg的问题 * 优化路由 * 修复路由 * 适配其他uin * 添加bing第三方绘图 * 修复bing绘图第三方调用错误 * 添加bing第三方绘图采样配置 * 修复错误 * 添加bing第三方绘图图片大小配置 * 修复视图错误 * 使用ap替换第三方绘图 * 适配trss * server 适配trss * 修复错误的后台版本更新 * 添加锅巴用户数据 * 修复server初始化消息错误 * 添加锅巴插件适配 * 更新后台页面 * 添加锅巴代理接口 * 优化锅巴接口代理 * 修复锅巴代理参数 * 删除调试信息 * 修复headers * 更新后台锅巴插件支持
- Loading branch information
1 parent
6c171b3
commit c68a50e
Showing
43 changed files
with
214 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { UserInfo } from './user_data.js' | ||
|
||
async function Guoba(fastify, options) { | ||
// 获取锅巴登陆链接 | ||
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('/guobaApi', async (request, reply) => { | ||
const body = request.body || {} | ||
const token = request.cookies.token || request.body?.token || 'unknown' | ||
let user = UserInfo(token) | ||
if (user && user.autho == 'admin' && body.guobaToken) { | ||
try { | ||
let { getAllWebAddress } = await import('../../../Guoba-Plugin/utils/common.js') | ||
const { custom, local, remote } = await getAllWebAddress() | ||
if (local.length > 0) { | ||
const guobaOptions = { | ||
method: body.post ? 'POST' : 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Guoba-Access-Token': body.guobaToken | ||
} | ||
} | ||
if (body.data) { | ||
if (body.post) { | ||
guobaOptions.body = JSON.stringify(body.data) | ||
} else { | ||
let paramsArray = [] | ||
Object.keys(body.data).forEach(key => paramsArray.push(key + '=' + body.data[key])) | ||
if (paramsArray.length > 0) { | ||
body.path += '?' + paramsArray.join('&') | ||
} | ||
} | ||
} | ||
const response = await fetch(`${local[0]}/${body.path}`, guobaOptions) | ||
if (response.ok) { | ||
const json = await response.json() | ||
reply.send(json) | ||
} | ||
} else { | ||
reply.send({ state: false, error: '锅巴接口异常' }) | ||
} | ||
} | ||
catch (err) { | ||
console.error(err) | ||
reply.send({ state: false, error: err }) | ||
} | ||
} else { | ||
reply.send({ state: false, error: '用户权限不足' }) | ||
} | ||
return reply | ||
}) | ||
} | ||
|
||
export default Guoba |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.