midway-fatcms 0.0.1-beta.33 → 0.0.1-beta.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -185,5 +185,7 @@ exports.default = (appInfo) => {
185
185
  fatcmsScheduleService: true,
186
186
  // Excel导出文件的临时目录
187
187
  fatcmsExportExcelTmpFilePath: (0, path_1.join)((0, os_1.tmpdir)(), 'fatcms-export-excel'),
188
+ // 在某些场景下,只有一个workbench code。如果启用了此配置,则不再根据域名配置识别Workbench.
189
+ fatcmsTargetWorkbenchCode: null
188
190
  };
189
191
  };
@@ -11,7 +11,6 @@ interface HttpGetRes {
11
11
  */
12
12
  export declare class StaticController extends BaseApiController {
13
13
  protected ctx: Context;
14
- constructor();
15
14
  private getLocalPaths;
16
15
  private initNotFoundList;
17
16
  private responseLocalFile;
@@ -20,6 +20,7 @@ const fs2 = require("fs");
20
20
  const path = require("path");
21
21
  const https = require("https");
22
22
  const functions_1 = require("../../libs/utils/functions");
23
+ const schedule_1 = require("../../schedule");
23
24
  function getPathConfig(ossName) {
24
25
  const remoteBaseUrlMap = {
25
26
  cdnjsx: 'https://cdnjsx.oss-cn-shanghai.aliyuncs.com',
@@ -43,12 +44,9 @@ let notFoundListIsInit = false;
43
44
  * 静态文件代理功能
44
45
  */
45
46
  let StaticController = class StaticController extends BaseApiController_1.BaseApiController {
46
- constructor() {
47
- super();
48
- this.initNotFoundList();
49
- }
50
47
  getLocalPaths() {
51
- const appDir = this.app.getAppDir();
48
+ const app = schedule_1.ANONYMOUS_CONTEXT.getApp();
49
+ const appDir = app.getAppDir();
52
50
  const localDir = path.join(appDir, './public/static'); // 本地文件存储目录
53
51
  const notFoundListFile = path.join(localDir, '__404__list.json'); // 404列表文件
54
52
  return {
@@ -125,6 +123,7 @@ let StaticController = class StaticController extends BaseApiController_1.BaseAp
125
123
  return false;
126
124
  }
127
125
  async proxyStaticFile(ossName, relativePath) {
126
+ await this.initNotFoundList();
128
127
  const { localDir } = this.getLocalPaths();
129
128
  const PATH_CONFIG = getPathConfig(ossName);
130
129
  // 构建本地路径和远程路径
@@ -282,7 +281,6 @@ __decorate([
282
281
  __metadata("design:returntype", Promise)
283
282
  ], StaticController.prototype, "proxyStaticFile", null);
284
283
  StaticController = __decorate([
285
- (0, core_1.Controller)('/ns/static'),
286
- __metadata("design:paramtypes", [])
284
+ (0, core_1.Controller)('/ns/static')
287
285
  ], StaticController);
288
286
  exports.StaticController = StaticController;
@@ -5,6 +5,7 @@ import { IScheduleService } from '../interface';
5
5
  export declare class WorkbenchService extends BaseService implements IScheduleService {
6
6
  ctx: Context;
7
7
  private curdProService;
8
+ private fatcmsTargetWorkbenchCode;
8
9
  clearCache(): void;
9
10
  runBySchedule(): Promise<void>;
10
11
  /**
@@ -134,6 +134,11 @@ let WorkbenchService = class WorkbenchService extends BaseService_1.BaseService
134
134
  if (asyncTaskWorkbenchCode && typeof asyncTaskWorkbenchCode === 'string') {
135
135
  return await this.getWorkbenchInfoByCode(asyncTaskWorkbenchCode);
136
136
  }
137
+ // 只有一个workbench的场景。对于后台系统。不需要配置域名的场景。
138
+ const fatcmsTargetWorkbenchCode = this.fatcmsTargetWorkbenchCode;
139
+ if (typeof fatcmsTargetWorkbenchCode === "string" && fatcmsTargetWorkbenchCode.length > 3) {
140
+ return await this.getWorkbenchInfoByCode(fatcmsTargetWorkbenchCode);
141
+ }
137
142
  //正式环境: 根据域名获取站点配置
138
143
  const host = this.getCurrentHost();
139
144
  const workbenchInfo = await this.getWorkbenchInfoByHost(host);
@@ -196,6 +201,10 @@ __decorate([
196
201
  (0, core_1.Inject)(),
197
202
  __metadata("design:type", CurdProService_1.CurdProService)
198
203
  ], WorkbenchService.prototype, "curdProService", void 0);
204
+ __decorate([
205
+ (0, core_1.Config)('fatcmsTargetWorkbenchCode'),
206
+ __metadata("design:type", String)
207
+ ], WorkbenchService.prototype, "fatcmsTargetWorkbenchCode", void 0);
199
208
  WorkbenchService = __decorate([
200
209
  (0, core_1.Provide)()
201
210
  ], WorkbenchService);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "midway-fatcms",
3
- "version": "0.0.1-beta.33",
3
+ "version": "0.0.1-beta.36",
4
4
  "description": "This is a midway component sample",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",