feat: 助手配置与服务命令扩展及依赖更新

This commit is contained in:
2025-04-27 03:26:50 +08:00
parent f2abfbf17c
commit 75d181ef43
25 changed files with 296 additions and 64 deletions

View File

@@ -0,0 +1,27 @@
import { app, assistantConfig } from '@/app.ts';
// import { getCacheAssistantConfig, setConfig } from '@/modules/config/index.ts';
// import { reload } from '@/modules/parent-msg.ts';
app
.route({
path: 'config',
description: '获取配置',
})
.define(async (ctx) => {
ctx.body = assistantConfig.getCacheAssistantConfig();
})
.addTo(app);
app
.route({
path: 'config',
key: 'set',
description: '设置配置',
})
.define(async (ctx) => {
const { data } = ctx.query;
// reload();
ctx.body = assistantConfig.setConfig(data);
})
.addTo(app);

View File

@@ -0,0 +1,2 @@
import './config/index.ts'
import './shop-install/index.ts'

View File

@@ -0,0 +1,61 @@
import { app } from '@/app.ts';
// import { getInstallList, installApp, uninstallApp } from '@/modules/install.ts';
const getInstallList = async () => {
return [];
};
const installApp = async (pkg: string) => {
return {
code: 200,
message: 'success',
data: {
pkg,
},
};
};
const uninstallApp = async (pkg: string) => {
return {
code: 200,
message: 'success',
};
};
app
.route({
path: 'shop',
key: 'list-installed',
})
.define(async (ctx) => {
// https://localhost:51015/client/router?path=shop&key=list-installed
const list = await getInstallList();
ctx.body = list;
})
.addTo(app);
app
.route({
path: 'shop',
key: 'install',
})
.define(async (ctx) => {
// https://localhost:51015/client/router?path=shop&key=install
const { pkg } = ctx.query.data;
const res = await installApp(pkg);
if (res.code !== 200) {
ctx.throw(res.code, res.message);
}
ctx.body = res;
})
.addTo(app);
app
.route({
path: 'shop',
key: 'uninstall',
})
.define(async (ctx) => {
// https://localhost:51015/client/router?path=shop&key=uninstall
const { pkg } = ctx.query.data;
const res = await uninstallApp(pkg);
ctx.body = res;
})
.addTo(app);