@ibiz-template/model-helper 0.1.17 → 0.1.19

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.
package/dist/index.esm.js CHANGED
@@ -14918,11 +14918,12 @@ var ModelUtil = class {
14918
14918
  * @param {(url: string) => Promise<IModel>} get 模型加载方法
14919
14919
  * @param {boolean} hub 是否为 hub 应用基座
14920
14920
  */
14921
- constructor(appId, modelTag, get, hub) {
14921
+ constructor(appId, modelTag, get, hub, permission = true) {
14922
14922
  this.appId = appId;
14923
14923
  this.modelTag = modelTag;
14924
14924
  this.get = get;
14925
14925
  this.hub = hub;
14926
+ this.permission = permission;
14926
14927
  /**
14927
14928
  * 模型缓存
14928
14929
  *
@@ -14976,13 +14977,43 @@ var ModelUtil = class {
14976
14977
  */
14977
14978
  async getAppModel() {
14978
14979
  if (!this.appModel) {
14979
- this.appModel = await this.getModel(
14980
- this.hub && ibiz.env.hub ? "/PSSYSAPP.hub.json" : "/PSSYSAPP.json"
14981
- );
14980
+ let appPath = "/PSSYSAPP.json";
14981
+ if (this.hub && ibiz.env.hub) {
14982
+ appPath = "/PSSYSAPP.hub.json";
14983
+ }
14984
+ if (this.permission === false) {
14985
+ appPath = "/simple/PSSYSAPP.simple.json";
14986
+ }
14987
+ this.appModel = await this.getModel(appPath);
14982
14988
  this.appModel.id = this.appId;
14983
14989
  }
14984
14990
  return this.appModel;
14985
14991
  }
14992
+ /**
14993
+ * 加载应用模型全局样式
14994
+ *
14995
+ * @author chitanda
14996
+ * @date 2023-09-06 10:09:11
14997
+ * @return {*} {(Promise<string | null>)}
14998
+ */
14999
+ async getAppStyle() {
15000
+ let style = "";
15001
+ try {
15002
+ let stylePath = "/PSSYSAPP.json.css";
15003
+ if (this.hub && ibiz.env.hub) {
15004
+ stylePath = "/PSSYSAPP.hub.json.css";
15005
+ }
15006
+ if (this.permission === false) {
15007
+ stylePath = "/simple/PSSYSAPP.simple.json.css";
15008
+ }
15009
+ style = await this.getModel(stylePath);
15010
+ if (style) {
15011
+ return style;
15012
+ }
15013
+ } catch (error) {
15014
+ }
15015
+ return null;
15016
+ }
14986
15017
  /**
14987
15018
  * 根据应用实体 codeName 或者 id 获取应用实体模型
14988
15019
  *
@@ -15154,6 +15185,9 @@ var ModelLoader = class {
15154
15185
  getAppDataEntityByCodeName(appId, codeName) {
15155
15186
  return this.helper.getAppDataEntityModel(codeName, appId, false);
15156
15187
  }
15188
+ getAppStyle(appId) {
15189
+ return this.helper.getAppStyle(appId);
15190
+ }
15157
15191
  };
15158
15192
 
15159
15193
  // src/model-helper.ts
@@ -15164,10 +15198,12 @@ var ModelHelper = class {
15164
15198
  * @date 2023-04-16 17:04:01
15165
15199
  * @param {(url: string) => Promise<IModel>} getModel 模型加载方法
15166
15200
  * @param {string} defaultAppId 默认应用标识
15201
+ * @param {boolean} [permission=true] 是否启用权限
15167
15202
  */
15168
- constructor(getModel, defaultAppId) {
15203
+ constructor(getModel, defaultAppId, permission = true) {
15169
15204
  this.getModel = getModel;
15170
15205
  this.defaultAppId = defaultAppId;
15206
+ this.permission = permission;
15171
15207
  this.dsl = new DSLHelper();
15172
15208
  /**
15173
15209
  * 模型获取工具类缓存
@@ -15194,7 +15230,8 @@ var ModelHelper = class {
15194
15230
  appId,
15195
15231
  modelTag,
15196
15232
  this.getModel,
15197
- this.defaultAppId === appId
15233
+ this.defaultAppId === appId,
15234
+ this.permission
15198
15235
  );
15199
15236
  await modelUtil.init();
15200
15237
  this.cache.set(appId, modelUtil);
@@ -15253,6 +15290,17 @@ var ModelHelper = class {
15253
15290
  const app = this.dsl.application(model);
15254
15291
  return app;
15255
15292
  }
15293
+ /**
15294
+ * 获取应用全局样式
15295
+ *
15296
+ * @author chitanda
15297
+ * @date 2023-09-06 10:09:48
15298
+ * @param {(string | IObject)} [appId]
15299
+ * @return {*} {(Promise<string | null>)}
15300
+ */
15301
+ getAppStyle(appId) {
15302
+ return this.getModelUtil(appId).getAppStyle();
15303
+ }
15256
15304
  /**
15257
15305
  * 根据应用实体 codeName 获取应用实体模型
15258
15306
  *