@airpower/web 0.0.38 → 0.0.40

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.
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import { defineComponent, computed, createBlock, openBlock, unref, mergeProps, toHandlers, withCtx, createElementBlock, Fragment, renderList, ref } from "vue";
5
- import { AirDecorator, getFieldConfig, AirClassTransformer, HttpConfig, AirI18n, QueryPageResponse, QueryPageRequest, Page, AbstractHttp, HttpResponse, HttpStatus, AbstractEntityService } from "@airpower/core";
5
+ import { AirDecorator, getFieldConfig, AirClassTransformer, AirI18n, QueryPageResponse, QueryPageRequest, Page, HttpConfig, AbstractHttp, HttpResponse, HttpStatus, AbstractEntityService } from "@airpower/core";
6
6
  export * from "@airpower/core";
7
7
  import { ElTable, ElTableColumn, ElMessageBox, ElMessage } from "element-plus";
8
8
  import axios from "axios";
@@ -88,28 +88,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
88
88
  };
89
89
  }
90
90
  });
91
- class WebAccessToken {
92
- /**
93
- * ### 获取AccessToken
94
- */
95
- static getAccessToken() {
96
- var _a;
97
- return ((_a = localStorage.getItem(HttpConfig.authorizationHeaderKey)) == null ? void 0 : _a.toString()) || "";
98
- }
99
- /**
100
- * ### 设置AccessToken
101
- * @param accessToken AccessToken
102
- */
103
- static setAccessToken(accessToken) {
104
- localStorage.setItem(HttpConfig.authorizationHeaderKey, accessToken);
105
- }
106
- /**
107
- * ### 移除AccessToken
108
- */
109
- static removeAccessToken() {
110
- localStorage.removeItem(HttpConfig.authorizationHeaderKey);
111
- }
112
- }
113
91
  class WebI18n extends AirI18n {
114
92
  constructor() {
115
93
  super(...arguments);
@@ -122,31 +100,32 @@ class WebI18n extends AirI18n {
122
100
  __publicField(this, "SelectPlease", "请选择");
123
101
  __publicField(this, "DisableSuccess", "禁用成功");
124
102
  __publicField(this, "EnableSuccess", "启用成功");
103
+ __publicField(this, "Confirm", "确定");
104
+ __publicField(this, "Cancel", "取消");
105
+ __publicField(this, "ConfirmPlease", "请确认");
106
+ __publicField(this, "ConfirmToDisable", "是否确认禁用当前选择的数据?");
107
+ __publicField(this, "ConfirmToEnable", "是否确认启用当前选择的数据?");
108
+ __publicField(this, "ConfirmToDelete", "是否确认删除当前选择的数据?");
125
109
  }
126
110
  }
127
111
  class DetailController {
128
- constructor() {
112
+ /**
113
+ * ### 创建表格控制器
114
+ * @param ServiceClass 服务类
115
+ * @param props `defineProps` 的返回值
116
+ * @param option `可选` 更多的配置
117
+ */
118
+ constructor(ServiceClass, props, option = {}) {
129
119
  __publicField(this, "isLoading", ref(false));
130
120
  __publicField(this, "formData");
131
121
  __publicField(this, "title", ref(WebI18n.get().Detail));
132
122
  __publicField(this, "service");
133
123
  __publicField(this, "option", {});
134
- }
135
- /**
136
- * ### 创建详情控制器
137
- * @param props `defineProps` 的返回值
138
- * @param entityClass 详情使用的实体类
139
- * @param serviceClass 详情使用的 `Service`
140
- * @param option `可选` 更多的配置
141
- */
142
- static create(props, entityClass, serviceClass, option = {}) {
143
- const instance = new this();
144
- instance.service = AirClassTransformer.newInstance(serviceClass);
145
- instance.option = option;
146
- instance.service.setLoading(instance.isLoading);
147
- instance.formData = ref(props.param ? props.param.copy() : AirClassTransformer.newInstance(entityClass));
148
- instance.getDetail();
149
- return instance;
124
+ this.service = AirClassTransformer.newInstance(ServiceClass);
125
+ this.service.setLoading(this.isLoading);
126
+ this.option = option;
127
+ this.formData = ref(props.param ? props.param.copy() : AirClassTransformer.newInstance(this.service.entityClass));
128
+ this.getDetail();
150
129
  }
151
130
  /**
152
131
  * ### 查询详情方法
@@ -156,7 +135,7 @@ class DetailController {
156
135
  this.formData.value = await this.service.getDetail(this.formData.value.id, this.option.apiUrl);
157
136
  if (this.option.afterGetDetail) {
158
137
  const result = this.option.afterGetDetail(this.formData.value);
159
- if (result !== void 0) {
138
+ if (result) {
160
139
  this.formData.value = result;
161
140
  }
162
141
  }
@@ -184,7 +163,8 @@ class BaseTableController {
184
163
  __publicField(this, "option", {});
185
164
  this.service = AirClassTransformer.newInstance(ServiceClass);
186
165
  this.request = ref(new QueryPageRequest(this.service.entityClass));
187
- this.init();
166
+ this.service.setLoading(this.isLoading);
167
+ this.getList();
188
168
  }
189
169
  /**
190
170
  * ### 设置配置
@@ -288,13 +268,6 @@ class BaseTableController {
288
268
  this.request.value.page = page;
289
269
  this.getList();
290
270
  }
291
- /**
292
- * ### 初始化
293
- */
294
- init() {
295
- this.service.setLoading(this.isLoading);
296
- this.getList();
297
- }
298
271
  }
299
272
  class TableController extends BaseTableController {
300
273
  /**
@@ -317,6 +290,7 @@ class TableController extends BaseTableController {
317
290
  * @param row 行数据
318
291
  */
319
292
  async delete(row) {
293
+ await this.confirmPlease(WebI18n.get().ConfirmToDelete);
320
294
  await this.service.delete(row.id, WebI18n.get().DeleteSuccess);
321
295
  this.getList();
322
296
  }
@@ -325,15 +299,7 @@ class TableController extends BaseTableController {
325
299
  * @param row 行数据
326
300
  */
327
301
  async disable(row) {
328
- await ElMessageBox.confirm(
329
- "是否确认禁用当前选择的数据?",
330
- "禁用提醒",
331
- {
332
- confirmButtonText: "确认禁用",
333
- cancelButtonText: "取消",
334
- type: "warning"
335
- }
336
- );
302
+ await this.confirmPlease(WebI18n.get().ConfirmToDisable);
337
303
  await this.service.disable(row.id, WebI18n.get().DisableSuccess);
338
304
  this.getList();
339
305
  }
@@ -342,17 +308,24 @@ class TableController extends BaseTableController {
342
308
  * @param row 行数据
343
309
  */
344
310
  async enable(row) {
311
+ await this.confirmPlease(WebI18n.get().ConfirmToEnable);
312
+ await this.service.enable(row.id, WebI18n.get().EnableSuccess);
313
+ this.getList();
314
+ }
315
+ /**
316
+ * ### 确认提示
317
+ * @param message 提示信息
318
+ */
319
+ async confirmPlease(message) {
345
320
  await ElMessageBox.confirm(
346
- "是否确认启用当前选择的数据?",
347
- "启用提醒",
321
+ message,
322
+ WebI18n.get().ConfirmPlease,
348
323
  {
349
- confirmButtonText: "确认启用",
350
- cancelButtonText: "取消",
324
+ confirmButtonText: WebI18n.get().Confirm,
325
+ cancelButtonText: WebI18n.get().Cancel,
351
326
  type: "warning"
352
327
  }
353
328
  );
354
- await this.service.enable(row.id, WebI18n.get().EnableSuccess);
355
- this.getList();
356
329
  }
357
330
  }
358
331
  class TableTreeController extends TableController {
@@ -380,6 +353,28 @@ class TableTreeController extends TableController {
380
353
  }
381
354
  }
382
355
  }
356
+ class WebAccessToken {
357
+ /**
358
+ * ### 获取AccessToken
359
+ */
360
+ static getAccessToken() {
361
+ var _a;
362
+ return ((_a = localStorage.getItem(HttpConfig.authorizationHeaderKey)) == null ? void 0 : _a.toString()) || "";
363
+ }
364
+ /**
365
+ * ### 设置AccessToken
366
+ * @param accessToken AccessToken
367
+ */
368
+ static setAccessToken(accessToken) {
369
+ localStorage.setItem(HttpConfig.authorizationHeaderKey, accessToken);
370
+ }
371
+ /**
372
+ * ### 移除AccessToken
373
+ */
374
+ static removeAccessToken() {
375
+ localStorage.removeItem(HttpConfig.authorizationHeaderKey);
376
+ }
377
+ }
383
378
  class WebHttp extends AbstractHttp {
384
379
  constructor() {
385
380
  super(...arguments);
@@ -1,4 +1,4 @@
1
- import { AirEntity, ClassConstructor, IJson } from '@airpower/core';
1
+ import { AirEntity, IJson } from '@airpower/core';
2
2
  import { Ref } from 'vue';
3
3
  import { AbstractWebService } from '../service';
4
4
  import { IDetailControllerOption } from './interface';
@@ -14,13 +14,14 @@ export declare class DetailController<E extends AirEntity, S extends AbstractWeb
14
14
  protected service: S;
15
15
  protected option: O;
16
16
  /**
17
- * ### 创建详情控制器
17
+ * ### 创建表格控制器
18
+ * @param ServiceClass 服务类
18
19
  * @param props `defineProps` 的返回值
19
- * @param entityClass 详情使用的实体类
20
- * @param serviceClass 详情使用的 `Service`
21
20
  * @param option `可选` 更多的配置
22
21
  */
23
- static create<T extends DetailController<E, S>, E extends AirEntity, S extends AbstractWebService<E>>(this: ClassConstructor<T>, props: IJson, entityClass: ClassConstructor<E>, serviceClass: ClassConstructor<S>, option?: IDetailControllerOption<E>): T;
22
+ constructor(ServiceClass: new () => S & {
23
+ entityClass: new () => E;
24
+ }, props: IJson, option?: O);
24
25
  /**
25
26
  * ### 查询详情方法
26
27
  */
@@ -65,8 +65,4 @@ export declare class BaseTableController<E extends AirEntity, S extends Abstract
65
65
  * @param page 分页对象
66
66
  */
67
67
  pageChanged(page: Page): Promise<void>;
68
- /**
69
- * ### 初始化
70
- */
71
- private init;
72
68
  }
@@ -28,4 +28,9 @@ export declare class TableController<E extends AirEntity, S extends AbstractWebS
28
28
  * @param row 行数据
29
29
  */
30
30
  enable(row: E): Promise<void>;
31
+ /**
32
+ * ### 确认提示
33
+ * @param message 提示信息
34
+ */
35
+ private confirmPlease;
31
36
  }
@@ -1,2 +1 @@
1
1
  export * from './WebAccessToken';
2
- export * from './WebI18n';
@@ -14,4 +14,10 @@ export declare class WebI18n extends AirI18n {
14
14
  SelectPlease: string;
15
15
  DisableSuccess: string;
16
16
  EnableSuccess: string;
17
+ Confirm: string;
18
+ Cancel: string;
19
+ ConfirmPlease: string;
20
+ ConfirmToDisable: string;
21
+ ConfirmToEnable: string;
22
+ ConfirmToDelete: string;
17
23
  }
@@ -0,0 +1 @@
1
+ export * from './WebI18n';
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './controller';
3
3
  export * from './decorator';
4
4
  export * from './helper';
5
5
  export * from './http';
6
+ export * from './i18n';
6
7
  export * from './service';
7
8
  export * from './shared';
8
9
  export * from './type';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@airpower/web",
3
3
  "type": "module",
4
- "version": "0.0.38",
4
+ "version": "0.0.40",
5
5
  "description": "AirPower-Web",
6
6
  "author": {
7
7
  "name": "Hamm",