refactor: 移除不再使用的轻代码路由,优化 OpenCode 客户端的端口配置
This commit is contained in:
@@ -2,8 +2,6 @@ import { app, assistantConfig } from '../app.ts';
|
||||
import './config/index.ts';
|
||||
import './shop-install/index.ts';
|
||||
import './ai/index.ts';
|
||||
// TODO:
|
||||
// import './light-code/index.ts';
|
||||
import './user/index.ts';
|
||||
import './call/index.ts'
|
||||
|
||||
@@ -64,18 +62,16 @@ export const checkAuth = async (ctx: any, isAdmin = false) => {
|
||||
}
|
||||
authCache.set(token, tokenUser);
|
||||
}
|
||||
if (ctx.state) {
|
||||
ctx.state = {
|
||||
...ctx.state,
|
||||
token,
|
||||
tokenUser,
|
||||
};
|
||||
}
|
||||
ctx.state = {
|
||||
...ctx.state,
|
||||
token,
|
||||
tokenUser,
|
||||
};
|
||||
const { username } = tokenUser;
|
||||
if (!auth.username) {
|
||||
// 初始管理员账号
|
||||
auth.username = username;
|
||||
assistantConfig.setConfig({ auth });
|
||||
assistantConfig.setConfig({ auth, token: token });
|
||||
}
|
||||
if (isAdmin && auth.username) {
|
||||
const admins = config.auth?.admin || [];
|
||||
@@ -83,6 +79,12 @@ export const checkAuth = async (ctx: any, isAdmin = false) => {
|
||||
const admin = auth.username;
|
||||
if (admin === username) {
|
||||
isCheckAdmin = true;
|
||||
const _token = config.token;
|
||||
if (!_token) {
|
||||
assistantConfig.setConfig({ token: token });
|
||||
} else if (_token && _token.startsWith('st-') && _token !== token) {
|
||||
assistantConfig.setConfig({ token: token });
|
||||
}
|
||||
}
|
||||
if (!isCheckAdmin && admins.length > 0 && admins.includes(username)) {
|
||||
isCheckAdmin = true;
|
||||
@@ -106,7 +108,7 @@ app
|
||||
description: '获取当前登录用户信息, 第一个登录的用户为管理员用户',
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
if (!ctx.query?.token && ctx.appId === app.appId) {
|
||||
if (!ctx.query?.token && ctx.appId === app.appId) {
|
||||
return;
|
||||
}
|
||||
const authResult = await checkAuth(ctx);
|
||||
@@ -122,7 +124,7 @@ app
|
||||
description: '管理员鉴权, 获取用户信息,并验证是否为管理员。',
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
logger.debug('query', ctx.query);
|
||||
// logger.debug('query', ctx.query);
|
||||
if (!ctx.query?.token && ctx.appId === app.appId) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user