@etsoo/appscript 1.2.48 → 1.2.52
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/lib/cjs/app/CoreApp.d.ts +2 -1
- package/lib/cjs/app/CoreApp.js +2 -1
- package/lib/cjs/bridges/BridgeUtils.d.ts +2 -6
- package/lib/cjs/bridges/BridgeUtils.js +8 -29
- package/lib/cjs/bridges/FlutterHost.d.ts +22 -0
- package/lib/cjs/bridges/FlutterHost.js +42 -0
- package/lib/cjs/bridges/IBridgeHost.d.ts +12 -1
- package/lib/cjs/business/BusinessUtils.d.ts +8 -0
- package/lib/cjs/business/BusinessUtils.js +17 -0
- package/lib/cjs/i18n/en-US.json +15 -0
- package/lib/cjs/i18n/zh-CN.json +15 -0
- package/lib/cjs/i18n/zh-HK.json +15 -0
- package/lib/mjs/app/CoreApp.d.ts +2 -1
- package/lib/mjs/app/CoreApp.js +2 -1
- package/lib/mjs/bridges/BridgeUtils.d.ts +2 -6
- package/lib/mjs/bridges/BridgeUtils.js +8 -29
- package/lib/mjs/bridges/FlutterHost.d.ts +22 -0
- package/lib/mjs/bridges/FlutterHost.js +38 -0
- package/lib/mjs/bridges/IBridgeHost.d.ts +12 -1
- package/lib/mjs/business/BusinessUtils.d.ts +8 -0
- package/lib/mjs/business/BusinessUtils.js +17 -0
- package/lib/mjs/i18n/en-US.json +15 -0
- package/lib/mjs/i18n/zh-CN.json +15 -0
- package/lib/mjs/i18n/zh-HK.json +15 -0
- package/package.json +1 -1
- package/src/app/CoreApp.ts +2 -1
- package/src/bridges/BridgeUtils.ts +8 -37
- package/src/bridges/FlutterHost.ts +52 -0
- package/src/bridges/IBridgeHost.ts +14 -1
- package/src/business/BusinessUtils.ts +20 -0
- package/src/i18n/en-US.json +15 -0
- package/src/i18n/zh-CN.json +15 -0
- package/src/i18n/zh-HK.json +15 -0
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -771,8 +771,9 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
771
771
|
* Try login, returning false means is loading
|
|
772
772
|
* UI get involved while refreshToken not intended
|
|
773
773
|
* @param data Additional request data
|
|
774
|
+
* @param showLoading Show loading bar or not during call
|
|
774
775
|
*/
|
|
775
|
-
tryLogin<D extends {} = {}>(_data?: D): Promise<boolean>;
|
|
776
|
+
tryLogin<D extends {} = {}>(_data?: D, _showLoading?: boolean): Promise<boolean>;
|
|
776
777
|
/**
|
|
777
778
|
* User login
|
|
778
779
|
* @param user User data
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -956,8 +956,9 @@ class CoreApp {
|
|
|
956
956
|
* Try login, returning false means is loading
|
|
957
957
|
* UI get involved while refreshToken not intended
|
|
958
958
|
* @param data Additional request data
|
|
959
|
+
* @param showLoading Show loading bar or not during call
|
|
959
960
|
*/
|
|
960
|
-
async tryLogin(_data) {
|
|
961
|
+
async tryLogin(_data, _showLoading) {
|
|
961
962
|
if (this._isTryingLogin)
|
|
962
963
|
return false;
|
|
963
964
|
this._isTryingLogin = true;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
+
import { FlutterHost } from './FlutterHost';
|
|
1
2
|
import { IBridgeHost } from './IBridgeHost';
|
|
2
3
|
/**
|
|
3
4
|
* Bridge utils
|
|
4
5
|
*/
|
|
5
6
|
export declare namespace BridgeUtils {
|
|
6
|
-
/**
|
|
7
|
-
* Is electron client
|
|
8
|
-
* @returns Result
|
|
9
|
-
*/
|
|
10
|
-
function isElectronClient(): boolean;
|
|
11
7
|
/**
|
|
12
8
|
* Bridge host
|
|
13
9
|
*/
|
|
14
|
-
const host: IBridgeHost | undefined;
|
|
10
|
+
const host: IBridgeHost | FlutterHost | undefined;
|
|
15
11
|
}
|
|
@@ -1,41 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BridgeUtils = void 0;
|
|
4
|
+
const FlutterHost_1 = require("./FlutterHost");
|
|
4
5
|
/**
|
|
5
6
|
* Bridge utils
|
|
6
7
|
*/
|
|
7
8
|
var BridgeUtils;
|
|
8
9
|
(function (BridgeUtils) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* @returns Result
|
|
12
|
-
*/
|
|
13
|
-
function isElectronClient() {
|
|
14
|
-
// Renderer process
|
|
15
|
-
if (typeof window !== 'undefined' &&
|
|
16
|
-
typeof window.process === 'object' &&
|
|
17
|
-
window.process.type === 'renderer') {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
// Main process
|
|
21
|
-
if (typeof process !== 'undefined' &&
|
|
22
|
-
typeof process.versions === 'object' &&
|
|
23
|
-
!!process.versions.electron) {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
// Detect the user agent when the `nodeIntegration` option is set to true
|
|
27
|
-
if (typeof navigator === 'object' &&
|
|
28
|
-
typeof navigator.userAgent === 'string' &&
|
|
29
|
-
navigator.userAgent.indexOf('Electron') >= 0) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
BridgeUtils.isElectronClient = isElectronClient;
|
|
10
|
+
var _a;
|
|
11
|
+
const g = globalThis;
|
|
35
12
|
/**
|
|
36
13
|
* Bridge host
|
|
37
14
|
*/
|
|
38
|
-
BridgeUtils.host =
|
|
39
|
-
?
|
|
40
|
-
:
|
|
15
|
+
BridgeUtils.host = typeof ((_a = g.flutter_inappwebview) === null || _a === void 0 ? void 0 : _a.callHandler) === 'function'
|
|
16
|
+
? new FlutterHost_1.FlutterHost(g.flutter_inappwebview.callHandler)
|
|
17
|
+
: typeof g.electron === 'object'
|
|
18
|
+
? g.electron
|
|
19
|
+
: undefined;
|
|
41
20
|
})(BridgeUtils = exports.BridgeUtils || (exports.BridgeUtils = {}));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IBridgeHost } from './IBridgeHost';
|
|
2
|
+
/**
|
|
3
|
+
* Flutter JavaScript Host
|
|
4
|
+
* https://inappwebview.dev/docs/javascript/communication/
|
|
5
|
+
*/
|
|
6
|
+
export declare class FlutterHost implements IBridgeHost {
|
|
7
|
+
callHandler: (name: string, ...args: unknown[]) => PromiseLike<Record<string, unknown> | void>;
|
|
8
|
+
/**
|
|
9
|
+
* Start Url
|
|
10
|
+
*/
|
|
11
|
+
private startUrl;
|
|
12
|
+
/**
|
|
13
|
+
* Constructor
|
|
14
|
+
* @param callHandler Call handler
|
|
15
|
+
*/
|
|
16
|
+
constructor(callHandler: (name: string, ...args: unknown[]) => PromiseLike<Record<string, unknown> | void>);
|
|
17
|
+
changeCulture(locale: string): void;
|
|
18
|
+
exit(): void;
|
|
19
|
+
getLabels<T extends string>(...keys: T[]): Promise<any>;
|
|
20
|
+
getStartUrl(): string | null | undefined;
|
|
21
|
+
loadApp(name: string, startUrl?: string): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlutterHost = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Flutter JavaScript Host
|
|
6
|
+
* https://inappwebview.dev/docs/javascript/communication/
|
|
7
|
+
*/
|
|
8
|
+
class FlutterHost {
|
|
9
|
+
/**
|
|
10
|
+
* Constructor
|
|
11
|
+
* @param callHandler Call handler
|
|
12
|
+
*/
|
|
13
|
+
constructor(callHandler) {
|
|
14
|
+
this.callHandler = callHandler;
|
|
15
|
+
}
|
|
16
|
+
changeCulture(locale) {
|
|
17
|
+
this.callHandler('changeCulture', locale);
|
|
18
|
+
}
|
|
19
|
+
exit() {
|
|
20
|
+
this.callHandler('exit');
|
|
21
|
+
}
|
|
22
|
+
async getLabels(...keys) {
|
|
23
|
+
var _a;
|
|
24
|
+
const init = {};
|
|
25
|
+
const result = (_a = (await this.callHandler('getLabels'))) !== null && _a !== void 0 ? _a : {};
|
|
26
|
+
return keys.reduce((a, v) => {
|
|
27
|
+
var _a;
|
|
28
|
+
return ({
|
|
29
|
+
...a,
|
|
30
|
+
[v]: (_a = result[v]) !== null && _a !== void 0 ? _a : ''
|
|
31
|
+
});
|
|
32
|
+
}, init);
|
|
33
|
+
}
|
|
34
|
+
getStartUrl() {
|
|
35
|
+
return this.startUrl;
|
|
36
|
+
}
|
|
37
|
+
loadApp(name, startUrl) {
|
|
38
|
+
this.startUrl = startUrl;
|
|
39
|
+
this.callHandler('loadApp', name, startUrl);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.FlutterHost = FlutterHost;
|
|
@@ -11,10 +11,21 @@ export interface IBridgeHost {
|
|
|
11
11
|
* Exit the application
|
|
12
12
|
*/
|
|
13
13
|
exit(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Get multiple culture labels
|
|
16
|
+
* @param keys Keys
|
|
17
|
+
*/
|
|
18
|
+
getLabels<T extends string>(...keys: T[]): PromiseLike<{
|
|
19
|
+
[K in T]: string;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Get app start Url / router Url
|
|
23
|
+
*/
|
|
24
|
+
getStartUrl(): string | undefined | null;
|
|
14
25
|
/**
|
|
15
26
|
* Load application
|
|
16
27
|
* @param name App name
|
|
17
|
-
* @param startUrl Start Url
|
|
28
|
+
* @param startUrl Start Url / router Url
|
|
18
29
|
*/
|
|
19
30
|
loadApp(name: string, startUrl?: string): void;
|
|
20
31
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DataTypes } from '@etsoo/shared';
|
|
1
2
|
import { IdLabelDto } from '../dto/IdLabelDto';
|
|
2
3
|
import { ICultureGet } from '../state/Culture';
|
|
3
4
|
import { EntityStatus } from './EntityStatus';
|
|
@@ -31,6 +32,13 @@ export declare namespace BusinessUtils {
|
|
|
31
32
|
id: EntityStatus;
|
|
32
33
|
label: string;
|
|
33
34
|
}[];
|
|
35
|
+
/**
|
|
36
|
+
* Get 12-month items
|
|
37
|
+
* @param monthLabels Month labels
|
|
38
|
+
* @param startMonth Start month, 0 as Jan.
|
|
39
|
+
* @returns 12 months
|
|
40
|
+
*/
|
|
41
|
+
function getMonths(monthLabels: string[], startMonth?: number): DataTypes.IdLabelItem[];
|
|
34
42
|
/**
|
|
35
43
|
* Get product unit's label
|
|
36
44
|
* Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
|
|
@@ -55,6 +55,23 @@ var BusinessUtils;
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
BusinessUtils.getEntityStatus = getEntityStatus;
|
|
58
|
+
/**
|
|
59
|
+
* Get 12-month items
|
|
60
|
+
* @param monthLabels Month labels
|
|
61
|
+
* @param startMonth Start month, 0 as Jan.
|
|
62
|
+
* @returns 12 months
|
|
63
|
+
*/
|
|
64
|
+
function getMonths(monthLabels, startMonth = 0) {
|
|
65
|
+
const months = [];
|
|
66
|
+
for (let i = 0; i < 12; i++) {
|
|
67
|
+
if (startMonth >= 12)
|
|
68
|
+
startMonth = 0;
|
|
69
|
+
months.push({ id: startMonth, label: monthLabels[startMonth] });
|
|
70
|
+
startMonth++;
|
|
71
|
+
}
|
|
72
|
+
return months;
|
|
73
|
+
}
|
|
74
|
+
BusinessUtils.getMonths = getMonths;
|
|
58
75
|
/**
|
|
59
76
|
* Get product unit's label
|
|
60
77
|
* Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
|
package/lib/cjs/i18n/en-US.json
CHANGED
|
@@ -50,6 +50,20 @@
|
|
|
50
50
|
"message": "Message",
|
|
51
51
|
"mobile": "Mobile number",
|
|
52
52
|
"mobilePhones": "Mobile numbers",
|
|
53
|
+
"months": [
|
|
54
|
+
"Jan.",
|
|
55
|
+
"Feb.",
|
|
56
|
+
"Mar.",
|
|
57
|
+
"Apr.",
|
|
58
|
+
"May.",
|
|
59
|
+
"Jun.",
|
|
60
|
+
"Jul.",
|
|
61
|
+
"Aug.",
|
|
62
|
+
"Sep.",
|
|
63
|
+
"Oct.",
|
|
64
|
+
"Nov.",
|
|
65
|
+
"Dec."
|
|
66
|
+
],
|
|
53
67
|
"more": "More",
|
|
54
68
|
"moreTag": "{0} more",
|
|
55
69
|
"name": "Name",
|
|
@@ -67,6 +81,7 @@
|
|
|
67
81
|
"pageNotFound": "Page Not Found",
|
|
68
82
|
"prompt": "Input",
|
|
69
83
|
"pullToRefresh": "Pull down to refresh",
|
|
84
|
+
"quarters": ["Q1", "Q2", "Q3", "Q4"],
|
|
70
85
|
"record": "Record",
|
|
71
86
|
"refresh": "Refresh",
|
|
72
87
|
"refreshing": "Refreshing",
|
package/lib/cjs/i18n/zh-CN.json
CHANGED
|
@@ -50,6 +50,20 @@
|
|
|
50
50
|
"message": "留言",
|
|
51
51
|
"mobile": "手机号码",
|
|
52
52
|
"mobilePhones": "手机号码",
|
|
53
|
+
"months": [
|
|
54
|
+
"1月",
|
|
55
|
+
"2月",
|
|
56
|
+
"3月",
|
|
57
|
+
"4月",
|
|
58
|
+
"5月",
|
|
59
|
+
"6月",
|
|
60
|
+
"7月",
|
|
61
|
+
"8月",
|
|
62
|
+
"9月",
|
|
63
|
+
"10月",
|
|
64
|
+
"11月",
|
|
65
|
+
"12月"
|
|
66
|
+
],
|
|
53
67
|
"more": "更多",
|
|
54
68
|
"moreTag": "({0}+)",
|
|
55
69
|
"name": "姓名",
|
|
@@ -67,6 +81,7 @@
|
|
|
67
81
|
"pageNotFound": "找不到页面",
|
|
68
82
|
"prompt": "输入",
|
|
69
83
|
"pullToRefresh": "下拉刷新",
|
|
84
|
+
"quarters": ["一季度", "二季度", "三季度", "四季度"],
|
|
70
85
|
"record": "记录",
|
|
71
86
|
"refresh": "刷新",
|
|
72
87
|
"refreshing": "正在刷新",
|
package/lib/cjs/i18n/zh-HK.json
CHANGED
|
@@ -50,6 +50,20 @@
|
|
|
50
50
|
"message": "留言",
|
|
51
51
|
"mobilePhone": "手機號碼",
|
|
52
52
|
"mobilePhones": "手機號碼",
|
|
53
|
+
"months": [
|
|
54
|
+
"1月",
|
|
55
|
+
"2月",
|
|
56
|
+
"3月",
|
|
57
|
+
"4月",
|
|
58
|
+
"5月",
|
|
59
|
+
"6月",
|
|
60
|
+
"7月",
|
|
61
|
+
"8月",
|
|
62
|
+
"9月",
|
|
63
|
+
"10月",
|
|
64
|
+
"11月",
|
|
65
|
+
"12月"
|
|
66
|
+
],
|
|
53
67
|
"more": "更多",
|
|
54
68
|
"moreTag": "({0}+)",
|
|
55
69
|
"name": "姓名",
|
|
@@ -67,6 +81,7 @@
|
|
|
67
81
|
"pageNotFound": "找不到頁面",
|
|
68
82
|
"prompt": "輸入",
|
|
69
83
|
"pullToRefresh": "下拉刷新",
|
|
84
|
+
"quarters": ["一季度", "二季度", "三季度", "四季度"],
|
|
70
85
|
"record": "記錄",
|
|
71
86
|
"refresh": "刷新",
|
|
72
87
|
"refreshing": "正在刷新",
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -771,8 +771,9 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
771
771
|
* Try login, returning false means is loading
|
|
772
772
|
* UI get involved while refreshToken not intended
|
|
773
773
|
* @param data Additional request data
|
|
774
|
+
* @param showLoading Show loading bar or not during call
|
|
774
775
|
*/
|
|
775
|
-
tryLogin<D extends {} = {}>(_data?: D): Promise<boolean>;
|
|
776
|
+
tryLogin<D extends {} = {}>(_data?: D, _showLoading?: boolean): Promise<boolean>;
|
|
776
777
|
/**
|
|
777
778
|
* User login
|
|
778
779
|
* @param user User data
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -953,8 +953,9 @@ export class CoreApp {
|
|
|
953
953
|
* Try login, returning false means is loading
|
|
954
954
|
* UI get involved while refreshToken not intended
|
|
955
955
|
* @param data Additional request data
|
|
956
|
+
* @param showLoading Show loading bar or not during call
|
|
956
957
|
*/
|
|
957
|
-
async tryLogin(_data) {
|
|
958
|
+
async tryLogin(_data, _showLoading) {
|
|
958
959
|
if (this._isTryingLogin)
|
|
959
960
|
return false;
|
|
960
961
|
this._isTryingLogin = true;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
+
import { FlutterHost } from './FlutterHost';
|
|
1
2
|
import { IBridgeHost } from './IBridgeHost';
|
|
2
3
|
/**
|
|
3
4
|
* Bridge utils
|
|
4
5
|
*/
|
|
5
6
|
export declare namespace BridgeUtils {
|
|
6
|
-
/**
|
|
7
|
-
* Is electron client
|
|
8
|
-
* @returns Result
|
|
9
|
-
*/
|
|
10
|
-
function isElectronClient(): boolean;
|
|
11
7
|
/**
|
|
12
8
|
* Bridge host
|
|
13
9
|
*/
|
|
14
|
-
const host: IBridgeHost | undefined;
|
|
10
|
+
const host: IBridgeHost | FlutterHost | undefined;
|
|
15
11
|
}
|
|
@@ -1,38 +1,17 @@
|
|
|
1
|
+
import { FlutterHost } from './FlutterHost';
|
|
1
2
|
/**
|
|
2
3
|
* Bridge utils
|
|
3
4
|
*/
|
|
4
5
|
export var BridgeUtils;
|
|
5
6
|
(function (BridgeUtils) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* @returns Result
|
|
9
|
-
*/
|
|
10
|
-
function isElectronClient() {
|
|
11
|
-
// Renderer process
|
|
12
|
-
if (typeof window !== 'undefined' &&
|
|
13
|
-
typeof window.process === 'object' &&
|
|
14
|
-
window.process.type === 'renderer') {
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
// Main process
|
|
18
|
-
if (typeof process !== 'undefined' &&
|
|
19
|
-
typeof process.versions === 'object' &&
|
|
20
|
-
!!process.versions.electron) {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
// Detect the user agent when the `nodeIntegration` option is set to true
|
|
24
|
-
if (typeof navigator === 'object' &&
|
|
25
|
-
typeof navigator.userAgent === 'string' &&
|
|
26
|
-
navigator.userAgent.indexOf('Electron') >= 0) {
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
BridgeUtils.isElectronClient = isElectronClient;
|
|
7
|
+
var _a;
|
|
8
|
+
const g = globalThis;
|
|
32
9
|
/**
|
|
33
10
|
* Bridge host
|
|
34
11
|
*/
|
|
35
|
-
BridgeUtils.host =
|
|
36
|
-
?
|
|
37
|
-
:
|
|
12
|
+
BridgeUtils.host = typeof ((_a = g.flutter_inappwebview) === null || _a === void 0 ? void 0 : _a.callHandler) === 'function'
|
|
13
|
+
? new FlutterHost(g.flutter_inappwebview.callHandler)
|
|
14
|
+
: typeof g.electron === 'object'
|
|
15
|
+
? g.electron
|
|
16
|
+
: undefined;
|
|
38
17
|
})(BridgeUtils || (BridgeUtils = {}));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IBridgeHost } from './IBridgeHost';
|
|
2
|
+
/**
|
|
3
|
+
* Flutter JavaScript Host
|
|
4
|
+
* https://inappwebview.dev/docs/javascript/communication/
|
|
5
|
+
*/
|
|
6
|
+
export declare class FlutterHost implements IBridgeHost {
|
|
7
|
+
callHandler: (name: string, ...args: unknown[]) => PromiseLike<Record<string, unknown> | void>;
|
|
8
|
+
/**
|
|
9
|
+
* Start Url
|
|
10
|
+
*/
|
|
11
|
+
private startUrl;
|
|
12
|
+
/**
|
|
13
|
+
* Constructor
|
|
14
|
+
* @param callHandler Call handler
|
|
15
|
+
*/
|
|
16
|
+
constructor(callHandler: (name: string, ...args: unknown[]) => PromiseLike<Record<string, unknown> | void>);
|
|
17
|
+
changeCulture(locale: string): void;
|
|
18
|
+
exit(): void;
|
|
19
|
+
getLabels<T extends string>(...keys: T[]): Promise<any>;
|
|
20
|
+
getStartUrl(): string | null | undefined;
|
|
21
|
+
loadApp(name: string, startUrl?: string): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flutter JavaScript Host
|
|
3
|
+
* https://inappwebview.dev/docs/javascript/communication/
|
|
4
|
+
*/
|
|
5
|
+
export class FlutterHost {
|
|
6
|
+
/**
|
|
7
|
+
* Constructor
|
|
8
|
+
* @param callHandler Call handler
|
|
9
|
+
*/
|
|
10
|
+
constructor(callHandler) {
|
|
11
|
+
this.callHandler = callHandler;
|
|
12
|
+
}
|
|
13
|
+
changeCulture(locale) {
|
|
14
|
+
this.callHandler('changeCulture', locale);
|
|
15
|
+
}
|
|
16
|
+
exit() {
|
|
17
|
+
this.callHandler('exit');
|
|
18
|
+
}
|
|
19
|
+
async getLabels(...keys) {
|
|
20
|
+
var _a;
|
|
21
|
+
const init = {};
|
|
22
|
+
const result = (_a = (await this.callHandler('getLabels'))) !== null && _a !== void 0 ? _a : {};
|
|
23
|
+
return keys.reduce((a, v) => {
|
|
24
|
+
var _a;
|
|
25
|
+
return ({
|
|
26
|
+
...a,
|
|
27
|
+
[v]: (_a = result[v]) !== null && _a !== void 0 ? _a : ''
|
|
28
|
+
});
|
|
29
|
+
}, init);
|
|
30
|
+
}
|
|
31
|
+
getStartUrl() {
|
|
32
|
+
return this.startUrl;
|
|
33
|
+
}
|
|
34
|
+
loadApp(name, startUrl) {
|
|
35
|
+
this.startUrl = startUrl;
|
|
36
|
+
this.callHandler('loadApp', name, startUrl);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -11,10 +11,21 @@ export interface IBridgeHost {
|
|
|
11
11
|
* Exit the application
|
|
12
12
|
*/
|
|
13
13
|
exit(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Get multiple culture labels
|
|
16
|
+
* @param keys Keys
|
|
17
|
+
*/
|
|
18
|
+
getLabels<T extends string>(...keys: T[]): PromiseLike<{
|
|
19
|
+
[K in T]: string;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Get app start Url / router Url
|
|
23
|
+
*/
|
|
24
|
+
getStartUrl(): string | undefined | null;
|
|
14
25
|
/**
|
|
15
26
|
* Load application
|
|
16
27
|
* @param name App name
|
|
17
|
-
* @param startUrl Start Url
|
|
28
|
+
* @param startUrl Start Url / router Url
|
|
18
29
|
*/
|
|
19
30
|
loadApp(name: string, startUrl?: string): void;
|
|
20
31
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DataTypes } from '@etsoo/shared';
|
|
1
2
|
import { IdLabelDto } from '../dto/IdLabelDto';
|
|
2
3
|
import { ICultureGet } from '../state/Culture';
|
|
3
4
|
import { EntityStatus } from './EntityStatus';
|
|
@@ -31,6 +32,13 @@ export declare namespace BusinessUtils {
|
|
|
31
32
|
id: EntityStatus;
|
|
32
33
|
label: string;
|
|
33
34
|
}[];
|
|
35
|
+
/**
|
|
36
|
+
* Get 12-month items
|
|
37
|
+
* @param monthLabels Month labels
|
|
38
|
+
* @param startMonth Start month, 0 as Jan.
|
|
39
|
+
* @returns 12 months
|
|
40
|
+
*/
|
|
41
|
+
function getMonths(monthLabels: string[], startMonth?: number): DataTypes.IdLabelItem[];
|
|
34
42
|
/**
|
|
35
43
|
* Get product unit's label
|
|
36
44
|
* Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
|
|
@@ -52,6 +52,23 @@ export var BusinessUtils;
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
BusinessUtils.getEntityStatus = getEntityStatus;
|
|
55
|
+
/**
|
|
56
|
+
* Get 12-month items
|
|
57
|
+
* @param monthLabels Month labels
|
|
58
|
+
* @param startMonth Start month, 0 as Jan.
|
|
59
|
+
* @returns 12 months
|
|
60
|
+
*/
|
|
61
|
+
function getMonths(monthLabels, startMonth = 0) {
|
|
62
|
+
const months = [];
|
|
63
|
+
for (let i = 0; i < 12; i++) {
|
|
64
|
+
if (startMonth >= 12)
|
|
65
|
+
startMonth = 0;
|
|
66
|
+
months.push({ id: startMonth, label: monthLabels[startMonth] });
|
|
67
|
+
startMonth++;
|
|
68
|
+
}
|
|
69
|
+
return months;
|
|
70
|
+
}
|
|
71
|
+
BusinessUtils.getMonths = getMonths;
|
|
55
72
|
/**
|
|
56
73
|
* Get product unit's label
|
|
57
74
|
* Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
|
package/lib/mjs/i18n/en-US.json
CHANGED
|
@@ -50,6 +50,20 @@
|
|
|
50
50
|
"message": "Message",
|
|
51
51
|
"mobile": "Mobile number",
|
|
52
52
|
"mobilePhones": "Mobile numbers",
|
|
53
|
+
"months": [
|
|
54
|
+
"Jan.",
|
|
55
|
+
"Feb.",
|
|
56
|
+
"Mar.",
|
|
57
|
+
"Apr.",
|
|
58
|
+
"May.",
|
|
59
|
+
"Jun.",
|
|
60
|
+
"Jul.",
|
|
61
|
+
"Aug.",
|
|
62
|
+
"Sep.",
|
|
63
|
+
"Oct.",
|
|
64
|
+
"Nov.",
|
|
65
|
+
"Dec."
|
|
66
|
+
],
|
|
53
67
|
"more": "More",
|
|
54
68
|
"moreTag": "{0} more",
|
|
55
69
|
"name": "Name",
|
|
@@ -67,6 +81,7 @@
|
|
|
67
81
|
"pageNotFound": "Page Not Found",
|
|
68
82
|
"prompt": "Input",
|
|
69
83
|
"pullToRefresh": "Pull down to refresh",
|
|
84
|
+
"quarters": ["Q1", "Q2", "Q3", "Q4"],
|
|
70
85
|
"record": "Record",
|
|
71
86
|
"refresh": "Refresh",
|
|
72
87
|
"refreshing": "Refreshing",
|
package/lib/mjs/i18n/zh-CN.json
CHANGED
|
@@ -50,6 +50,20 @@
|
|
|
50
50
|
"message": "留言",
|
|
51
51
|
"mobile": "手机号码",
|
|
52
52
|
"mobilePhones": "手机号码",
|
|
53
|
+
"months": [
|
|
54
|
+
"1月",
|
|
55
|
+
"2月",
|
|
56
|
+
"3月",
|
|
57
|
+
"4月",
|
|
58
|
+
"5月",
|
|
59
|
+
"6月",
|
|
60
|
+
"7月",
|
|
61
|
+
"8月",
|
|
62
|
+
"9月",
|
|
63
|
+
"10月",
|
|
64
|
+
"11月",
|
|
65
|
+
"12月"
|
|
66
|
+
],
|
|
53
67
|
"more": "更多",
|
|
54
68
|
"moreTag": "({0}+)",
|
|
55
69
|
"name": "姓名",
|
|
@@ -67,6 +81,7 @@
|
|
|
67
81
|
"pageNotFound": "找不到页面",
|
|
68
82
|
"prompt": "输入",
|
|
69
83
|
"pullToRefresh": "下拉刷新",
|
|
84
|
+
"quarters": ["一季度", "二季度", "三季度", "四季度"],
|
|
70
85
|
"record": "记录",
|
|
71
86
|
"refresh": "刷新",
|
|
72
87
|
"refreshing": "正在刷新",
|
package/lib/mjs/i18n/zh-HK.json
CHANGED
|
@@ -50,6 +50,20 @@
|
|
|
50
50
|
"message": "留言",
|
|
51
51
|
"mobilePhone": "手機號碼",
|
|
52
52
|
"mobilePhones": "手機號碼",
|
|
53
|
+
"months": [
|
|
54
|
+
"1月",
|
|
55
|
+
"2月",
|
|
56
|
+
"3月",
|
|
57
|
+
"4月",
|
|
58
|
+
"5月",
|
|
59
|
+
"6月",
|
|
60
|
+
"7月",
|
|
61
|
+
"8月",
|
|
62
|
+
"9月",
|
|
63
|
+
"10月",
|
|
64
|
+
"11月",
|
|
65
|
+
"12月"
|
|
66
|
+
],
|
|
53
67
|
"more": "更多",
|
|
54
68
|
"moreTag": "({0}+)",
|
|
55
69
|
"name": "姓名",
|
|
@@ -67,6 +81,7 @@
|
|
|
67
81
|
"pageNotFound": "找不到頁面",
|
|
68
82
|
"prompt": "輸入",
|
|
69
83
|
"pullToRefresh": "下拉刷新",
|
|
84
|
+
"quarters": ["一季度", "二季度", "三季度", "四季度"],
|
|
70
85
|
"record": "記錄",
|
|
71
86
|
"refresh": "刷新",
|
|
72
87
|
"refreshing": "正在刷新",
|
package/package.json
CHANGED
package/src/app/CoreApp.ts
CHANGED
|
@@ -1706,8 +1706,9 @@ export abstract class CoreApp<
|
|
|
1706
1706
|
* Try login, returning false means is loading
|
|
1707
1707
|
* UI get involved while refreshToken not intended
|
|
1708
1708
|
* @param data Additional request data
|
|
1709
|
+
* @param showLoading Show loading bar or not during call
|
|
1709
1710
|
*/
|
|
1710
|
-
async tryLogin<D extends {} = {}>(_data?: D) {
|
|
1711
|
+
async tryLogin<D extends {} = {}>(_data?: D, _showLoading?: boolean) {
|
|
1711
1712
|
if (this._isTryingLogin) return false;
|
|
1712
1713
|
this._isTryingLogin = true;
|
|
1713
1714
|
return true;
|
|
@@ -1,48 +1,19 @@
|
|
|
1
|
+
import { FlutterHost } from './FlutterHost';
|
|
1
2
|
import { IBridgeHost } from './IBridgeHost';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Bridge utils
|
|
5
6
|
*/
|
|
6
7
|
export namespace BridgeUtils {
|
|
7
|
-
|
|
8
|
-
* Is electron client
|
|
9
|
-
* @returns Result
|
|
10
|
-
*/
|
|
11
|
-
export function isElectronClient() {
|
|
12
|
-
// Renderer process
|
|
13
|
-
if (
|
|
14
|
-
typeof window !== 'undefined' &&
|
|
15
|
-
typeof window.process === 'object' &&
|
|
16
|
-
(window.process as any).type === 'renderer'
|
|
17
|
-
) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Main process
|
|
22
|
-
if (
|
|
23
|
-
typeof process !== 'undefined' &&
|
|
24
|
-
typeof process.versions === 'object' &&
|
|
25
|
-
!!process.versions.electron
|
|
26
|
-
) {
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Detect the user agent when the `nodeIntegration` option is set to true
|
|
31
|
-
if (
|
|
32
|
-
typeof navigator === 'object' &&
|
|
33
|
-
typeof navigator.userAgent === 'string' &&
|
|
34
|
-
navigator.userAgent.indexOf('Electron') >= 0
|
|
35
|
-
) {
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
8
|
+
const g: any = globalThis;
|
|
41
9
|
|
|
42
10
|
/**
|
|
43
11
|
* Bridge host
|
|
44
12
|
*/
|
|
45
|
-
export const host =
|
|
46
|
-
|
|
47
|
-
|
|
13
|
+
export const host =
|
|
14
|
+
typeof g.flutter_inappwebview?.callHandler === 'function'
|
|
15
|
+
? new FlutterHost(g.flutter_inappwebview.callHandler)
|
|
16
|
+
: typeof g.electron === 'object'
|
|
17
|
+
? (g.electron as IBridgeHost)
|
|
18
|
+
: undefined;
|
|
48
19
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { IBridgeHost } from './IBridgeHost';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Flutter JavaScript Host
|
|
5
|
+
* https://inappwebview.dev/docs/javascript/communication/
|
|
6
|
+
*/
|
|
7
|
+
export class FlutterHost implements IBridgeHost {
|
|
8
|
+
/**
|
|
9
|
+
* Start Url
|
|
10
|
+
*/
|
|
11
|
+
private startUrl: string | null | undefined;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Constructor
|
|
15
|
+
* @param callHandler Call handler
|
|
16
|
+
*/
|
|
17
|
+
constructor(
|
|
18
|
+
public callHandler: (
|
|
19
|
+
name: string,
|
|
20
|
+
...args: unknown[]
|
|
21
|
+
) => PromiseLike<Record<string, unknown> | void>
|
|
22
|
+
) {}
|
|
23
|
+
|
|
24
|
+
changeCulture(locale: string): void {
|
|
25
|
+
this.callHandler('changeCulture', locale);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exit(): void {
|
|
29
|
+
this.callHandler('exit');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async getLabels<T extends string>(...keys: T[]) {
|
|
33
|
+
const init: any = {};
|
|
34
|
+
const result = (await this.callHandler('getLabels')) ?? {};
|
|
35
|
+
return keys.reduce(
|
|
36
|
+
(a, v) => ({
|
|
37
|
+
...a,
|
|
38
|
+
[v]: result[v] ?? ''
|
|
39
|
+
}),
|
|
40
|
+
init
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getStartUrl(): string | null | undefined {
|
|
45
|
+
return this.startUrl;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
loadApp(name: string, startUrl?: string): void {
|
|
49
|
+
this.startUrl = startUrl;
|
|
50
|
+
this.callHandler('loadApp', name, startUrl);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -13,10 +13,23 @@ export interface IBridgeHost {
|
|
|
13
13
|
*/
|
|
14
14
|
exit(): void;
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Get multiple culture labels
|
|
18
|
+
* @param keys Keys
|
|
19
|
+
*/
|
|
20
|
+
getLabels<T extends string>(
|
|
21
|
+
...keys: T[]
|
|
22
|
+
): PromiseLike<{ [K in T]: string }>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get app start Url / router Url
|
|
26
|
+
*/
|
|
27
|
+
getStartUrl(): string | undefined | null;
|
|
28
|
+
|
|
16
29
|
/**
|
|
17
30
|
* Load application
|
|
18
31
|
* @param name App name
|
|
19
|
-
* @param startUrl Start Url
|
|
32
|
+
* @param startUrl Start Url / router Url
|
|
20
33
|
*/
|
|
21
34
|
loadApp(name: string, startUrl?: string): void;
|
|
22
35
|
}
|
|
@@ -56,6 +56,26 @@ export namespace BusinessUtils {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Get 12-month items
|
|
61
|
+
* @param monthLabels Month labels
|
|
62
|
+
* @param startMonth Start month, 0 as Jan.
|
|
63
|
+
* @returns 12 months
|
|
64
|
+
*/
|
|
65
|
+
export function getMonths(monthLabels: string[], startMonth: number = 0) {
|
|
66
|
+
const months: DataTypes.IdLabelItem[] = [];
|
|
67
|
+
|
|
68
|
+
for (let i = 0; i < 12; i++) {
|
|
69
|
+
if (startMonth >= 12) startMonth = 0;
|
|
70
|
+
|
|
71
|
+
months.push({ id: startMonth, label: monthLabels[startMonth] });
|
|
72
|
+
|
|
73
|
+
startMonth++;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return months;
|
|
77
|
+
}
|
|
78
|
+
|
|
59
79
|
/**
|
|
60
80
|
* Get product unit's label
|
|
61
81
|
* Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
|
package/src/i18n/en-US.json
CHANGED
|
@@ -50,6 +50,20 @@
|
|
|
50
50
|
"message": "Message",
|
|
51
51
|
"mobile": "Mobile number",
|
|
52
52
|
"mobilePhones": "Mobile numbers",
|
|
53
|
+
"months": [
|
|
54
|
+
"Jan.",
|
|
55
|
+
"Feb.",
|
|
56
|
+
"Mar.",
|
|
57
|
+
"Apr.",
|
|
58
|
+
"May.",
|
|
59
|
+
"Jun.",
|
|
60
|
+
"Jul.",
|
|
61
|
+
"Aug.",
|
|
62
|
+
"Sep.",
|
|
63
|
+
"Oct.",
|
|
64
|
+
"Nov.",
|
|
65
|
+
"Dec."
|
|
66
|
+
],
|
|
53
67
|
"more": "More",
|
|
54
68
|
"moreTag": "{0} more",
|
|
55
69
|
"name": "Name",
|
|
@@ -67,6 +81,7 @@
|
|
|
67
81
|
"pageNotFound": "Page Not Found",
|
|
68
82
|
"prompt": "Input",
|
|
69
83
|
"pullToRefresh": "Pull down to refresh",
|
|
84
|
+
"quarters": ["Q1", "Q2", "Q3", "Q4"],
|
|
70
85
|
"record": "Record",
|
|
71
86
|
"refresh": "Refresh",
|
|
72
87
|
"refreshing": "Refreshing",
|
package/src/i18n/zh-CN.json
CHANGED
|
@@ -50,6 +50,20 @@
|
|
|
50
50
|
"message": "留言",
|
|
51
51
|
"mobile": "手机号码",
|
|
52
52
|
"mobilePhones": "手机号码",
|
|
53
|
+
"months": [
|
|
54
|
+
"1月",
|
|
55
|
+
"2月",
|
|
56
|
+
"3月",
|
|
57
|
+
"4月",
|
|
58
|
+
"5月",
|
|
59
|
+
"6月",
|
|
60
|
+
"7月",
|
|
61
|
+
"8月",
|
|
62
|
+
"9月",
|
|
63
|
+
"10月",
|
|
64
|
+
"11月",
|
|
65
|
+
"12月"
|
|
66
|
+
],
|
|
53
67
|
"more": "更多",
|
|
54
68
|
"moreTag": "({0}+)",
|
|
55
69
|
"name": "姓名",
|
|
@@ -67,6 +81,7 @@
|
|
|
67
81
|
"pageNotFound": "找不到页面",
|
|
68
82
|
"prompt": "输入",
|
|
69
83
|
"pullToRefresh": "下拉刷新",
|
|
84
|
+
"quarters": ["一季度", "二季度", "三季度", "四季度"],
|
|
70
85
|
"record": "记录",
|
|
71
86
|
"refresh": "刷新",
|
|
72
87
|
"refreshing": "正在刷新",
|
package/src/i18n/zh-HK.json
CHANGED
|
@@ -50,6 +50,20 @@
|
|
|
50
50
|
"message": "留言",
|
|
51
51
|
"mobilePhone": "手機號碼",
|
|
52
52
|
"mobilePhones": "手機號碼",
|
|
53
|
+
"months": [
|
|
54
|
+
"1月",
|
|
55
|
+
"2月",
|
|
56
|
+
"3月",
|
|
57
|
+
"4月",
|
|
58
|
+
"5月",
|
|
59
|
+
"6月",
|
|
60
|
+
"7月",
|
|
61
|
+
"8月",
|
|
62
|
+
"9月",
|
|
63
|
+
"10月",
|
|
64
|
+
"11月",
|
|
65
|
+
"12月"
|
|
66
|
+
],
|
|
53
67
|
"more": "更多",
|
|
54
68
|
"moreTag": "({0}+)",
|
|
55
69
|
"name": "姓名",
|
|
@@ -67,6 +81,7 @@
|
|
|
67
81
|
"pageNotFound": "找不到頁面",
|
|
68
82
|
"prompt": "輸入",
|
|
69
83
|
"pullToRefresh": "下拉刷新",
|
|
84
|
+
"quarters": ["一季度", "二季度", "三季度", "四季度"],
|
|
70
85
|
"record": "記錄",
|
|
71
86
|
"refresh": "刷新",
|
|
72
87
|
"refreshing": "正在刷新",
|