fast-vue-multi-pages 1.0.29 → 1.1.0

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.
@@ -15,6 +15,7 @@ import { FastVueMultiEventBus } from "./other/FastVueMultiEventBus";
15
15
  import { FastVueMultiObject } from "./other/FastVueMultiObject";
16
16
  import { FastVueMultiUUID } from "./other/FastVueMultiUUID";
17
17
  import { FastVueMultiAnimate } from "./other/FastVueMultiAnimate";
18
+ import moment from "moment";
18
19
  /**
19
20
  * FastVueMultiTool 工具类
20
21
  */
@@ -99,4 +100,8 @@ export declare class FastVueMultiTool {
99
100
  * 数值动画类
100
101
  */
101
102
  static Animate: typeof FastVueMultiAnimate;
103
+ /**
104
+ * moment工具类 http://momentjs.com/
105
+ */
106
+ static Moment: typeof moment;
102
107
  }
@@ -19,6 +19,7 @@ const FastVueMultiEventBus_1 = require("./other/FastVueMultiEventBus");
19
19
  const FastVueMultiObject_1 = require("./other/FastVueMultiObject");
20
20
  const FastVueMultiUUID_1 = require("./other/FastVueMultiUUID");
21
21
  const FastVueMultiAnimate_1 = require("./other/FastVueMultiAnimate");
22
+ const moment_1 = tslib_1.__importDefault(require("moment"));
22
23
  /**
23
24
  * FastVueMultiTool 工具类
24
25
  */
@@ -103,5 +104,9 @@ class FastVueMultiTool {
103
104
  * 数值动画类
104
105
  */
105
106
  static Animate = FastVueMultiAnimate_1.FastVueMultiAnimate;
107
+ /**
108
+ * moment工具类 http://momentjs.com/
109
+ */
110
+ static Moment = moment_1.default;
106
111
  }
107
112
  exports.FastVueMultiTool = FastVueMultiTool;
@@ -1,4 +1,5 @@
1
1
  import { FastVueMultiTool } from "./FastVueMultiTool";
2
2
  import { FastVueMultiSimpleJsonResponse } from "./http/FastVueMultiSimpleJsonResponse";
3
3
  import { FastVueMultiSimpleRequestConfig } from "./http/FastVueMultiSimpleRequestConfig";
4
- export { FastVueMultiTool, FastVueMultiSimpleJsonResponse, FastVueMultiSimpleRequestConfig };
4
+ import { FastVueNative } from "./native/FastVueNative";
5
+ export { FastVueNative, FastVueMultiTool, FastVueMultiSimpleJsonResponse, FastVueMultiSimpleRequestConfig };
package/dist/cjs/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FastVueMultiSimpleRequestConfig = exports.FastVueMultiSimpleJsonResponse = exports.FastVueMultiTool = void 0;
3
+ exports.FastVueMultiSimpleRequestConfig = exports.FastVueMultiSimpleJsonResponse = exports.FastVueMultiTool = exports.FastVueNative = void 0;
4
4
  const FastVueMultiTool_1 = require("./FastVueMultiTool");
5
5
  Object.defineProperty(exports, "FastVueMultiTool", { enumerable: true, get: function () { return FastVueMultiTool_1.FastVueMultiTool; } });
6
6
  const FastVueMultiSimpleJsonResponse_1 = require("./http/FastVueMultiSimpleJsonResponse");
7
7
  Object.defineProperty(exports, "FastVueMultiSimpleJsonResponse", { enumerable: true, get: function () { return FastVueMultiSimpleJsonResponse_1.FastVueMultiSimpleJsonResponse; } });
8
8
  const FastVueMultiSimpleRequestConfig_1 = require("./http/FastVueMultiSimpleRequestConfig");
9
9
  Object.defineProperty(exports, "FastVueMultiSimpleRequestConfig", { enumerable: true, get: function () { return FastVueMultiSimpleRequestConfig_1.FastVueMultiSimpleRequestConfig; } });
10
+ const FastVueNative_1 = require("./native/FastVueNative");
11
+ Object.defineProperty(exports, "FastVueNative", { enumerable: true, get: function () { return FastVueNative_1.FastVueNative; } });
@@ -0,0 +1,71 @@
1
+ /**
2
+ * FastNative 调用Android或IOS原生方法工具
3
+ * @author Janesen
4
+ */
5
+ /**
6
+ * 执行本地方法核心类
7
+ */
8
+ export declare class FastVueNative {
9
+ private static methodInfos;
10
+ private static getKey;
11
+ private static showError;
12
+ /**
13
+ * 是否是安卓客户端
14
+ */
15
+ static isAndroid(): boolean;
16
+ /**
17
+ * 是否是ios客户端
18
+ */
19
+ static isIOS(): boolean;
20
+ /**
21
+ * 执行手机客户端原生方法
22
+ * @param methodName 方法名称
23
+ * @param methodParams 方法参数,Array格式,按照原生方法的参数顺序设置
24
+ * @param callBack 回调函数
25
+ */
26
+ static execute(methodName: string, methodParams: any, callBack?: (result: {
27
+ success: boolean;
28
+ message: string;
29
+ data: any;
30
+ }) => void): void;
31
+ /**
32
+ * 手机原生方法回执时调用
33
+ * @param key 回调函数的唯一标识
34
+ * @param result 回调结果
35
+ */
36
+ static appCallBack(key: string, result: string): void;
37
+ /**
38
+ * 递归执行回调,针对同一个浏览器下嵌入iframe问题
39
+ * @param targetWindow 目标window
40
+ * @param key
41
+ * @param result
42
+ * @private
43
+ */
44
+ private static doAppCallBack;
45
+ /**
46
+ * 手机原生方法回执时调用
47
+ * @param key 回调函数的唯一标识
48
+ * @param result 回调结果
49
+ */
50
+ private static executeAppCallBack;
51
+ /**
52
+ * 手机原生方法执行错误时调用
53
+ * @param message 错误信息
54
+ */
55
+ private static error;
56
+ /**
57
+ * 可同步或异步执行手机客户端原生方法
58
+ * @param methodName 方法名称
59
+ * @param methodParams 方法参数,Array格式,按照原生方法的参数顺序设置
60
+ * @param callBack 回调函数
61
+ */
62
+ static executeByPromise(methodName: string, methodParams: any, callBack?: (result: {
63
+ success: boolean;
64
+ message: string;
65
+ data?: any;
66
+ }) => void): Promise<{
67
+ success: boolean;
68
+ message: string;
69
+ data: any;
70
+ }>;
71
+ }
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FastVueNative = void 0;
4
+ const FastVueMultiObject_1 = require("../other/FastVueMultiObject");
5
+ const FastVueMultiBoolean_1 = require("../other/FastVueMultiBoolean");
6
+ /**
7
+ * FastNative 调用Android或IOS原生方法工具
8
+ * @author Janesen
9
+ */
10
+ /**
11
+ * 执行本地方法核心类
12
+ */
13
+ class FastVueNative {
14
+ static methodInfos = {};
15
+ static getKey() {
16
+ let d = new Date().getTime();
17
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
18
+ let r = (d + Math.random() * 16) % 16 | 0;
19
+ d = Math.floor(d / 16);
20
+ return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
21
+ });
22
+ }
23
+ static showError(message) {
24
+ alert("FastAppJs发生错误:" + message);
25
+ }
26
+ /**
27
+ * 是否是安卓客户端
28
+ */
29
+ static isAndroid() {
30
+ return navigator.userAgent.toLowerCase().indexOf('android') > -1;
31
+ }
32
+ /**
33
+ * 是否是ios客户端
34
+ */
35
+ static isIOS() {
36
+ return navigator.userAgent.toLowerCase().indexOf('iphone') > -1;
37
+ }
38
+ /**
39
+ * 执行手机客户端原生方法
40
+ * @param methodName 方法名称
41
+ * @param methodParams 方法参数,Array格式,按照原生方法的参数顺序设置
42
+ * @param callBack 回调函数
43
+ */
44
+ static execute(methodName, methodParams, callBack) {
45
+ const Base64 = require("js-base64");
46
+ const key = this.getKey();
47
+ try {
48
+ if (methodParams == null) {
49
+ methodParams = [];
50
+ }
51
+ if (callBack == null) {
52
+ callBack = function (result) { };
53
+ }
54
+ this.methodInfos[key] = { methodName: methodName, methodParams: methodParams, callBack: callBack };
55
+ methodParams.unshift(key);
56
+ methodParams.forEach(function (value, index) {
57
+ if (value == null) {
58
+ methodParams[index] = "";
59
+ return true;
60
+ }
61
+ if (!(value instanceof Array)) {
62
+ methodParams[index] = value.toString();
63
+ }
64
+ });
65
+ if (this.isAndroid()) {
66
+ if (window["app"] && window["app"].doJavaScript && typeof (window["app"]).doJavaScript === 'function') {
67
+ window["app"].doJavaScript(methodName, Base64.encode(JSON.stringify(methodParams)));
68
+ }
69
+ else {
70
+ this.executeAppCallBack(key, Base64.encode(JSON.stringify({
71
+ success: false,
72
+ message: "客户端WebView不支持调用原生功能!",
73
+ data: null
74
+ })));
75
+ }
76
+ }
77
+ else if (this.isIOS()) {
78
+ let message = 'window.app.doJavaScript(' + methodName + ',' + Base64.encode(JSON.stringify(methodParams)) + ')';
79
+ alert(message); // IOS 使用alert触发程序中的事件,并过滤执行到客户端上的方法
80
+ }
81
+ else {
82
+ this.executeAppCallBack(key, Base64.encode(JSON.stringify({
83
+ success: false,
84
+ message: "客户端WebView不支持调用原生功能!",
85
+ data: null
86
+ })));
87
+ }
88
+ }
89
+ catch (e) {
90
+ console.error(e);
91
+ this.executeAppCallBack(key, Base64.encode(JSON.stringify({
92
+ success: false,
93
+ message: FastVueMultiObject_1.FastVueMultiObject.geErrorInfo(e),
94
+ data: null
95
+ })));
96
+ }
97
+ }
98
+ /**
99
+ * 手机原生方法回执时调用
100
+ * @param key 回调函数的唯一标识
101
+ * @param result 回调结果
102
+ */
103
+ static appCallBack(key, result) {
104
+ this.doAppCallBack(window, key, result);
105
+ }
106
+ /**
107
+ * 递归执行回调,针对同一个浏览器下嵌入iframe问题
108
+ * @param targetWindow 目标window
109
+ * @param key
110
+ * @param result
111
+ * @private
112
+ */
113
+ static doAppCallBack(targetWindow, key, result) {
114
+ if (targetWindow["appJs"]) {
115
+ targetWindow["appJs"].executeAppCallBack(key, result);
116
+ }
117
+ for (let i = 0; i < targetWindow.length; i++) {
118
+ this.doAppCallBack(targetWindow[i], key, result);
119
+ }
120
+ }
121
+ /**
122
+ * 手机原生方法回执时调用
123
+ * @param key 回调函数的唯一标识
124
+ * @param result 回调结果
125
+ */
126
+ static executeAppCallBack(key, result) {
127
+ let methodInfo = this.methodInfos[key.toString()];
128
+ if (methodInfo) {
129
+ const Base64 = require("js-base64");
130
+ result = Base64.decode(result);
131
+ const jsonData = JSON.parse(result);
132
+ try {
133
+ jsonData.success = FastVueMultiBoolean_1.FastVueMultiBoolean.parse(jsonData.success);
134
+ jsonData.data = jsonData.result;
135
+ if (methodInfo.callBack && typeof methodInfo.callBack === 'function') {
136
+ methodInfo.callBack(jsonData);
137
+ }
138
+ }
139
+ catch (e) {
140
+ console.error(e);
141
+ if (methodInfo.callBack && typeof methodInfo.callBack === 'function') {
142
+ methodInfo.callBack({ success: false, message: e.message, data: null });
143
+ }
144
+ }
145
+ finally {
146
+ console.info("执行原生方法:", methodInfo.methodName, "方法参数:", methodInfo.methodParams, "执行结果:", jsonData);
147
+ }
148
+ }
149
+ }
150
+ /**
151
+ * 手机原生方法执行错误时调用
152
+ * @param message 错误信息
153
+ */
154
+ static error(message) {
155
+ alert('手机原生端发生错误:' + message);
156
+ }
157
+ /**
158
+ * 可同步或异步执行手机客户端原生方法
159
+ * @param methodName 方法名称
160
+ * @param methodParams 方法参数,Array格式,按照原生方法的参数顺序设置
161
+ * @param callBack 回调函数
162
+ */
163
+ static async executeByPromise(methodName, methodParams, callBack) {
164
+ return new Promise(function (resolved, rejected) {
165
+ FastVueNative.execute(methodName, methodParams, function (result) {
166
+ if (callBack) {
167
+ callBack(result);
168
+ }
169
+ resolved(result);
170
+ });
171
+ });
172
+ }
173
+ }
174
+ exports.FastVueNative = FastVueNative;
@@ -9,4 +9,9 @@ export declare class FastVueMultiObject {
9
9
  * @param value
10
10
  */
11
11
  static isValid(value: any): boolean;
12
+ /**
13
+ * 获取异常信息的堆栈信息
14
+ * @param event
15
+ */
16
+ static geErrorInfo(event: any): string;
12
17
  }
@@ -39,5 +39,27 @@ class FastVueMultiObject {
39
39
  }
40
40
  return true;
41
41
  }
42
+ /**
43
+ * 获取异常信息的堆栈信息
44
+ * @param event
45
+ */
46
+ static geErrorInfo(event) {
47
+ if (event) {
48
+ if (event.error && event.error.stack) {
49
+ return event.error.stack;
50
+ }
51
+ else if (event.stack) {
52
+ return event.stack;
53
+ }
54
+ else if (event.message) {
55
+ return event.message;
56
+ }
57
+ else if (event.reason) {
58
+ return event.reason;
59
+ }
60
+ return event.toString();
61
+ }
62
+ return "";
63
+ }
42
64
  }
43
65
  exports.FastVueMultiObject = FastVueMultiObject;
@@ -15,6 +15,7 @@ import { FastVueMultiEventBus } from "./other/FastVueMultiEventBus";
15
15
  import { FastVueMultiObject } from "./other/FastVueMultiObject";
16
16
  import { FastVueMultiUUID } from "./other/FastVueMultiUUID";
17
17
  import { FastVueMultiAnimate } from "./other/FastVueMultiAnimate";
18
+ import moment from "moment";
18
19
  /**
19
20
  * FastVueMultiTool 工具类
20
21
  */
@@ -99,4 +100,8 @@ export declare class FastVueMultiTool {
99
100
  * 数值动画类
100
101
  */
101
102
  static Animate: typeof FastVueMultiAnimate;
103
+ /**
104
+ * moment工具类 http://momentjs.com/
105
+ */
106
+ static Moment: typeof moment;
102
107
  }
@@ -1,8 +1,9 @@
1
- define(["require", "exports", "tslib", "lodash", "./http/FastVueMultiHttp", "./other/FastVueMultiStore", "./vue/FastVueMultiConfig", "./http/FastVueMultiCookie", "./other/FastVueMultiClipboard", "./other/FastVueMultiDate", "./other/FastVueMultiBoolean", "./other/FastVueMultiFunction", "./other/FastVueMultiElement", "./other/FastVueMultiWindow", "./other/FastVueMultiFile", "./other/FastVueMultiBase64", "./other/FastVueMultiEventBus", "./other/FastVueMultiObject", "./other/FastVueMultiUUID", "./other/FastVueMultiAnimate"], function (require, exports, tslib_1, lodash_1, FastVueMultiHttp_1, FastVueMultiStore_1, FastVueMultiConfig_1, FastVueMultiCookie_1, FastVueMultiClipboard_1, FastVueMultiDate_1, FastVueMultiBoolean_1, FastVueMultiFunction_1, FastVueMultiElement_1, FastVueMultiWindow_1, FastVueMultiFile_1, FastVueMultiBase64_1, FastVueMultiEventBus_1, FastVueMultiObject_1, FastVueMultiUUID_1, FastVueMultiAnimate_1) {
1
+ define(["require", "exports", "tslib", "lodash", "./http/FastVueMultiHttp", "./other/FastVueMultiStore", "./vue/FastVueMultiConfig", "./http/FastVueMultiCookie", "./other/FastVueMultiClipboard", "./other/FastVueMultiDate", "./other/FastVueMultiBoolean", "./other/FastVueMultiFunction", "./other/FastVueMultiElement", "./other/FastVueMultiWindow", "./other/FastVueMultiFile", "./other/FastVueMultiBase64", "./other/FastVueMultiEventBus", "./other/FastVueMultiObject", "./other/FastVueMultiUUID", "./other/FastVueMultiAnimate", "moment"], function (require, exports, tslib_1, lodash_1, FastVueMultiHttp_1, FastVueMultiStore_1, FastVueMultiConfig_1, FastVueMultiCookie_1, FastVueMultiClipboard_1, FastVueMultiDate_1, FastVueMultiBoolean_1, FastVueMultiFunction_1, FastVueMultiElement_1, FastVueMultiWindow_1, FastVueMultiFile_1, FastVueMultiBase64_1, FastVueMultiEventBus_1, FastVueMultiObject_1, FastVueMultiUUID_1, FastVueMultiAnimate_1, moment_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.FastVueMultiTool = void 0;
5
5
  lodash_1 = tslib_1.__importDefault(lodash_1);
6
+ moment_1 = tslib_1.__importDefault(moment_1);
6
7
  /**
7
8
  * FastVueMultiTool 工具类
8
9
  */
@@ -89,6 +90,10 @@ define(["require", "exports", "tslib", "lodash", "./http/FastVueMultiHttp", "./o
89
90
  * 数值动画类
90
91
  */
91
92
  FastVueMultiTool.Animate = FastVueMultiAnimate_1.FastVueMultiAnimate;
93
+ /**
94
+ * moment工具类 http://momentjs.com/
95
+ */
96
+ FastVueMultiTool.Moment = moment_1.default;
92
97
  return FastVueMultiTool;
93
98
  }());
94
99
  exports.FastVueMultiTool = FastVueMultiTool;
@@ -1,4 +1,5 @@
1
1
  import { FastVueMultiTool } from "./FastVueMultiTool";
2
2
  import { FastVueMultiSimpleJsonResponse } from "./http/FastVueMultiSimpleJsonResponse";
3
3
  import { FastVueMultiSimpleRequestConfig } from "./http/FastVueMultiSimpleRequestConfig";
4
- export { FastVueMultiTool, FastVueMultiSimpleJsonResponse, FastVueMultiSimpleRequestConfig };
4
+ import { FastVueNative } from "./native/FastVueNative";
5
+ export { FastVueNative, FastVueMultiTool, FastVueMultiSimpleJsonResponse, FastVueMultiSimpleRequestConfig };
package/dist/esm/index.js CHANGED
@@ -1,8 +1,9 @@
1
- define(["require", "exports", "./FastVueMultiTool", "./http/FastVueMultiSimpleJsonResponse", "./http/FastVueMultiSimpleRequestConfig"], function (require, exports, FastVueMultiTool_1, FastVueMultiSimpleJsonResponse_1, FastVueMultiSimpleRequestConfig_1) {
1
+ define(["require", "exports", "./FastVueMultiTool", "./http/FastVueMultiSimpleJsonResponse", "./http/FastVueMultiSimpleRequestConfig", "./native/FastVueNative"], function (require, exports, FastVueMultiTool_1, FastVueMultiSimpleJsonResponse_1, FastVueMultiSimpleRequestConfig_1, FastVueNative_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.FastVueMultiSimpleRequestConfig = exports.FastVueMultiSimpleJsonResponse = exports.FastVueMultiTool = void 0;
4
+ exports.FastVueMultiSimpleRequestConfig = exports.FastVueMultiSimpleJsonResponse = exports.FastVueMultiTool = exports.FastVueNative = void 0;
5
5
  Object.defineProperty(exports, "FastVueMultiTool", { enumerable: true, get: function () { return FastVueMultiTool_1.FastVueMultiTool; } });
6
6
  Object.defineProperty(exports, "FastVueMultiSimpleJsonResponse", { enumerable: true, get: function () { return FastVueMultiSimpleJsonResponse_1.FastVueMultiSimpleJsonResponse; } });
7
7
  Object.defineProperty(exports, "FastVueMultiSimpleRequestConfig", { enumerable: true, get: function () { return FastVueMultiSimpleRequestConfig_1.FastVueMultiSimpleRequestConfig; } });
8
+ Object.defineProperty(exports, "FastVueNative", { enumerable: true, get: function () { return FastVueNative_1.FastVueNative; } });
8
9
  });
@@ -0,0 +1,71 @@
1
+ /**
2
+ * FastNative 调用Android或IOS原生方法工具
3
+ * @author Janesen
4
+ */
5
+ /**
6
+ * 执行本地方法核心类
7
+ */
8
+ export declare class FastVueNative {
9
+ private static methodInfos;
10
+ private static getKey;
11
+ private static showError;
12
+ /**
13
+ * 是否是安卓客户端
14
+ */
15
+ static isAndroid(): boolean;
16
+ /**
17
+ * 是否是ios客户端
18
+ */
19
+ static isIOS(): boolean;
20
+ /**
21
+ * 执行手机客户端原生方法
22
+ * @param methodName 方法名称
23
+ * @param methodParams 方法参数,Array格式,按照原生方法的参数顺序设置
24
+ * @param callBack 回调函数
25
+ */
26
+ static execute(methodName: string, methodParams: any, callBack?: (result: {
27
+ success: boolean;
28
+ message: string;
29
+ data: any;
30
+ }) => void): void;
31
+ /**
32
+ * 手机原生方法回执时调用
33
+ * @param key 回调函数的唯一标识
34
+ * @param result 回调结果
35
+ */
36
+ static appCallBack(key: string, result: string): void;
37
+ /**
38
+ * 递归执行回调,针对同一个浏览器下嵌入iframe问题
39
+ * @param targetWindow 目标window
40
+ * @param key
41
+ * @param result
42
+ * @private
43
+ */
44
+ private static doAppCallBack;
45
+ /**
46
+ * 手机原生方法回执时调用
47
+ * @param key 回调函数的唯一标识
48
+ * @param result 回调结果
49
+ */
50
+ private static executeAppCallBack;
51
+ /**
52
+ * 手机原生方法执行错误时调用
53
+ * @param message 错误信息
54
+ */
55
+ private static error;
56
+ /**
57
+ * 可同步或异步执行手机客户端原生方法
58
+ * @param methodName 方法名称
59
+ * @param methodParams 方法参数,Array格式,按照原生方法的参数顺序设置
60
+ * @param callBack 回调函数
61
+ */
62
+ static executeByPromise(methodName: string, methodParams: any, callBack?: (result: {
63
+ success: boolean;
64
+ message: string;
65
+ data?: any;
66
+ }) => void): Promise<{
67
+ success: boolean;
68
+ message: string;
69
+ data: any;
70
+ }>;
71
+ }
@@ -0,0 +1,181 @@
1
+ define(["require", "exports", "tslib", "../other/FastVueMultiObject", "../other/FastVueMultiBoolean"], function (require, exports, tslib_1, FastVueMultiObject_1, FastVueMultiBoolean_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.FastVueNative = void 0;
5
+ /**
6
+ * FastNative 调用Android或IOS原生方法工具
7
+ * @author Janesen
8
+ */
9
+ /**
10
+ * 执行本地方法核心类
11
+ */
12
+ var FastVueNative = /** @class */ (function () {
13
+ function FastVueNative() {
14
+ }
15
+ FastVueNative.getKey = function () {
16
+ var d = new Date().getTime();
17
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
18
+ var r = (d + Math.random() * 16) % 16 | 0;
19
+ d = Math.floor(d / 16);
20
+ return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
21
+ });
22
+ };
23
+ FastVueNative.showError = function (message) {
24
+ alert("FastAppJs发生错误:" + message);
25
+ };
26
+ /**
27
+ * 是否是安卓客户端
28
+ */
29
+ FastVueNative.isAndroid = function () {
30
+ return navigator.userAgent.toLowerCase().indexOf('android') > -1;
31
+ };
32
+ /**
33
+ * 是否是ios客户端
34
+ */
35
+ FastVueNative.isIOS = function () {
36
+ return navigator.userAgent.toLowerCase().indexOf('iphone') > -1;
37
+ };
38
+ /**
39
+ * 执行手机客户端原生方法
40
+ * @param methodName 方法名称
41
+ * @param methodParams 方法参数,Array格式,按照原生方法的参数顺序设置
42
+ * @param callBack 回调函数
43
+ */
44
+ FastVueNative.execute = function (methodName, methodParams, callBack) {
45
+ var Base64 = require("js-base64");
46
+ var key = this.getKey();
47
+ try {
48
+ if (methodParams == null) {
49
+ methodParams = [];
50
+ }
51
+ if (callBack == null) {
52
+ callBack = function (result) { };
53
+ }
54
+ this.methodInfos[key] = { methodName: methodName, methodParams: methodParams, callBack: callBack };
55
+ methodParams.unshift(key);
56
+ methodParams.forEach(function (value, index) {
57
+ if (value == null) {
58
+ methodParams[index] = "";
59
+ return true;
60
+ }
61
+ if (!(value instanceof Array)) {
62
+ methodParams[index] = value.toString();
63
+ }
64
+ });
65
+ if (this.isAndroid()) {
66
+ if (window["app"] && window["app"].doJavaScript && typeof (window["app"]).doJavaScript === 'function') {
67
+ window["app"].doJavaScript(methodName, Base64.encode(JSON.stringify(methodParams)));
68
+ }
69
+ else {
70
+ this.executeAppCallBack(key, Base64.encode(JSON.stringify({
71
+ success: false,
72
+ message: "客户端WebView不支持调用原生功能!",
73
+ data: null
74
+ })));
75
+ }
76
+ }
77
+ else if (this.isIOS()) {
78
+ var message = 'window.app.doJavaScript(' + methodName + ',' + Base64.encode(JSON.stringify(methodParams)) + ')';
79
+ alert(message); // IOS 使用alert触发程序中的事件,并过滤执行到客户端上的方法
80
+ }
81
+ else {
82
+ this.executeAppCallBack(key, Base64.encode(JSON.stringify({
83
+ success: false,
84
+ message: "客户端WebView不支持调用原生功能!",
85
+ data: null
86
+ })));
87
+ }
88
+ }
89
+ catch (e) {
90
+ console.error(e);
91
+ this.executeAppCallBack(key, Base64.encode(JSON.stringify({
92
+ success: false,
93
+ message: FastVueMultiObject_1.FastVueMultiObject.geErrorInfo(e),
94
+ data: null
95
+ })));
96
+ }
97
+ };
98
+ /**
99
+ * 手机原生方法回执时调用
100
+ * @param key 回调函数的唯一标识
101
+ * @param result 回调结果
102
+ */
103
+ FastVueNative.appCallBack = function (key, result) {
104
+ this.doAppCallBack(window, key, result);
105
+ };
106
+ /**
107
+ * 递归执行回调,针对同一个浏览器下嵌入iframe问题
108
+ * @param targetWindow 目标window
109
+ * @param key
110
+ * @param result
111
+ * @private
112
+ */
113
+ FastVueNative.doAppCallBack = function (targetWindow, key, result) {
114
+ if (targetWindow["appJs"]) {
115
+ targetWindow["appJs"].executeAppCallBack(key, result);
116
+ }
117
+ for (var i = 0; i < targetWindow.length; i++) {
118
+ this.doAppCallBack(targetWindow[i], key, result);
119
+ }
120
+ };
121
+ /**
122
+ * 手机原生方法回执时调用
123
+ * @param key 回调函数的唯一标识
124
+ * @param result 回调结果
125
+ */
126
+ FastVueNative.executeAppCallBack = function (key, result) {
127
+ var methodInfo = this.methodInfos[key.toString()];
128
+ if (methodInfo) {
129
+ var Base64 = require("js-base64");
130
+ result = Base64.decode(result);
131
+ var jsonData = JSON.parse(result);
132
+ try {
133
+ jsonData.success = FastVueMultiBoolean_1.FastVueMultiBoolean.parse(jsonData.success);
134
+ jsonData.data = jsonData.result;
135
+ if (methodInfo.callBack && typeof methodInfo.callBack === 'function') {
136
+ methodInfo.callBack(jsonData);
137
+ }
138
+ }
139
+ catch (e) {
140
+ console.error(e);
141
+ if (methodInfo.callBack && typeof methodInfo.callBack === 'function') {
142
+ methodInfo.callBack({ success: false, message: e.message, data: null });
143
+ }
144
+ }
145
+ finally {
146
+ console.info("执行原生方法:", methodInfo.methodName, "方法参数:", methodInfo.methodParams, "执行结果:", jsonData);
147
+ }
148
+ }
149
+ };
150
+ /**
151
+ * 手机原生方法执行错误时调用
152
+ * @param message 错误信息
153
+ */
154
+ FastVueNative.error = function (message) {
155
+ alert('手机原生端发生错误:' + message);
156
+ };
157
+ /**
158
+ * 可同步或异步执行手机客户端原生方法
159
+ * @param methodName 方法名称
160
+ * @param methodParams 方法参数,Array格式,按照原生方法的参数顺序设置
161
+ * @param callBack 回调函数
162
+ */
163
+ FastVueNative.executeByPromise = function (methodName, methodParams, callBack) {
164
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
165
+ return tslib_1.__generator(this, function (_a) {
166
+ return [2 /*return*/, new Promise(function (resolved, rejected) {
167
+ FastVueNative.execute(methodName, methodParams, function (result) {
168
+ if (callBack) {
169
+ callBack(result);
170
+ }
171
+ resolved(result);
172
+ });
173
+ })];
174
+ });
175
+ });
176
+ };
177
+ FastVueNative.methodInfos = {};
178
+ return FastVueNative;
179
+ }());
180
+ exports.FastVueNative = FastVueNative;
181
+ });
@@ -9,4 +9,9 @@ export declare class FastVueMultiObject {
9
9
  * @param value
10
10
  */
11
11
  static isValid(value: any): boolean;
12
+ /**
13
+ * 获取异常信息的堆栈信息
14
+ * @param event
15
+ */
16
+ static geErrorInfo(event: any): string;
12
17
  }
@@ -41,6 +41,28 @@ define(["require", "exports", "tslib", "lodash"], function (require, exports, ts
41
41
  }
42
42
  return true;
43
43
  };
44
+ /**
45
+ * 获取异常信息的堆栈信息
46
+ * @param event
47
+ */
48
+ FastVueMultiObject.geErrorInfo = function (event) {
49
+ if (event) {
50
+ if (event.error && event.error.stack) {
51
+ return event.error.stack;
52
+ }
53
+ else if (event.stack) {
54
+ return event.stack;
55
+ }
56
+ else if (event.message) {
57
+ return event.message;
58
+ }
59
+ else if (event.reason) {
60
+ return event.reason;
61
+ }
62
+ return event.toString();
63
+ }
64
+ return "";
65
+ };
44
66
  return FastVueMultiObject;
45
67
  }());
46
68
  exports.FastVueMultiObject = FastVueMultiObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fast-vue-multi-pages",
3
- "version": "1.0.29",
3
+ "version": "1.1.0",
4
4
  "author": "janesen",
5
5
  "description": "快速搭建VUE项目工具类的基本库,主要用于每个功能页面独立生成html",
6
6
  "main": "./dist/cjs/index.js",
package/vue/FastPages.js CHANGED
@@ -136,9 +136,9 @@ export default defineComponent({
136
136
  else {
137
137
  options = new FastBuildOption_1.FastBuildOption();
138
138
  }
139
- let baseDir = path.join(dirName, "_auto", "index");
139
+ let baseDir = path.join(dirName, "src", "__pages_auto", "index");
140
140
  if (!fs.existsSync(baseDir)) {
141
- fs.mkdirSync(baseDir);
141
+ fs.mkdirSync(baseDir, { recursive: true });
142
142
  }
143
143
  let indexJsContent = "import {createApp} from \"vue\";\n";
144
144
  indexJsContent += "import main from \"./main\";\n";