@airpower/web 0.0.6 → 0.0.7
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/airpower.es.js +40 -37
- package/dist/airpower.umd.js +40 -37
- package/package.json +2 -2
package/dist/airpower.es.js
CHANGED
|
@@ -920,10 +920,36 @@ const _AirDesensitize = class _AirDesensitize2 {
|
|
|
920
920
|
};
|
|
921
921
|
__publicField2(_AirDesensitize, "IP_V4_PART_COUNT", 4);
|
|
922
922
|
class AirEvent {
|
|
923
|
+
constructor() {
|
|
924
|
+
__publicField2(this, "listeners", /* @__PURE__ */ new Map());
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* ### 发出事件
|
|
928
|
+
* @param type 事件类型
|
|
929
|
+
* @param args 参数
|
|
930
|
+
*/
|
|
931
|
+
emit(type, ...args) {
|
|
932
|
+
const callbacks = this.listeners.get(type) || [];
|
|
933
|
+
callbacks.forEach((callback) => {
|
|
934
|
+
callback(...args);
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* ### 取消监听事件
|
|
939
|
+
* @param type 事件类型
|
|
940
|
+
* @param callback 回调方法
|
|
941
|
+
*/
|
|
942
|
+
off(type, callback) {
|
|
943
|
+
const callbacks = this.listeners.get(type) || [];
|
|
944
|
+
const index = callbacks.indexOf(callback);
|
|
945
|
+
if (index !== -1) {
|
|
946
|
+
callbacks.splice(index, 1);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
923
949
|
/**
|
|
924
950
|
* ### 监听多个事件
|
|
925
951
|
*/
|
|
926
|
-
|
|
952
|
+
onAll(types, callback) {
|
|
927
953
|
types.forEach((type) => {
|
|
928
954
|
this.on(type, callback);
|
|
929
955
|
});
|
|
@@ -933,7 +959,7 @@ class AirEvent {
|
|
|
933
959
|
* @param type 事件类型
|
|
934
960
|
* @param callback 回调方法
|
|
935
961
|
*/
|
|
936
|
-
|
|
962
|
+
on(type, callback) {
|
|
937
963
|
const callbacks = this.listeners.get(type) || [];
|
|
938
964
|
callbacks.push(callback);
|
|
939
965
|
this.listeners.set(type, callbacks);
|
|
@@ -943,38 +969,15 @@ class AirEvent {
|
|
|
943
969
|
* @param type 事件类型
|
|
944
970
|
* @param callback 回调方法
|
|
945
971
|
*/
|
|
946
|
-
|
|
972
|
+
once(type, callback) {
|
|
947
973
|
const onceCallback = (...args) => {
|
|
948
974
|
callback(...args);
|
|
949
975
|
this.off(type, onceCallback);
|
|
950
976
|
};
|
|
951
977
|
this.on(type, onceCallback);
|
|
952
978
|
}
|
|
953
|
-
/**
|
|
954
|
-
* ### 发出事件
|
|
955
|
-
* @param type 事件类型
|
|
956
|
-
* @param args 参数
|
|
957
|
-
*/
|
|
958
|
-
static emit(type, ...args) {
|
|
959
|
-
const callbacks = this.listeners.get(type) || [];
|
|
960
|
-
callbacks.forEach((callback) => {
|
|
961
|
-
callback(...args);
|
|
962
|
-
});
|
|
963
|
-
}
|
|
964
|
-
/**
|
|
965
|
-
* ### 取消监听事件
|
|
966
|
-
* @param type 事件类型
|
|
967
|
-
* @param callback 回调方法
|
|
968
|
-
*/
|
|
969
|
-
static off(type, callback) {
|
|
970
|
-
const callbacks = this.listeners.get(type) || [];
|
|
971
|
-
const index = callbacks.indexOf(callback);
|
|
972
|
-
if (index !== -1) {
|
|
973
|
-
callbacks.splice(index, 1);
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
979
|
}
|
|
977
|
-
|
|
980
|
+
const AirEvent$1 = new AirEvent();
|
|
978
981
|
var AirLanguage = /* @__PURE__ */ ((AirLanguage2) => {
|
|
979
982
|
AirLanguage2["English"] = "English";
|
|
980
983
|
AirLanguage2["ChineseSimplified"] = "简体中文";
|
|
@@ -8113,7 +8116,7 @@ class AbstractHttp {
|
|
|
8113
8116
|
reject(new HttpResponseError(response.message, response.code));
|
|
8114
8117
|
return;
|
|
8115
8118
|
}
|
|
8116
|
-
AirEvent.emit(CoreEvents.NEED_LOGIN, response);
|
|
8119
|
+
AirEvent$1.emit(CoreEvents.NEED_LOGIN, response);
|
|
8117
8120
|
return;
|
|
8118
8121
|
}
|
|
8119
8122
|
if (response.code !== CoreConfig.successCode) {
|
|
@@ -8121,7 +8124,7 @@ class AbstractHttp {
|
|
|
8121
8124
|
reject(new HttpResponseError(response.message, response.code));
|
|
8122
8125
|
return;
|
|
8123
8126
|
}
|
|
8124
|
-
AirEvent.emit(CoreEvents.HTTP_ERROR, response);
|
|
8127
|
+
AirEvent$1.emit(CoreEvents.HTTP_ERROR, response);
|
|
8125
8128
|
return;
|
|
8126
8129
|
}
|
|
8127
8130
|
resolve(response.data);
|
|
@@ -8371,7 +8374,7 @@ class AbstractEntityService extends AbstractService {
|
|
|
8371
8374
|
*/
|
|
8372
8375
|
async add(data, message, title = "添加成功", apiUrl = this.urlForAdd) {
|
|
8373
8376
|
const saved = await this.api(apiUrl).postGet(data, this.entityClass);
|
|
8374
|
-
AirEvent.emit(CoreEvents.ADD_SUCCESS, title, message, saved);
|
|
8377
|
+
AirEvent$1.emit(CoreEvents.ADD_SUCCESS, title, message, saved);
|
|
8375
8378
|
return saved.id;
|
|
8376
8379
|
}
|
|
8377
8380
|
/**
|
|
@@ -8383,7 +8386,7 @@ class AbstractEntityService extends AbstractService {
|
|
|
8383
8386
|
*/
|
|
8384
8387
|
async update(data, message, title = "修改成功", apiUrl = this.urlForUpdate) {
|
|
8385
8388
|
await this.api(apiUrl).post(data);
|
|
8386
|
-
AirEvent.emit(CoreEvents.UPDATE_SUCCESS, title, message, data);
|
|
8389
|
+
AirEvent$1.emit(CoreEvents.UPDATE_SUCCESS, title, message, data);
|
|
8387
8390
|
}
|
|
8388
8391
|
/**
|
|
8389
8392
|
* ### 保存一条数据并返回主键 `ID`
|
|
@@ -8411,9 +8414,9 @@ class AbstractEntityService extends AbstractService {
|
|
|
8411
8414
|
const instance = this.newEntityInstance(id);
|
|
8412
8415
|
try {
|
|
8413
8416
|
await this.api(apiUrl).callbackError().post(instance);
|
|
8414
|
-
AirEvent.emit(CoreEvents.DELETE_SUCCESS, title, message, instance);
|
|
8417
|
+
AirEvent$1.emit(CoreEvents.DELETE_SUCCESS, title, message, instance);
|
|
8415
8418
|
} catch (err) {
|
|
8416
|
-
AirEvent.emit(CoreEvents.DELETE_FAIL, "删除失败", err.message, instance);
|
|
8419
|
+
AirEvent$1.emit(CoreEvents.DELETE_FAIL, "删除失败", err.message, instance);
|
|
8417
8420
|
}
|
|
8418
8421
|
}
|
|
8419
8422
|
/**
|
|
@@ -8427,9 +8430,9 @@ class AbstractEntityService extends AbstractService {
|
|
|
8427
8430
|
const instance = this.newEntityInstance(id);
|
|
8428
8431
|
try {
|
|
8429
8432
|
await this.api(apiUrl).callbackError().addHttpHeader("a", "b").post(instance);
|
|
8430
|
-
AirEvent.emit(CoreEvents.DISABLE_SUCCESS, title, message, instance);
|
|
8433
|
+
AirEvent$1.emit(CoreEvents.DISABLE_SUCCESS, title, message, instance);
|
|
8431
8434
|
} catch (err) {
|
|
8432
|
-
AirEvent.emit(CoreEvents.ENABLE_FAIL, "禁用失败", err.message, instance);
|
|
8435
|
+
AirEvent$1.emit(CoreEvents.ENABLE_FAIL, "禁用失败", err.message, instance);
|
|
8433
8436
|
}
|
|
8434
8437
|
}
|
|
8435
8438
|
/**
|
|
@@ -8443,9 +8446,9 @@ class AbstractEntityService extends AbstractService {
|
|
|
8443
8446
|
const instance = this.newEntityInstance(id);
|
|
8444
8447
|
try {
|
|
8445
8448
|
await this.api(apiUrl).callbackError().post(this.newEntityInstance(id));
|
|
8446
|
-
AirEvent.emit(CoreEvents.ENABLE_SUCCESS, title, message, instance);
|
|
8449
|
+
AirEvent$1.emit(CoreEvents.ENABLE_SUCCESS, title, message, instance);
|
|
8447
8450
|
} catch (err) {
|
|
8448
|
-
AirEvent.emit(CoreEvents.ENABLE_FAIL, "启用失败", err.message, instance);
|
|
8451
|
+
AirEvent$1.emit(CoreEvents.ENABLE_FAIL, "启用失败", err.message, instance);
|
|
8449
8452
|
}
|
|
8450
8453
|
}
|
|
8451
8454
|
/**
|
package/dist/airpower.umd.js
CHANGED
|
@@ -924,10 +924,36 @@
|
|
|
924
924
|
};
|
|
925
925
|
__publicField2(_AirDesensitize, "IP_V4_PART_COUNT", 4);
|
|
926
926
|
class AirEvent {
|
|
927
|
+
constructor() {
|
|
928
|
+
__publicField2(this, "listeners", /* @__PURE__ */ new Map());
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* ### 发出事件
|
|
932
|
+
* @param type 事件类型
|
|
933
|
+
* @param args 参数
|
|
934
|
+
*/
|
|
935
|
+
emit(type, ...args) {
|
|
936
|
+
const callbacks = this.listeners.get(type) || [];
|
|
937
|
+
callbacks.forEach((callback) => {
|
|
938
|
+
callback(...args);
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* ### 取消监听事件
|
|
943
|
+
* @param type 事件类型
|
|
944
|
+
* @param callback 回调方法
|
|
945
|
+
*/
|
|
946
|
+
off(type, callback) {
|
|
947
|
+
const callbacks = this.listeners.get(type) || [];
|
|
948
|
+
const index = callbacks.indexOf(callback);
|
|
949
|
+
if (index !== -1) {
|
|
950
|
+
callbacks.splice(index, 1);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
927
953
|
/**
|
|
928
954
|
* ### 监听多个事件
|
|
929
955
|
*/
|
|
930
|
-
|
|
956
|
+
onAll(types, callback) {
|
|
931
957
|
types.forEach((type) => {
|
|
932
958
|
this.on(type, callback);
|
|
933
959
|
});
|
|
@@ -937,7 +963,7 @@
|
|
|
937
963
|
* @param type 事件类型
|
|
938
964
|
* @param callback 回调方法
|
|
939
965
|
*/
|
|
940
|
-
|
|
966
|
+
on(type, callback) {
|
|
941
967
|
const callbacks = this.listeners.get(type) || [];
|
|
942
968
|
callbacks.push(callback);
|
|
943
969
|
this.listeners.set(type, callbacks);
|
|
@@ -947,38 +973,15 @@
|
|
|
947
973
|
* @param type 事件类型
|
|
948
974
|
* @param callback 回调方法
|
|
949
975
|
*/
|
|
950
|
-
|
|
976
|
+
once(type, callback) {
|
|
951
977
|
const onceCallback = (...args) => {
|
|
952
978
|
callback(...args);
|
|
953
979
|
this.off(type, onceCallback);
|
|
954
980
|
};
|
|
955
981
|
this.on(type, onceCallback);
|
|
956
982
|
}
|
|
957
|
-
/**
|
|
958
|
-
* ### 发出事件
|
|
959
|
-
* @param type 事件类型
|
|
960
|
-
* @param args 参数
|
|
961
|
-
*/
|
|
962
|
-
static emit(type, ...args) {
|
|
963
|
-
const callbacks = this.listeners.get(type) || [];
|
|
964
|
-
callbacks.forEach((callback) => {
|
|
965
|
-
callback(...args);
|
|
966
|
-
});
|
|
967
|
-
}
|
|
968
|
-
/**
|
|
969
|
-
* ### 取消监听事件
|
|
970
|
-
* @param type 事件类型
|
|
971
|
-
* @param callback 回调方法
|
|
972
|
-
*/
|
|
973
|
-
static off(type, callback) {
|
|
974
|
-
const callbacks = this.listeners.get(type) || [];
|
|
975
|
-
const index = callbacks.indexOf(callback);
|
|
976
|
-
if (index !== -1) {
|
|
977
|
-
callbacks.splice(index, 1);
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
983
|
}
|
|
981
|
-
|
|
984
|
+
const AirEvent$1 = new AirEvent();
|
|
982
985
|
var AirLanguage = /* @__PURE__ */ ((AirLanguage2) => {
|
|
983
986
|
AirLanguage2["English"] = "English";
|
|
984
987
|
AirLanguage2["ChineseSimplified"] = "简体中文";
|
|
@@ -8117,7 +8120,7 @@
|
|
|
8117
8120
|
reject(new HttpResponseError(response.message, response.code));
|
|
8118
8121
|
return;
|
|
8119
8122
|
}
|
|
8120
|
-
AirEvent.emit(CoreEvents.NEED_LOGIN, response);
|
|
8123
|
+
AirEvent$1.emit(CoreEvents.NEED_LOGIN, response);
|
|
8121
8124
|
return;
|
|
8122
8125
|
}
|
|
8123
8126
|
if (response.code !== CoreConfig.successCode) {
|
|
@@ -8125,7 +8128,7 @@
|
|
|
8125
8128
|
reject(new HttpResponseError(response.message, response.code));
|
|
8126
8129
|
return;
|
|
8127
8130
|
}
|
|
8128
|
-
AirEvent.emit(CoreEvents.HTTP_ERROR, response);
|
|
8131
|
+
AirEvent$1.emit(CoreEvents.HTTP_ERROR, response);
|
|
8129
8132
|
return;
|
|
8130
8133
|
}
|
|
8131
8134
|
resolve(response.data);
|
|
@@ -8375,7 +8378,7 @@
|
|
|
8375
8378
|
*/
|
|
8376
8379
|
async add(data, message, title = "添加成功", apiUrl = this.urlForAdd) {
|
|
8377
8380
|
const saved = await this.api(apiUrl).postGet(data, this.entityClass);
|
|
8378
|
-
AirEvent.emit(CoreEvents.ADD_SUCCESS, title, message, saved);
|
|
8381
|
+
AirEvent$1.emit(CoreEvents.ADD_SUCCESS, title, message, saved);
|
|
8379
8382
|
return saved.id;
|
|
8380
8383
|
}
|
|
8381
8384
|
/**
|
|
@@ -8387,7 +8390,7 @@
|
|
|
8387
8390
|
*/
|
|
8388
8391
|
async update(data, message, title = "修改成功", apiUrl = this.urlForUpdate) {
|
|
8389
8392
|
await this.api(apiUrl).post(data);
|
|
8390
|
-
AirEvent.emit(CoreEvents.UPDATE_SUCCESS, title, message, data);
|
|
8393
|
+
AirEvent$1.emit(CoreEvents.UPDATE_SUCCESS, title, message, data);
|
|
8391
8394
|
}
|
|
8392
8395
|
/**
|
|
8393
8396
|
* ### 保存一条数据并返回主键 `ID`
|
|
@@ -8415,9 +8418,9 @@
|
|
|
8415
8418
|
const instance = this.newEntityInstance(id);
|
|
8416
8419
|
try {
|
|
8417
8420
|
await this.api(apiUrl).callbackError().post(instance);
|
|
8418
|
-
AirEvent.emit(CoreEvents.DELETE_SUCCESS, title, message, instance);
|
|
8421
|
+
AirEvent$1.emit(CoreEvents.DELETE_SUCCESS, title, message, instance);
|
|
8419
8422
|
} catch (err) {
|
|
8420
|
-
AirEvent.emit(CoreEvents.DELETE_FAIL, "删除失败", err.message, instance);
|
|
8423
|
+
AirEvent$1.emit(CoreEvents.DELETE_FAIL, "删除失败", err.message, instance);
|
|
8421
8424
|
}
|
|
8422
8425
|
}
|
|
8423
8426
|
/**
|
|
@@ -8431,9 +8434,9 @@
|
|
|
8431
8434
|
const instance = this.newEntityInstance(id);
|
|
8432
8435
|
try {
|
|
8433
8436
|
await this.api(apiUrl).callbackError().addHttpHeader("a", "b").post(instance);
|
|
8434
|
-
AirEvent.emit(CoreEvents.DISABLE_SUCCESS, title, message, instance);
|
|
8437
|
+
AirEvent$1.emit(CoreEvents.DISABLE_SUCCESS, title, message, instance);
|
|
8435
8438
|
} catch (err) {
|
|
8436
|
-
AirEvent.emit(CoreEvents.ENABLE_FAIL, "禁用失败", err.message, instance);
|
|
8439
|
+
AirEvent$1.emit(CoreEvents.ENABLE_FAIL, "禁用失败", err.message, instance);
|
|
8437
8440
|
}
|
|
8438
8441
|
}
|
|
8439
8442
|
/**
|
|
@@ -8447,9 +8450,9 @@
|
|
|
8447
8450
|
const instance = this.newEntityInstance(id);
|
|
8448
8451
|
try {
|
|
8449
8452
|
await this.api(apiUrl).callbackError().post(this.newEntityInstance(id));
|
|
8450
|
-
AirEvent.emit(CoreEvents.ENABLE_SUCCESS, title, message, instance);
|
|
8453
|
+
AirEvent$1.emit(CoreEvents.ENABLE_SUCCESS, title, message, instance);
|
|
8451
8454
|
} catch (err) {
|
|
8452
|
-
AirEvent.emit(CoreEvents.ENABLE_FAIL, "启用失败", err.message, instance);
|
|
8455
|
+
AirEvent$1.emit(CoreEvents.ENABLE_FAIL, "启用失败", err.message, instance);
|
|
8453
8456
|
}
|
|
8454
8457
|
}
|
|
8455
8458
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airpower/web",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"description": "AirPower-Web",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Hamm",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"preview": "vite preview"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@airpower/core": "^0.0.
|
|
37
|
+
"@airpower/core": "^0.0.5",
|
|
38
38
|
"axios": "^1.8.4",
|
|
39
39
|
"vue": "^3.5.13"
|
|
40
40
|
},
|