fix: fix hot-api for not build in bun app.mjs
This commit is contained in:
@@ -4,10 +4,10 @@ import { spawnSync } from 'node:child_process';
|
||||
const command = new Command('server')
|
||||
.description('启动服务')
|
||||
.option('-d, --daemon', '是否以守护进程方式运行')
|
||||
.option('-n, --name <name>', '服务名称')
|
||||
.option('-n, --name <name>', '服务名称', 'assistant-server')
|
||||
.option('-p, --port <port>', '服务端口')
|
||||
.option('-s, --start', '是否启动服务')
|
||||
.option('-i, --home', '是否以home方式运行')
|
||||
.option('-e, --interpreter <interpreter>', '指定使用的解释器', 'bun')
|
||||
.action((options) => {
|
||||
const { port } = options;
|
||||
const [_interpreter, execPath] = process.argv;
|
||||
@@ -24,8 +24,8 @@ const command = new Command('server')
|
||||
if (port) {
|
||||
shellCommands.push(`-p ${port}`);
|
||||
}
|
||||
if (options.home) {
|
||||
shellCommands.push('--home');
|
||||
if (options.interpreter) {
|
||||
shellCommands.push(`-e ${options.interpreter}`);
|
||||
}
|
||||
const basename = _interpreter.split('/').pop();
|
||||
|
||||
|
||||
19
assistant/src/routes/hot-api/key-sender/index.ts
Normal file
19
assistant/src/routes/hot-api/key-sender/index.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { app } from '@/app.ts';
|
||||
import { Hotkeys } from '@kevisual/hot-api';
|
||||
import { useContextKey } from '@kevisual/context';
|
||||
app.route({
|
||||
path: 'key-sender',
|
||||
middleware: ['admin-auth']
|
||||
}).define(async (ctx) => {
|
||||
let keys = ctx.query.keys;
|
||||
if (keys.includes(' ')) {
|
||||
keys = keys.replace(/\s+/g, '+');
|
||||
}
|
||||
const hotKeys: Hotkeys = useContextKey('hotkeys', () => new Hotkeys());
|
||||
if (typeof keys === 'string') {
|
||||
await hotKeys.pressHotkey({
|
||||
hotkey: keys,
|
||||
});
|
||||
}
|
||||
ctx.body = 'ok';
|
||||
}).addTo(app);
|
||||
@@ -2,8 +2,10 @@ import { app, assistantConfig } from '../app.ts';
|
||||
import './config/index.ts';
|
||||
import './shop-install/index.ts';
|
||||
import './ai/index.ts';
|
||||
import './light-code/index.ts';
|
||||
// TODO:
|
||||
// import './light-code/index.ts';
|
||||
import './user/index.ts';
|
||||
import './hot-api/key-sender/index.ts';
|
||||
|
||||
import os from 'node:os';
|
||||
import { authCache } from '@/module/cache/auth.ts';
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { app, assistantConfig } from '@/app.ts';
|
||||
import { AppDownload } from '@/services/app/index.ts';
|
||||
import { AssistantApp } from '@/module/assistant/index.ts';
|
||||
import { shopDefine } from './define.ts';
|
||||
app
|
||||
.route({
|
||||
...shopDefine.get('getRegistry'),
|
||||
middleware: ['admin-auth'],
|
||||
path: 'shop',
|
||||
key: 'get-registry',
|
||||
description: '获取应用商店注册表信息',
|
||||
middleware: ['admin-auth'],
|
||||
metadata: {
|
||||
admin: true,
|
||||
}
|
||||
@@ -19,7 +20,9 @@ app
|
||||
|
||||
app
|
||||
.route({
|
||||
...shopDefine.get('listInstalled'),
|
||||
path: 'shop',
|
||||
key: 'list-installed',
|
||||
description: '列出当前已安装的所有应用',
|
||||
middleware: ['admin-auth'],
|
||||
metadata: {
|
||||
admin: true,
|
||||
@@ -35,7 +38,9 @@ app
|
||||
|
||||
app
|
||||
.route({
|
||||
...shopDefine.get('install'),
|
||||
path: 'shop',
|
||||
key: 'install',
|
||||
description: '安装指定的应用,可以指定 id、type、force 和 yes 参数',
|
||||
middleware: ['admin-auth'],
|
||||
metadata: {
|
||||
admin: true,
|
||||
@@ -60,7 +65,9 @@ app
|
||||
|
||||
app
|
||||
.route({
|
||||
...shopDefine.get('uninstall'),
|
||||
path: 'shop',
|
||||
key: 'uninstall',
|
||||
description: '卸载指定的应用,可以指定 id 和 type 参数',
|
||||
middleware: ['admin-auth'],
|
||||
metadata: {
|
||||
admin: true,
|
||||
|
||||
@@ -7,7 +7,7 @@ app.route({
|
||||
}).define(async (ctx) => {
|
||||
const { username, password } = ctx.query;
|
||||
const query = assistantConfig.query;
|
||||
const auth = assistantConfig.getConfig().auth;
|
||||
const auth = assistantConfig.getConfig().auth || {};
|
||||
const res = await query.post({
|
||||
path: 'user',
|
||||
key: 'login',
|
||||
@@ -25,7 +25,7 @@ app.route({
|
||||
}
|
||||
if (!auth.username) {
|
||||
// 初始管理员账号
|
||||
auth.username = 'admin';
|
||||
auth.username = loginUser;
|
||||
assistantConfig.setConfig({ auth });
|
||||
}
|
||||
// 保存配置
|
||||
|
||||
Reference in New Issue
Block a user