youzanyun-devtool-worker
Version:
54 lines (53 loc) • 2.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const spring4js_nodejs_1 = require("spring4js-nodejs");
const BaseController_1 = tslib_1.__importDefault(require("../BaseController"));
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
const path_1 = tslib_1.__importDefault(require("path"));
let BuiltInAppController = class BuiltInAppController extends BaseController_1.default {
async setTarget(ctx, next) {
const { target, workbenchId } = ctx.query;
const dir = await this.configService.getDataDir();
const filePath = path_1.default.join(dir, "target.json");
if (target) {
await fs_extra_1.default.writeJSON(filePath, { target });
}
await this.sideBarService.closeMenu(workbenchId, null);
ctx.body = {
code: 200,
data: {},
message: "success",
success: true,
msg: "success",
};
}
async getTarget(ctx, next) {
const dir = await this.configService.getDataDir();
const filePath = path_1.default.join(dir, "target.json");
const { target } = await fs_extra_1.default.readJson(filePath);
ctx.body = {
code: 200,
data: { target },
message: "success",
success: true,
msg: "success",
};
}
};
tslib_1.__decorate([
(0, spring4js_nodejs_1.Resource)()
], BuiltInAppController.prototype, "configService", void 0);
tslib_1.__decorate([
(0, spring4js_nodejs_1.Resource)()
], BuiltInAppController.prototype, "sideBarService", void 0);
tslib_1.__decorate([
(0, spring4js_nodejs_1.Path)("set-target", spring4js_nodejs_1.HttpMethod.PUT)
], BuiltInAppController.prototype, "setTarget", null);
tslib_1.__decorate([
(0, spring4js_nodejs_1.Path)("get-target", spring4js_nodejs_1.HttpMethod.GET)
], BuiltInAppController.prototype, "getTarget", null);
BuiltInAppController = tslib_1.__decorate([
(0, spring4js_nodejs_1.Controller)("/api/built-in-app/")
], BuiltInAppController);
exports.default = BuiltInAppController;