Merge pull request #854 from Bluemangoo/main-829

https://github.com/MCSManager/MCSManager/issues/829
This commit is contained in:
unitwk 2023-03-27 11:01:58 +08:00 committed by GitHub
commit e7e68d328e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,7 @@ import { isTopPermissionByUuid } from "../../service/permission_service";
import { isEmpty, toText } from "../../../app/common/typecheck";
import { toBoolean } from "../../../app/common/typecheck";
import { toNumber } from "../../../app/common/typecheck";
const router = new Router({ prefix: "/protected_instance" });
// Routing permission verification middleware
@ -422,9 +423,22 @@ router.get(
const serviceUuid = String(ctx.query.remote_uuid);
const instanceUuid = String(ctx.query.uuid);
const remoteService = RemoteServiceSubsystem.getInstance(serviceUuid);
const result = await new RemoteRequest(remoteService).request("instance/outputlog", {
let result = await new RemoteRequest(remoteService).request("instance/outputlog", {
instanceUuid
});
if (ctx.query.size) {
let size, sizeStr = ctx.query.size;
if (sizeStr instanceof Array) {
sizeStr = sizeStr[0];
}
size = parseInt(sizeStr);
if (sizeStr.toLowerCase().endsWith("kb")) {
size *= 1024;
}
if (result.length > size) {
result = result.slice(-size);
}
}
ctx.body = result;
} catch (err) {
ctx.body = err;