fast-vue-multi-pages 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +63 -0
- package/dist/cjs/FastVueMultiTool.d.ts +60 -0
- package/dist/cjs/FastVueMultiTool.js +65 -0
- package/dist/cjs/http/FastVueMultiCookie.d.ts +18 -0
- package/dist/cjs/http/FastVueMultiCookie.js +30 -0
- package/dist/cjs/http/FastVueMultiHttp.d.ts +225 -0
- package/dist/cjs/http/FastVueMultiHttp.js +572 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/loader/FastTagBuilderLoader.d.ts +2 -0
- package/dist/cjs/loader/FastTagBuilderLoader.js +89 -0
- package/dist/cjs/other/FastVueMultiBoolean.d.ts +13 -0
- package/dist/cjs/other/FastVueMultiBoolean.js +56 -0
- package/dist/cjs/other/FastVueMultiClipboard.d.ts +21 -0
- package/dist/cjs/other/FastVueMultiClipboard.js +38 -0
- package/dist/cjs/other/FastVueMultiDate.d.ts +30 -0
- package/dist/cjs/other/FastVueMultiDate.js +166 -0
- package/dist/cjs/other/FastVueMultiElement.d.ts +46 -0
- package/dist/cjs/other/FastVueMultiElement.js +154 -0
- package/dist/cjs/other/FastVueMultiFunction.d.ts +19 -0
- package/dist/cjs/other/FastVueMultiFunction.js +68 -0
- package/dist/cjs/other/FastVueMultiStore.d.ts +13 -0
- package/dist/cjs/other/FastVueMultiStore.js +23 -0
- package/dist/cjs/other/FastVueMultiWindow.d.ts +21 -0
- package/dist/cjs/other/FastVueMultiWindow.js +53 -0
- package/dist/cjs/store/FastVueMultiStore.d.ts +13 -0
- package/dist/cjs/store/FastVueMultiStore.js +23 -0
- package/dist/cjs/vue/FastVueMultiConfig.d.ts +18 -0
- package/dist/cjs/vue/FastVueMultiConfig.js +43 -0
- package/dist/esm/FastVueMultiTool.d.ts +60 -0
- package/dist/esm/FastVueMultiTool.js +59 -0
- package/dist/esm/http/FastVueMultiCookie.d.ts +18 -0
- package/dist/esm/http/FastVueMultiCookie.js +34 -0
- package/dist/esm/http/FastVueMultiHttp.d.ts +225 -0
- package/dist/esm/http/FastVueMultiHttp.js +608 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/loader/FastTagBuilderLoader.d.ts +2 -0
- package/dist/esm/loader/FastTagBuilderLoader.js +89 -0
- package/dist/esm/other/FastVueMultiBoolean.d.ts +13 -0
- package/dist/esm/other/FastVueMultiBoolean.js +60 -0
- package/dist/esm/other/FastVueMultiClipboard.d.ts +21 -0
- package/dist/esm/other/FastVueMultiClipboard.js +56 -0
- package/dist/esm/other/FastVueMultiDate.d.ts +30 -0
- package/dist/esm/other/FastVueMultiDate.js +170 -0
- package/dist/esm/other/FastVueMultiElement.d.ts +46 -0
- package/dist/esm/other/FastVueMultiElement.js +158 -0
- package/dist/esm/other/FastVueMultiFunction.d.ts +19 -0
- package/dist/esm/other/FastVueMultiFunction.js +97 -0
- package/dist/esm/other/FastVueMultiStore.d.ts +13 -0
- package/dist/esm/other/FastVueMultiStore.js +27 -0
- package/dist/esm/other/FastVueMultiWindow.d.ts +21 -0
- package/dist/esm/other/FastVueMultiWindow.js +57 -0
- package/dist/esm/store/FastVueMultiStore.d.ts +13 -0
- package/dist/esm/store/FastVueMultiStore.js +27 -0
- package/dist/esm/vue/FastVueMultiConfig.d.ts +18 -0
- package/dist/esm/vue/FastVueMultiConfig.js +48 -0
- package/package.json +64 -0
- package/vue/FastBuildOption.d.ts +241 -0
- package/vue/FastBuildOption.js +249 -0
- package/vue/FastInjectJsPlugin.d.ts +11 -0
- package/vue/FastInjectJsPlugin.js +101 -0
- package/vue/FastPages.d.ts +25 -0
- package/vue/FastPages.js +173 -0
- package/vue/FastVueMultiConfig.d.ts +18 -0
- package/vue/FastVueMultiConfig.js +43 -0
- package/vue/FastVueMultiPages.d.ts +62 -0
- package/vue/FastVueMultiPages.js +294 -0
- package/vue/index.d.ts +2 -0
- package/vue/index.js +5 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FastVueMultiBoolean = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
6
|
+
class FastVueMultiBoolean {
|
7
|
+
/**
|
8
|
+
* 判断目标值是否为布尔值
|
9
|
+
* @param source
|
10
|
+
*/
|
11
|
+
static isBoolean(source) {
|
12
|
+
if (source == null) {
|
13
|
+
return false;
|
14
|
+
}
|
15
|
+
if (source instanceof Boolean) {
|
16
|
+
return true;
|
17
|
+
}
|
18
|
+
return typeof source === 'boolean';
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* 转为布尔值
|
22
|
+
* @param source 目标值
|
23
|
+
* @param defaultValue 默认值,当为空或无效的布尔值时 返回
|
24
|
+
*/
|
25
|
+
static parse(source, defaultValue) {
|
26
|
+
if (lodash_1.default.isEmpty(defaultValue)) {
|
27
|
+
defaultValue = false;
|
28
|
+
}
|
29
|
+
if (lodash_1.default.isEmpty(source)) {
|
30
|
+
return defaultValue;
|
31
|
+
}
|
32
|
+
if (lodash_1.default.isString(source)) {
|
33
|
+
if (source === "0" || source.toLowerCase() === "false") {
|
34
|
+
return false;
|
35
|
+
}
|
36
|
+
if (source === "1" || source.toLowerCase() === "true") {
|
37
|
+
return true;
|
38
|
+
}
|
39
|
+
return defaultValue;
|
40
|
+
}
|
41
|
+
if (lodash_1.default.isNumber(source)) {
|
42
|
+
if (source === 0) {
|
43
|
+
return false;
|
44
|
+
}
|
45
|
+
if (source === 1) {
|
46
|
+
return true;
|
47
|
+
}
|
48
|
+
return defaultValue;
|
49
|
+
}
|
50
|
+
if (this.isBoolean(source)) {
|
51
|
+
return source;
|
52
|
+
}
|
53
|
+
return defaultValue;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
exports.FastVueMultiBoolean = FastVueMultiBoolean;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import * as clipboard from "clipboard-polyfill";
|
2
|
+
export declare class FastVueMultiClipboard {
|
3
|
+
/**
|
4
|
+
* 将内容复制到剪贴板中
|
5
|
+
* @param content
|
6
|
+
*/
|
7
|
+
static copy(content: string): Promise<void>;
|
8
|
+
/**
|
9
|
+
* 将blob复制到剪贴板中
|
10
|
+
* @param blob
|
11
|
+
*/
|
12
|
+
static copyBlob(blob: Blob): Promise<void>;
|
13
|
+
/**
|
14
|
+
* 获取剪贴板的文本内容
|
15
|
+
*/
|
16
|
+
static getText(): Promise<string | undefined>;
|
17
|
+
/**
|
18
|
+
* 获取剪贴板的ClipboardItem内容
|
19
|
+
*/
|
20
|
+
static getItems(): Promise<clipboard.ClipboardItems | undefined>;
|
21
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FastVueMultiClipboard = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const clipboard = tslib_1.__importStar(require("clipboard-polyfill"));
|
6
|
+
class FastVueMultiClipboard {
|
7
|
+
/**
|
8
|
+
* 将内容复制到剪贴板中
|
9
|
+
* @param content
|
10
|
+
*/
|
11
|
+
static copy(content) {
|
12
|
+
return clipboard.writeText(content);
|
13
|
+
}
|
14
|
+
/**
|
15
|
+
* 将blob复制到剪贴板中
|
16
|
+
* @param blob
|
17
|
+
*/
|
18
|
+
static copyBlob(blob) {
|
19
|
+
let contentType = blob.type;
|
20
|
+
let items = {};
|
21
|
+
items[contentType] = blob;
|
22
|
+
const item = new clipboard.ClipboardItem(items);
|
23
|
+
return clipboard.write([item]);
|
24
|
+
}
|
25
|
+
/**
|
26
|
+
* 获取剪贴板的文本内容
|
27
|
+
*/
|
28
|
+
static async getText() {
|
29
|
+
return await clipboard.readText();
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* 获取剪贴板的ClipboardItem内容
|
33
|
+
*/
|
34
|
+
static async getItems() {
|
35
|
+
return await clipboard.read();
|
36
|
+
}
|
37
|
+
}
|
38
|
+
exports.FastVueMultiClipboard = FastVueMultiClipboard;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
export declare class FastVueMultiDate {
|
2
|
+
/**
|
3
|
+
* 判断目标值是否是日期类型
|
4
|
+
* @param source
|
5
|
+
*/
|
6
|
+
static isDate(source: any): boolean;
|
7
|
+
/**
|
8
|
+
* 格式化日期
|
9
|
+
* @param source 日期
|
10
|
+
* @param pattern 格式类型,例如:yyyy-MM-DD HH:mm:ss,更多查看:https://momentjs.com/docs/#/displaying/
|
11
|
+
*/
|
12
|
+
static format(source: Date, pattern: string): string | null;
|
13
|
+
/**
|
14
|
+
* 将字符串日期转换为Date对象
|
15
|
+
* @param source 日期值
|
16
|
+
*/
|
17
|
+
static parse(source: string): Date | null;
|
18
|
+
/**
|
19
|
+
* 格式化日期的友好展示,例如:1分钟前,3分钟前
|
20
|
+
* @param source
|
21
|
+
* @param level 精确级别 1 分钟 2 小时 3 天 4 周 5 月
|
22
|
+
*/
|
23
|
+
static formatNice(source: string, level?: number): string | null;
|
24
|
+
/**
|
25
|
+
* 将总时间转换为中文描述,最高描述到:天,例如:2天03时45分09秒
|
26
|
+
* @param timestamp 时间戳 单位:毫秒
|
27
|
+
* @param chinese 是否用中文表达,默认:true
|
28
|
+
*/
|
29
|
+
static toDescription(timestamp: number, chinese: boolean): string;
|
30
|
+
}
|
@@ -0,0 +1,166 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FastVueMultiDate = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const moment_1 = tslib_1.__importDefault(require("moment"));
|
6
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
7
|
+
class FastVueMultiDate {
|
8
|
+
/**
|
9
|
+
* 判断目标值是否是日期类型
|
10
|
+
* @param source
|
11
|
+
*/
|
12
|
+
static isDate(source) {
|
13
|
+
if (source == null) {
|
14
|
+
return false;
|
15
|
+
}
|
16
|
+
if (source instanceof Date) {
|
17
|
+
return true;
|
18
|
+
}
|
19
|
+
return toString.call(source) === '[object Date]';
|
20
|
+
}
|
21
|
+
/**
|
22
|
+
* 格式化日期
|
23
|
+
* @param source 日期
|
24
|
+
* @param pattern 格式类型,例如:yyyy-MM-DD HH:mm:ss,更多查看:https://momentjs.com/docs/#/displaying/
|
25
|
+
*/
|
26
|
+
static format(source, pattern) {
|
27
|
+
if (lodash_1.default.isEmpty(pattern)) {
|
28
|
+
return null;
|
29
|
+
}
|
30
|
+
if (lodash_1.default.isEmpty(source)) {
|
31
|
+
return null;
|
32
|
+
}
|
33
|
+
return (0, moment_1.default)(source).format(pattern);
|
34
|
+
}
|
35
|
+
/**
|
36
|
+
* 将字符串日期转换为Date对象
|
37
|
+
* @param source 日期值
|
38
|
+
*/
|
39
|
+
static parse(source) {
|
40
|
+
if (lodash_1.default.isEmpty(source)) {
|
41
|
+
return null;
|
42
|
+
}
|
43
|
+
return (0, moment_1.default)(source).toDate();
|
44
|
+
}
|
45
|
+
/**
|
46
|
+
* 格式化日期的友好展示,例如:1分钟前,3分钟前
|
47
|
+
* @param source
|
48
|
+
* @param level 精确级别 1 分钟 2 小时 3 天 4 周 5 月
|
49
|
+
*/
|
50
|
+
static formatNice(source, level) {
|
51
|
+
if (lodash_1.default.isEmpty(source)) {
|
52
|
+
return null;
|
53
|
+
}
|
54
|
+
if (level === undefined) {
|
55
|
+
level = 2;
|
56
|
+
}
|
57
|
+
const seconds = 1000;
|
58
|
+
const minute = seconds * 60;
|
59
|
+
const hour = minute * 60;
|
60
|
+
const day = hour * 24;
|
61
|
+
const week = day * 7;
|
62
|
+
const month = day * 30;
|
63
|
+
const time1 = new Date().getTime(); //当前的时间戳
|
64
|
+
const sourceDate = this.parse(source);
|
65
|
+
if (!sourceDate) {
|
66
|
+
return null;
|
67
|
+
}
|
68
|
+
const time2 = sourceDate.getTime();
|
69
|
+
const time = time1 - time2;
|
70
|
+
if (time <= minute) {
|
71
|
+
return "刚刚";
|
72
|
+
}
|
73
|
+
if (time / month >= 3) {
|
74
|
+
return this.format(sourceDate, "yyyy-MM-DD HH:mm");
|
75
|
+
}
|
76
|
+
let nice = true;
|
77
|
+
if (time / month >= 1) {
|
78
|
+
if (level >= 5) {
|
79
|
+
return parseInt(String(time / month)) + "个月前";
|
80
|
+
}
|
81
|
+
nice = false;
|
82
|
+
}
|
83
|
+
if (nice && time / week >= 1) {
|
84
|
+
if (level >= 4) {
|
85
|
+
return parseInt(String(time / week)) + "周前";
|
86
|
+
}
|
87
|
+
nice = false;
|
88
|
+
}
|
89
|
+
if (nice && time / day >= 1) {
|
90
|
+
if (level >= 3) {
|
91
|
+
return parseInt(String(time / day)) + "天前";
|
92
|
+
}
|
93
|
+
nice = false;
|
94
|
+
}
|
95
|
+
if (nice && time / hour >= 1) {
|
96
|
+
if (level >= 2) {
|
97
|
+
return parseInt(String(time / hour)) + "小时前";
|
98
|
+
}
|
99
|
+
nice = false;
|
100
|
+
}
|
101
|
+
if (nice && time / minute >= 1) {
|
102
|
+
if (level >= 1) {
|
103
|
+
return parseInt(String(time / minute)) + "分钟前";
|
104
|
+
}
|
105
|
+
}
|
106
|
+
return this.format(sourceDate, "yyyy-MM-DD HH:mm");
|
107
|
+
}
|
108
|
+
/**
|
109
|
+
* 将总时间转换为中文描述,最高描述到:天,例如:2天03时45分09秒
|
110
|
+
* @param timestamp 时间戳 单位:毫秒
|
111
|
+
* @param chinese 是否用中文表达,默认:true
|
112
|
+
*/
|
113
|
+
static toDescription(timestamp, chinese) {
|
114
|
+
if (chinese === undefined) {
|
115
|
+
chinese = true;
|
116
|
+
}
|
117
|
+
let seconds = 1000, minuteUnit = 1000 * 60, hourUnit = 1000 * 60 * 60, dayUnit = 1000 * 60 * 60 * 24;
|
118
|
+
let descriptions = [];
|
119
|
+
if (timestamp < seconds) {
|
120
|
+
descriptions.push("00" + (chinese ? '秒' : ''));
|
121
|
+
return descriptions.join("");
|
122
|
+
}
|
123
|
+
else if (timestamp < minuteUnit) {
|
124
|
+
descriptions.push(lodash_1.default.padStart(String(timestamp / seconds), 2, "0") + (chinese ? '秒' : ''));
|
125
|
+
return descriptions.join("");
|
126
|
+
}
|
127
|
+
if (timestamp < hourUnit) {
|
128
|
+
let minute = parseInt(String(timestamp / minuteUnit));
|
129
|
+
descriptions.push(lodash_1.default.padStart(String(minute), 2, "0") + (chinese ? '分' : ':'));
|
130
|
+
let nextTimestamp = timestamp - parseInt(String(minute * minuteUnit));
|
131
|
+
if (nextTimestamp === 0) {
|
132
|
+
descriptions.push("00" + (chinese ? '秒' : ''));
|
133
|
+
}
|
134
|
+
else {
|
135
|
+
descriptions.push(this.toDescription(nextTimestamp, chinese));
|
136
|
+
}
|
137
|
+
return descriptions.join("");
|
138
|
+
}
|
139
|
+
if (timestamp < dayUnit) {
|
140
|
+
let hour = parseInt(String(timestamp / hourUnit));
|
141
|
+
descriptions.push(lodash_1.default.padStart(String(hour), 2, "0") + (chinese ? '时' : ':'));
|
142
|
+
let nextTimestamp = timestamp - parseInt(String(hour * hourUnit));
|
143
|
+
if (nextTimestamp === 0) {
|
144
|
+
descriptions.push("00" + (chinese ? '分' : ':'));
|
145
|
+
descriptions.push("00" + (chinese ? '秒' : ''));
|
146
|
+
}
|
147
|
+
else {
|
148
|
+
descriptions.push(this.toDescription(nextTimestamp, chinese));
|
149
|
+
}
|
150
|
+
return descriptions.join("");
|
151
|
+
}
|
152
|
+
let day = parseInt(String(timestamp / dayUnit));
|
153
|
+
descriptions.push(day + (chinese ? '天' : 'day '));
|
154
|
+
let nextTimestamp = timestamp - parseInt(String(day * dayUnit));
|
155
|
+
if (nextTimestamp === 0) {
|
156
|
+
descriptions.push("00" + (chinese ? '时' : ':'));
|
157
|
+
descriptions.push("00" + (chinese ? '分' : ':'));
|
158
|
+
descriptions.push("00" + (chinese ? '秒' : ''));
|
159
|
+
}
|
160
|
+
else {
|
161
|
+
descriptions.push(this.toDescription(nextTimestamp, chinese));
|
162
|
+
}
|
163
|
+
return descriptions.join("");
|
164
|
+
}
|
165
|
+
}
|
166
|
+
exports.FastVueMultiDate = FastVueMultiDate;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
export declare class FastVueMultiElement {
|
2
|
+
/**
|
3
|
+
* 绑定节点属性变动的监听
|
4
|
+
* @param source 节点对象
|
5
|
+
* @param attrs 需要监听的属性集合
|
6
|
+
* @param callBack 回调
|
7
|
+
*/
|
8
|
+
static onAttributesChange(source: Element, attrs: any[], callBack?: (event: MutationRecord) => void): MutationObserver | null;
|
9
|
+
/**
|
10
|
+
* 绑定当前节点子节点的变动的监听
|
11
|
+
* @param source 节点对象
|
12
|
+
* @param callBack 回调
|
13
|
+
*/
|
14
|
+
static onChildrenChange(source: Element, callBack?: (event: MutationRecord) => void): MutationObserver | null;
|
15
|
+
/**
|
16
|
+
* 在目标节点后追加新的节点
|
17
|
+
* @param targetEl 目标节点
|
18
|
+
* @param newEl 新的节点
|
19
|
+
*/
|
20
|
+
static insertAfter(targetEl: Element, newEl: Element): void;
|
21
|
+
/**
|
22
|
+
* 在目标节点前追加新的节点
|
23
|
+
* @param targetEl 目标节点
|
24
|
+
* @param newEl 新的节点
|
25
|
+
*/
|
26
|
+
static insertBefore(targetEl: Element, newEl: Element): void;
|
27
|
+
/**
|
28
|
+
* 获取目标节点的实际占位空间,包含的内外边距
|
29
|
+
* @param targetEl
|
30
|
+
*/
|
31
|
+
static getRealSize(targetEl: Element): {
|
32
|
+
width: number;
|
33
|
+
height: number;
|
34
|
+
};
|
35
|
+
/**
|
36
|
+
* 获取目标节点的selector
|
37
|
+
* @param targetEl
|
38
|
+
*/
|
39
|
+
static getPath(targetEl: Element): string;
|
40
|
+
/**
|
41
|
+
* 判断目标元素的滚动条 是否已滚动到底部
|
42
|
+
* @param targetEl
|
43
|
+
* @param scrollNimble 检测的灵敏度,越大越灵敏
|
44
|
+
*/
|
45
|
+
static isScrollBottom(targetEl: Element, scrollNimble: number): boolean;
|
46
|
+
}
|
@@ -0,0 +1,154 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FastVueMultiElement = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
6
|
+
class FastVueMultiElement {
|
7
|
+
/**
|
8
|
+
* 绑定节点属性变动的监听
|
9
|
+
* @param source 节点对象
|
10
|
+
* @param attrs 需要监听的属性集合
|
11
|
+
* @param callBack 回调
|
12
|
+
*/
|
13
|
+
static onAttributesChange(source, attrs, callBack) {
|
14
|
+
if (source) {
|
15
|
+
const observe = new MutationObserver(mutationsList => {
|
16
|
+
mutationsList.forEach((item, index) => {
|
17
|
+
if (callBack) {
|
18
|
+
callBack(item);
|
19
|
+
}
|
20
|
+
});
|
21
|
+
});
|
22
|
+
observe.observe(source, {
|
23
|
+
attributes: true,
|
24
|
+
attributeFilter: attrs
|
25
|
+
});
|
26
|
+
return observe;
|
27
|
+
}
|
28
|
+
return null;
|
29
|
+
}
|
30
|
+
/**
|
31
|
+
* 绑定当前节点子节点的变动的监听
|
32
|
+
* @param source 节点对象
|
33
|
+
* @param callBack 回调
|
34
|
+
*/
|
35
|
+
static onChildrenChange(source, callBack) {
|
36
|
+
if (source) {
|
37
|
+
const observe = new MutationObserver(mutationsList => {
|
38
|
+
mutationsList.forEach((item, index) => {
|
39
|
+
if (callBack) {
|
40
|
+
callBack(item);
|
41
|
+
}
|
42
|
+
});
|
43
|
+
});
|
44
|
+
observe.observe(source, {
|
45
|
+
childList: true,
|
46
|
+
subtree: true
|
47
|
+
});
|
48
|
+
return observe;
|
49
|
+
}
|
50
|
+
return null;
|
51
|
+
}
|
52
|
+
/**
|
53
|
+
* 在目标节点后追加新的节点
|
54
|
+
* @param targetEl 目标节点
|
55
|
+
* @param newEl 新的节点
|
56
|
+
*/
|
57
|
+
static insertAfter(targetEl, newEl) {
|
58
|
+
let parent = targetEl.parentNode;
|
59
|
+
if (parent.lastChild === targetEl) {
|
60
|
+
parent.appendChild(newEl);
|
61
|
+
}
|
62
|
+
else {
|
63
|
+
parent.insertBefore(newEl, targetEl.nextSibling);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
/**
|
67
|
+
* 在目标节点前追加新的节点
|
68
|
+
* @param targetEl 目标节点
|
69
|
+
* @param newEl 新的节点
|
70
|
+
*/
|
71
|
+
static insertBefore(targetEl, newEl) {
|
72
|
+
let parent = targetEl.parentNode;
|
73
|
+
if (parent.lastChild === targetEl) {
|
74
|
+
parent.appendChild(newEl);
|
75
|
+
}
|
76
|
+
else {
|
77
|
+
parent.insertBefore(newEl, targetEl);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
/**
|
81
|
+
* 获取目标节点的实际占位空间,包含的内外边距
|
82
|
+
* @param targetEl
|
83
|
+
*/
|
84
|
+
static getRealSize(targetEl) {
|
85
|
+
let childStyle = window.getComputedStyle(targetEl);
|
86
|
+
let height = lodash_1.default.parseInt(childStyle.height);
|
87
|
+
let width = lodash_1.default.parseInt(childStyle.width);
|
88
|
+
let vSpace = lodash_1.default.parseInt(childStyle.marginTop)
|
89
|
+
+ lodash_1.default.parseInt(childStyle.marginBottom)
|
90
|
+
+ lodash_1.default.parseInt(childStyle.paddingTop)
|
91
|
+
+ lodash_1.default.parseInt(childStyle.paddingBottom);
|
92
|
+
let hSpace = lodash_1.default.parseInt(childStyle.marginLeft)
|
93
|
+
+ lodash_1.default.parseInt(childStyle.marginRight)
|
94
|
+
+ lodash_1.default.parseInt(childStyle.paddingLeft)
|
95
|
+
+ lodash_1.default.parseInt(childStyle.paddingRight);
|
96
|
+
return { width: width + hSpace, height: height + vSpace };
|
97
|
+
}
|
98
|
+
/**
|
99
|
+
* 获取目标节点的selector
|
100
|
+
* @param targetEl
|
101
|
+
*/
|
102
|
+
static getPath(targetEl) {
|
103
|
+
let currEl = targetEl;
|
104
|
+
let domPath = [];
|
105
|
+
if (currEl.id) {
|
106
|
+
domPath.unshift('#' + currEl.id);
|
107
|
+
}
|
108
|
+
else {
|
109
|
+
while (currEl.nodeName.toLowerCase() !== "html") {
|
110
|
+
if (currEl.id) {
|
111
|
+
domPath.unshift('#' + currEl.id);
|
112
|
+
break;
|
113
|
+
}
|
114
|
+
else if (currEl.tagName.toLocaleLowerCase() === "body") {
|
115
|
+
domPath.unshift(currEl.tagName.toLowerCase());
|
116
|
+
}
|
117
|
+
else {
|
118
|
+
for (let i = 0; i < currEl.parentNode.childElementCount; i++) {
|
119
|
+
if (currEl.parentNode.children[i] === currEl) {
|
120
|
+
let className = currEl.getAttribute('class');
|
121
|
+
if (className) {
|
122
|
+
let selectors = currEl.className.split(/\s/g), array = [];
|
123
|
+
for (let j = 0; j < selectors.length; ++j) {
|
124
|
+
if (selectors[j].length > 0) {
|
125
|
+
array.push('.' + selectors[j]);
|
126
|
+
}
|
127
|
+
}
|
128
|
+
className = array.join("");
|
129
|
+
}
|
130
|
+
else {
|
131
|
+
className = "";
|
132
|
+
}
|
133
|
+
domPath.unshift(currEl.tagName.toLowerCase() + className + ':nth-child(' + (i + 1) + ')');
|
134
|
+
}
|
135
|
+
}
|
136
|
+
}
|
137
|
+
currEl = currEl.parentNode;
|
138
|
+
}
|
139
|
+
}
|
140
|
+
return domPath.join(' > ');
|
141
|
+
}
|
142
|
+
/**
|
143
|
+
* 判断目标元素的滚动条 是否已滚动到底部
|
144
|
+
* @param targetEl
|
145
|
+
* @param scrollNimble 检测的灵敏度,越大越灵敏
|
146
|
+
*/
|
147
|
+
static isScrollBottom(targetEl, scrollNimble) {
|
148
|
+
const scrollTop = targetEl.scrollTop;
|
149
|
+
const elHeight = targetEl.getBoundingClientRect().height;
|
150
|
+
const scrollHeight = targetEl.scrollHeight;
|
151
|
+
return scrollTop + elHeight >= (scrollHeight - scrollNimble);
|
152
|
+
}
|
153
|
+
}
|
154
|
+
exports.FastVueMultiElement = FastVueMultiElement;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
export declare class FastVueMultiFunction {
|
2
|
+
/**
|
3
|
+
* 判断目标类型是否为函数
|
4
|
+
* @param source
|
5
|
+
*/
|
6
|
+
static isFunction(source: any): boolean;
|
7
|
+
/**
|
8
|
+
* 批量执行函数并获取返回值
|
9
|
+
* @param source 单个函数或函数数组
|
10
|
+
* @param params 执行函数携带的参数
|
11
|
+
*/
|
12
|
+
static run(source: any, ...params: any[]): any | null;
|
13
|
+
/**
|
14
|
+
* 按顺序同步执行函数,当其中一个函数返回false时,则终止后续执行
|
15
|
+
* @param source 单个函数或函数数组
|
16
|
+
* @param params 执行函数携带的参数
|
17
|
+
*/
|
18
|
+
static syncRun(source: any, ...params: any[]): Promise<void>;
|
19
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FastVueMultiFunction = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
6
|
+
const FastVueMultiBoolean_1 = require("./FastVueMultiBoolean");
|
7
|
+
class FastVueMultiFunction {
|
8
|
+
/**
|
9
|
+
* 判断目标类型是否为函数
|
10
|
+
* @param source
|
11
|
+
*/
|
12
|
+
static isFunction(source) {
|
13
|
+
if (source == null) {
|
14
|
+
return false;
|
15
|
+
}
|
16
|
+
return !!source && typeof source === 'function';
|
17
|
+
}
|
18
|
+
/**
|
19
|
+
* 批量执行函数并获取返回值
|
20
|
+
* @param source 单个函数或函数数组
|
21
|
+
* @param params 执行函数携带的参数
|
22
|
+
*/
|
23
|
+
static run(source, ...params) {
|
24
|
+
const result = [];
|
25
|
+
if (this.isFunction(source)) {
|
26
|
+
result.push(source.apply(this, params));
|
27
|
+
}
|
28
|
+
else if (lodash_1.default.isArray(source)) {
|
29
|
+
for (let i = 0; i < source.length; i++) {
|
30
|
+
result.push(source[i].apply(this, params));
|
31
|
+
}
|
32
|
+
}
|
33
|
+
else if (lodash_1.default.isString(source)) {
|
34
|
+
result.push(eval(source));
|
35
|
+
}
|
36
|
+
if (result.length == 1) {
|
37
|
+
return result[0];
|
38
|
+
}
|
39
|
+
else if (result.length > 1) {
|
40
|
+
return result;
|
41
|
+
}
|
42
|
+
return null;
|
43
|
+
}
|
44
|
+
/**
|
45
|
+
* 按顺序同步执行函数,当其中一个函数返回false时,则终止后续执行
|
46
|
+
* @param source 单个函数或函数数组
|
47
|
+
* @param params 执行函数携带的参数
|
48
|
+
*/
|
49
|
+
static async syncRun(source, ...params) {
|
50
|
+
if (lodash_1.default.isArray(source)) {
|
51
|
+
for (let i = 0; i < source.length; i++) {
|
52
|
+
if (lodash_1.default.isFunction(source[i])) {
|
53
|
+
let result = await source[i].apply(this, params);
|
54
|
+
if (!FastVueMultiBoolean_1.FastVueMultiBoolean.parse(result, false)) {
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
else if (this.isFunction(source)) {
|
61
|
+
source.apply(this, params);
|
62
|
+
}
|
63
|
+
else if (lodash_1.default.isString(source)) {
|
64
|
+
eval(source);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
exports.FastVueMultiFunction = FastVueMultiFunction;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FastVueMultiStore = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const store2_1 = tslib_1.__importDefault(require("store2"));
|
6
|
+
class FastVueMultiStore {
|
7
|
+
/**
|
8
|
+
* 设置缓存的值
|
9
|
+
* @param key 键
|
10
|
+
* @param value 值
|
11
|
+
*/
|
12
|
+
static setValue(key, value) {
|
13
|
+
store2_1.default.set(key, value, true);
|
14
|
+
}
|
15
|
+
/**
|
16
|
+
* 获取缓存的值
|
17
|
+
* @param key 键
|
18
|
+
*/
|
19
|
+
static getValue(key) {
|
20
|
+
return store2_1.default.get(key);
|
21
|
+
}
|
22
|
+
}
|
23
|
+
exports.FastVueMultiStore = FastVueMultiStore;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
export declare class FastVueMultiWindow {
|
2
|
+
/**
|
3
|
+
* 添加window的onLoad事件,如果存在onLoad函数名则进行合并
|
4
|
+
* @param callBack
|
5
|
+
*/
|
6
|
+
static addOnLoad(callBack: () => void): void;
|
7
|
+
/**
|
8
|
+
* 添加window的函数,如果存在相同的函数名则进行合并
|
9
|
+
* @param functionName 函数名
|
10
|
+
* @param functionBody 函数执行的代码
|
11
|
+
*/
|
12
|
+
static addFunction(functionName: string, functionBody: (params: any) => void): void;
|
13
|
+
/**
|
14
|
+
* 安全的获取窗口宽度,有的手机渲染后document.body.clientWidth 莫明会返回0
|
15
|
+
*/
|
16
|
+
static safeGetClientWidth(): number;
|
17
|
+
/**
|
18
|
+
* 安全的获取窗口高度,有的手机渲染后document.body.clientHeight 莫明会返回0
|
19
|
+
*/
|
20
|
+
static safeGetClientHeight(): number;
|
21
|
+
}
|