Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-02-18 03:37:45 +08:00
parent 63edd0fd84
commit f33d4c293d
12 changed files with 433 additions and 204 deletions

View File

@@ -54,15 +54,4 @@ export const simpleRouter = useContextKey('simpleRouter', () => {
return new SimpleRouter();
});
app.route({
path: 'router',
key: 'list',
description: '获取路由列表',
}).define(async (ctx) => {
const list = ctx.app.getList((item) => {
if (item?.path?.includes?.('auth') || item?.id?.includes?.('auth')) return false;
return true;
})
console.log('路由列表:', list.length);
ctx.body = { list }
}).addTo(app);
app.createRouteList()

View File

@@ -11,7 +11,7 @@ app
path: 'ai',
key: 'chat',
description: '与 AI 进行对话, 调用 GPT 的AI 服务,生成结果,并返回。',
middleware: ['admin-auth'],
middleware: ['auth-admin'],
metadata: {
admin: true,
}

View File

@@ -59,7 +59,7 @@ app.route({
path: 'client',
key: 'restart',
description: '重启客户端',
middleware: ['admin-auth'],
middleware: ['auth-admin'],
metadata: {
tags: ['opencode'],
...createSkill({

View File

@@ -5,7 +5,7 @@ app
.route({
path: 'config',
description: '获取配置',
middleware: ['admin-auth'],
middleware: ['auth-admin'],
})
.define(async (ctx) => {
ctx.body = assistantConfig.getCacheAssistantConfig();
@@ -17,7 +17,7 @@ app
path: 'config',
key: 'set',
description: '设置配置',
middleware: ['admin-auth'],
middleware: ['auth-admin'],
})
.define(async (ctx) => {
const { data } = ctx.query;

View File

@@ -118,8 +118,8 @@ app
.addTo(app);
app
.route({
path: 'admin-auth',
id: 'admin-auth',
path: 'auth-admin',
id: 'auth-admin',
description: '管理员鉴权, 获取用户信息,并验证是否为管理员。',
})
.define(async (ctx) => {

View File

@@ -8,7 +8,7 @@ app.route({
path: 'kevisual',
key: ' me',
description: '查看 ev cli 是否登录',
middleware: ['admin-auth'],
middleware: ['auth-admin'],
metadata: {
tags: ['opencode'],
...createSkill({
@@ -36,7 +36,7 @@ app.route({
path: 'kevisual',
key: 'loginByAdmin',
description: '通过当前登录用户 ev cli',
middleware: ['admin-auth'],
middleware: ['auth-admin'],
metadata: {
tags: ['opencode'],
...createSkill({

View File

@@ -7,7 +7,7 @@ app.route({
path: 'kevisual',
key: 'deploy',
description: '部署一个网页',
middleware: ['admin-auth'],
middleware: ['auth-admin'],
metadata: {
tags: ['kevisual'],
...createSkill({

View File

@@ -5,7 +5,7 @@ import { AssistantApp } from "@/lib.ts";
app.route({
path: 'remote',
key: 'status',
middleware: ['admin-auth'],
middleware: ['auth-admin'],
description: '获取远程app连接状态',
}).define(async (ctx) => {
const manager = useContextKey('manager') as AssistantApp;
@@ -24,7 +24,7 @@ app.route({
app.route({
path: 'remote',
key: 'connect',
middleware: ['admin-auth'],
middleware: ['auth-admin'],
description: '连接远程app',
}).define(async (ctx) => {
const manager = useContextKey('manager') as AssistantApp;

View File

@@ -6,7 +6,7 @@ app
path: 'shop',
key: 'get-registry',
description: '获取应用商店注册表信息',
middleware: ['admin-auth'],
middleware: ['auth-admin'],
metadata: {
admin: true,
}
@@ -23,7 +23,7 @@ app
path: 'shop',
key: 'list-installed',
description: '列出当前已安装的所有应用',
middleware: ['admin-auth'],
middleware: ['auth-admin'],
metadata: {
admin: true,
}
@@ -41,7 +41,7 @@ app
path: 'shop',
key: 'install',
description: '安装指定的应用,可以指定 id、type、force 和 yes 参数',
middleware: ['admin-auth'],
middleware: ['auth-admin'],
metadata: {
admin: true,
}
@@ -68,7 +68,7 @@ app
path: 'shop',
key: 'uninstall',
description: '卸载指定的应用,可以指定 id 和 type 参数',
middleware: ['admin-auth'],
middleware: ['auth-admin'],
metadata: {
admin: true,
}