@wiajs/core 0.1.12 → 0.1.16
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/build.js +11 -6
- package/dist/core.common.js +200 -120
- package/dist/core.common.min.js +3 -3
- package/dist/core.esm.js +198 -119
- package/dist/core.esm.min.js +3 -3
- package/dist/core.js +202 -122
- package/dist/core.min.js +3 -3
- package/lib/bmap.js +12 -12
- package/package.json +1 -2
- package/util/tool.js +50 -2
- package/util/wiafile.js +41 -26
- package/util/wiapage.js +27 -20
package/dist/core.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wia core v0.1.
|
|
3
|
-
* (c)
|
|
2
|
+
* wia core v0.1.16
|
|
3
|
+
* (c) 2021 Sibyl Yu
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
6
|
(function (global, factory) {
|
|
7
7
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
8
8
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
9
|
-
(global = global || self, factory(global[
|
|
10
|
-
}(this, function (exports) { 'use strict';
|
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@wiajs/Core"] = {}));
|
|
10
|
+
})(this, (function (exports) { 'use strict';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* promise version ajax get、post
|
|
14
14
|
* return Promise objext.
|
|
15
15
|
* get move to base.js
|
|
16
16
|
*/
|
|
17
|
-
var Ajax =
|
|
18
|
-
/*#__PURE__*/
|
|
19
|
-
function () {
|
|
17
|
+
var Ajax = /*#__PURE__*/function () {
|
|
20
18
|
function Ajax() {}
|
|
21
19
|
|
|
22
20
|
var _proto = Ajax.prototype;
|
|
@@ -122,7 +120,8 @@
|
|
|
122
120
|
function _inheritsLoose(subClass, superClass) {
|
|
123
121
|
subClass.prototype = Object.create(superClass.prototype);
|
|
124
122
|
subClass.prototype.constructor = subClass;
|
|
125
|
-
|
|
123
|
+
|
|
124
|
+
_setPrototypeOf(subClass, superClass);
|
|
126
125
|
}
|
|
127
126
|
|
|
128
127
|
function _setPrototypeOf(o, p) {
|
|
@@ -134,13 +133,13 @@
|
|
|
134
133
|
return _setPrototypeOf(o, p);
|
|
135
134
|
}
|
|
136
135
|
|
|
137
|
-
function
|
|
136
|
+
function _isNativeReflectConstruct() {
|
|
138
137
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
139
138
|
if (Reflect.construct.sham) return false;
|
|
140
139
|
if (typeof Proxy === "function") return true;
|
|
141
140
|
|
|
142
141
|
try {
|
|
143
|
-
|
|
142
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
144
143
|
return true;
|
|
145
144
|
} catch (e) {
|
|
146
145
|
return false;
|
|
@@ -148,7 +147,7 @@
|
|
|
148
147
|
}
|
|
149
148
|
|
|
150
149
|
function _construct(Parent, args, Class) {
|
|
151
|
-
if (
|
|
150
|
+
if (_isNativeReflectConstruct()) {
|
|
152
151
|
_construct = Reflect.construct;
|
|
153
152
|
} else {
|
|
154
153
|
_construct = function _construct(Parent, args, Class) {
|
|
@@ -190,8 +189,8 @@
|
|
|
190
189
|
|
|
191
190
|
return $.uid(mask, map);
|
|
192
191
|
},
|
|
193
|
-
mdPreloaderContent: "\n <span class=\"preloader-inner\">\n
|
|
194
|
-
iosPreloaderContent: ("\n <span class=\"preloader-inner\">\n
|
|
192
|
+
mdPreloaderContent: "\n <span class=\"preloader-inner\">\n\t\t\t<svg viewBox=\"0 0 36 36\">\n\t\t\t\t<circle cx=\"18\" cy=\"18\" r=\"16\"></circle>\n\t\t\t</svg>\n </span>\n ".trim(),
|
|
193
|
+
iosPreloaderContent: ("\n <span class=\"preloader-inner\">\n\t\t\t" + [0, 1, 2, 3, 4, 5, 6, 7].map(function () {
|
|
195
194
|
return '<span class="preloader-inner-line"></span>';
|
|
196
195
|
}).join('') + "\n </span>\n ").trim(),
|
|
197
196
|
auroraPreloaderContent: "\n <span class=\"preloader-inner\">\n <span class=\"preloader-inner-circle\"></span>\n </span>\n ",
|
|
@@ -318,6 +317,22 @@
|
|
|
318
317
|
args.splice(0, 1);
|
|
319
318
|
return (_$2 = $).assign.apply(_$2, [to].concat(args));
|
|
320
319
|
},
|
|
320
|
+
// ���������ʵ�������������ԡ���������
|
|
321
|
+
bindMethods: function bindMethods(instance, obj) {
|
|
322
|
+
var _this = this;
|
|
323
|
+
|
|
324
|
+
Object.keys(obj).forEach(function (key) {
|
|
325
|
+
if (_this.isObject(obj[key])) {
|
|
326
|
+
Object.keys(obj[key]).forEach(function (subKey) {
|
|
327
|
+
if (typeof obj[key][subKey] === 'function') {
|
|
328
|
+
obj[key][subKey] = obj[key][subKey].bind(instance);
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
instance[key] = obj[key];
|
|
334
|
+
});
|
|
335
|
+
},
|
|
321
336
|
colorHexToRgb: function colorHexToRgb(hex) {
|
|
322
337
|
var h = hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) {
|
|
323
338
|
return r + r + g + g + b + b;
|
|
@@ -433,9 +448,7 @@
|
|
|
433
448
|
* 需要支持事件的对象,可以从这个类继承,则类实例具备事件功能。
|
|
434
449
|
* Fork from Framework7,
|
|
435
450
|
*/
|
|
436
|
-
var Event =
|
|
437
|
-
/*#__PURE__*/
|
|
438
|
-
function () {
|
|
451
|
+
var Event = /*#__PURE__*/function () {
|
|
439
452
|
function Event(params, parents) {
|
|
440
453
|
if (params === void 0) {
|
|
441
454
|
params = {};
|
|
@@ -564,9 +577,7 @@
|
|
|
564
577
|
return Event;
|
|
565
578
|
}();
|
|
566
579
|
|
|
567
|
-
var Module =
|
|
568
|
-
/*#__PURE__*/
|
|
569
|
-
function (_Event) {
|
|
580
|
+
var Module = /*#__PURE__*/function (_Event) {
|
|
570
581
|
_inheritsLoose(Module, _Event);
|
|
571
582
|
|
|
572
583
|
function Module(params, parents) {
|
|
@@ -610,7 +621,7 @@
|
|
|
610
621
|
});
|
|
611
622
|
}
|
|
612
623
|
/**
|
|
613
|
-
*
|
|
624
|
+
* 将扩展模块的相关方法、事件加载到类实例
|
|
614
625
|
* @param {*} moduleName 扩展模块名称
|
|
615
626
|
* @param {*} moduleParams
|
|
616
627
|
*/
|
|
@@ -641,7 +652,7 @@
|
|
|
641
652
|
instance[modulePropName] = moduleProp;
|
|
642
653
|
}
|
|
643
654
|
});
|
|
644
|
-
} // 将扩展模块中的on
|
|
655
|
+
} // 将扩展模块中的on加载到实例的事件侦听中,比如 init 在实例初始化时被调用
|
|
645
656
|
|
|
646
657
|
|
|
647
658
|
if (module.on && instance.on) {
|
|
@@ -661,7 +672,7 @@
|
|
|
661
672
|
instance.vnodeHooks[hookName][vnodeId].push(handler.bind(instance));
|
|
662
673
|
});
|
|
663
674
|
});
|
|
664
|
-
} //
|
|
675
|
+
} // 执行模块的create方法,模块实例化回调,Module create callback
|
|
665
676
|
|
|
666
677
|
|
|
667
678
|
if (module.create) {
|
|
@@ -669,7 +680,7 @@
|
|
|
669
680
|
}
|
|
670
681
|
}
|
|
671
682
|
/**
|
|
672
|
-
*
|
|
683
|
+
* 实例创建初始化时,执行扩展模块中定义的相关回调
|
|
673
684
|
* @param {*} modulesParams
|
|
674
685
|
*/
|
|
675
686
|
;
|
|
@@ -688,7 +699,7 @@
|
|
|
688
699
|
};
|
|
689
700
|
|
|
690
701
|
/**
|
|
691
|
-
*
|
|
702
|
+
* 将模块类装配到指定类的modules属性,用于扩展类
|
|
692
703
|
* @param {*} module 模块类
|
|
693
704
|
* @param {...any} params 参数
|
|
694
705
|
*/
|
|
@@ -770,7 +781,7 @@
|
|
|
770
781
|
|
|
771
782
|
var _parameters = parameters,
|
|
772
783
|
defaultSelector = _parameters.defaultSelector,
|
|
773
|
-
|
|
784
|
+
Constructor = _parameters.constructor,
|
|
774
785
|
domProp = _parameters.domProp,
|
|
775
786
|
app = _parameters.app,
|
|
776
787
|
addMethods = _parameters.addMethods;
|
|
@@ -780,15 +791,15 @@
|
|
|
780
791
|
args[_key] = arguments[_key];
|
|
781
792
|
}
|
|
782
793
|
|
|
783
|
-
if (app) return _construct(
|
|
784
|
-
return _construct(
|
|
794
|
+
if (app) return _construct(Constructor, [app].concat(args));
|
|
795
|
+
return _construct(Constructor, args);
|
|
785
796
|
},
|
|
786
797
|
get: function get(el) {
|
|
787
798
|
if (el === void 0) {
|
|
788
799
|
el = defaultSelector;
|
|
789
800
|
}
|
|
790
801
|
|
|
791
|
-
if (el instanceof
|
|
802
|
+
if (el instanceof Constructor) return el;
|
|
792
803
|
var $el = $(el);
|
|
793
804
|
if ($el.length === 0) return undefined;
|
|
794
805
|
return $el[0][domProp];
|
|
@@ -1117,7 +1128,7 @@
|
|
|
1117
1128
|
var $clickedEl = $(e.target);
|
|
1118
1129
|
var $clickedLinkEl = $clickedEl.closest('a');
|
|
1119
1130
|
var isLink = $clickedLinkEl.length > 0;
|
|
1120
|
-
|
|
1131
|
+
isLink && $clickedLinkEl.attr('href'); // call Modules Clicks
|
|
1121
1132
|
|
|
1122
1133
|
Object.keys(app.modules).forEach(function (moduleName) {
|
|
1123
1134
|
var moduleClicks = app.modules[moduleName].clicks;
|
|
@@ -1243,44 +1254,35 @@
|
|
|
1243
1254
|
}
|
|
1244
1255
|
};
|
|
1245
1256
|
|
|
1246
|
-
var Support = $.support;
|
|
1247
|
-
var Device = $.device;
|
|
1257
|
+
var Support$1 = $.support;
|
|
1258
|
+
var Device$1 = $.device;
|
|
1259
|
+
/**
|
|
1260
|
+
* 应用类,每个wia应用从该类继承,由 首页加载创建或者路由创建
|
|
1261
|
+
*/
|
|
1248
1262
|
|
|
1249
|
-
var App =
|
|
1250
|
-
/*#__PURE__*/
|
|
1251
|
-
function (_Module) {
|
|
1263
|
+
var App = /*#__PURE__*/function (_Module) {
|
|
1252
1264
|
_inheritsLoose(App, _Module);
|
|
1253
1265
|
|
|
1254
|
-
function App(
|
|
1266
|
+
function App(opt) {
|
|
1255
1267
|
var _this;
|
|
1256
1268
|
|
|
1257
|
-
_this = _Module.call(this,
|
|
1258
|
-
|
|
1259
|
-
if (App.instance) {
|
|
1260
|
-
throw new Error("App is already initialized and can't be initialized more than once");
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
|
-
var passedParams = $.extend({}, params); // App Instance
|
|
1269
|
+
_this = _Module.call(this, opt) || this;
|
|
1270
|
+
var passedParams = $.extend({}, opt);
|
|
1264
1271
|
|
|
1265
1272
|
var app = _assertThisInitialized(_this);
|
|
1266
1273
|
|
|
1267
|
-
app.device = Device;
|
|
1268
|
-
app.support = Support;
|
|
1269
|
-
App.instance = app;
|
|
1270
|
-
$.app = app;
|
|
1271
|
-
$.App = App; // Default
|
|
1274
|
+
app.device = Device$1;
|
|
1275
|
+
app.support = Support$1; // Default
|
|
1272
1276
|
|
|
1273
|
-
var
|
|
1274
|
-
version: '
|
|
1275
|
-
id: 'pub.wia.testapp',
|
|
1277
|
+
var def = {
|
|
1278
|
+
version: '0.0.1',
|
|
1276
1279
|
root: 'body',
|
|
1277
1280
|
theme: 'auto',
|
|
1278
1281
|
language: window.navigator.language,
|
|
1279
1282
|
routes: [],
|
|
1280
|
-
name: 'wia',
|
|
1281
1283
|
lazyModulesPath: null,
|
|
1282
1284
|
initOnDeviceReady: true,
|
|
1283
|
-
init: true,
|
|
1285
|
+
// init: true, // 路由加载时,为 false,,为true
|
|
1284
1286
|
autoDarkTheme: false,
|
|
1285
1287
|
iosTranslucentBars: true,
|
|
1286
1288
|
iosTranslucentModals: true,
|
|
@@ -1288,15 +1290,14 @@
|
|
|
1288
1290
|
componentUrl: undefined
|
|
1289
1291
|
}; // Extend defaults with modules params
|
|
1290
1292
|
|
|
1291
|
-
app.useModulesParams(
|
|
1293
|
+
app.useModulesParams(def); // Extend defaults with passed params
|
|
1292
1294
|
|
|
1293
|
-
app.params = $.extend(
|
|
1295
|
+
app.params = $.extend(def, opt);
|
|
1294
1296
|
var $rootEl = $(app.params.root);
|
|
1295
1297
|
$.extend(app, {
|
|
1296
|
-
|
|
1297
|
-
id: app.params.id,
|
|
1298
|
-
// App Name
|
|
1298
|
+
owner: app.params.owner,
|
|
1299
1299
|
name: app.params.name,
|
|
1300
|
+
id: app.params.owner + "." + app.params.name,
|
|
1300
1301
|
// App version
|
|
1301
1302
|
version: app.params.version,
|
|
1302
1303
|
// Routes
|
|
@@ -1305,6 +1306,7 @@
|
|
|
1305
1306
|
language: app.params.language,
|
|
1306
1307
|
// Root
|
|
1307
1308
|
root: $rootEl,
|
|
1309
|
+
$el: $rootEl,
|
|
1308
1310
|
cfg: app.params.cfg,
|
|
1309
1311
|
// app config
|
|
1310
1312
|
api: app.params.api,
|
|
@@ -1314,8 +1316,8 @@
|
|
|
1314
1316
|
// Theme
|
|
1315
1317
|
theme: function getTheme() {
|
|
1316
1318
|
if (app.params.theme === 'auto') {
|
|
1317
|
-
if (Device.ios) return 'ios';
|
|
1318
|
-
if (Device.desktop
|
|
1319
|
+
if (Device$1.ios) return 'ios';
|
|
1320
|
+
if (Device$1.desktop) return 'aurora';
|
|
1319
1321
|
return 'md';
|
|
1320
1322
|
}
|
|
1321
1323
|
|
|
@@ -1330,16 +1332,13 @@
|
|
|
1330
1332
|
app.root[0].wia = app;
|
|
1331
1333
|
}
|
|
1332
1334
|
|
|
1333
|
-
if (Device.ios && Device.webView) {
|
|
1334
|
-
// Strange hack required for iOS 8 webview to work on inputs
|
|
1335
|
-
window.addEventListener('touchstart', function () {});
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
1335
|
app.touchEvents = {
|
|
1339
|
-
start: Support.touch ? 'touchstart' : Support.pointerEvents ? 'pointerdown' : 'mousedown',
|
|
1340
|
-
move: Support.touch ? 'touchmove' : Support.pointerEvents ? 'pointermove' : 'mousemove',
|
|
1341
|
-
end: Support.touch ? 'touchend' : Support.pointerEvents ? 'pointerup' : 'mouseup'
|
|
1342
|
-
}; // 加载use
|
|
1336
|
+
start: Support$1.touch ? 'touchstart' : Support$1.pointerEvents ? 'pointerdown' : 'mousedown',
|
|
1337
|
+
move: Support$1.touch ? 'touchmove' : Support$1.pointerEvents ? 'pointermove' : 'mousemove',
|
|
1338
|
+
end: Support$1.touch ? 'touchend' : Support$1.pointerEvents ? 'pointerup' : 'mouseup'
|
|
1339
|
+
}; // 加载use插入的模块类,每个模块作为app的一个属性,合并到实例。
|
|
1340
|
+
// 模块包括相关属性及方法(如:create、get、destroy)
|
|
1341
|
+
// 调用每个模块的 create 方法
|
|
1343
1342
|
|
|
1344
1343
|
app.useModules(); // 初始化数据,Init Data & Methods
|
|
1345
1344
|
|
|
@@ -1373,39 +1372,46 @@
|
|
|
1373
1372
|
|
|
1374
1373
|
|
|
1375
1374
|
function init() {
|
|
1376
|
-
if (Device.cordova && app.params.initOnDeviceReady) {
|
|
1375
|
+
if (Device$1.cordova && app.params.initOnDeviceReady) {
|
|
1377
1376
|
$(document).on('deviceready', function () {
|
|
1378
1377
|
app.init();
|
|
1379
1378
|
});
|
|
1380
1379
|
} else {
|
|
1381
1380
|
app.init();
|
|
1382
1381
|
}
|
|
1383
|
-
}
|
|
1382
|
+
} // 应用初始化,路由跳转时不执行初始化
|
|
1384
1383
|
|
|
1385
|
-
if (app.params.component || app.params.componentUrl) {
|
|
1386
|
-
app.router.componentLoader(app.params.component, app.params.componentUrl, {
|
|
1387
|
-
componentOptions: {
|
|
1388
|
-
el: app.root[0]
|
|
1389
|
-
}
|
|
1390
|
-
}, function (el) {
|
|
1391
|
-
app.root = $(el);
|
|
1392
|
-
app.root[0].f7 = app;
|
|
1393
|
-
app.rootComponent = el.f7Component;
|
|
1394
|
-
if (app.params.init) init();
|
|
1395
|
-
});
|
|
1396
|
-
} else if (app.params.init) {
|
|
1397
|
-
init();
|
|
1398
|
-
} // Return app instance
|
|
1399
1384
|
|
|
1385
|
+
if (app.params.init) init(); // Return app instance
|
|
1400
1386
|
|
|
1401
1387
|
return app || _assertThisInitialized(_this);
|
|
1388
|
+
} // 首次加载事件,全局只触发一次
|
|
1389
|
+
|
|
1390
|
+
|
|
1391
|
+
var _proto = App.prototype;
|
|
1392
|
+
|
|
1393
|
+
_proto.load = function load(param) {
|
|
1394
|
+
this.emit('local::load appLoad', param);
|
|
1395
|
+
} // 从后台切换到前台显示事件
|
|
1396
|
+
;
|
|
1397
|
+
|
|
1398
|
+
_proto.show = function show(url, data) {
|
|
1399
|
+
this.emit('local::show appShow', url, data);
|
|
1400
|
+
} // 从前台显示切换到后台事件
|
|
1401
|
+
;
|
|
1402
|
+
|
|
1403
|
+
_proto.hide = function hide() {
|
|
1404
|
+
this.emit('local::hide appHide');
|
|
1405
|
+
} // 卸载应用事件
|
|
1406
|
+
;
|
|
1407
|
+
|
|
1408
|
+
_proto.unload = function unload() {
|
|
1409
|
+
this.emit('local::unload appUnload');
|
|
1402
1410
|
}
|
|
1403
1411
|
/**
|
|
1404
1412
|
* 初始化数据
|
|
1405
1413
|
*/
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
var _proto = App.prototype;
|
|
1414
|
+
;
|
|
1409
1415
|
|
|
1410
1416
|
_proto.initData = function initData() {
|
|
1411
1417
|
var app = this; // Data
|
|
@@ -1454,12 +1460,19 @@
|
|
|
1454
1460
|
var app = this;
|
|
1455
1461
|
if (app.mq.dark) app.mq.dark.removeListener(app.colorSchemeListener);
|
|
1456
1462
|
if (app.mq.light) app.mq.light.removeListener(app.colorSchemeListener);
|
|
1457
|
-
} //
|
|
1463
|
+
} // 初始化,包括控制 html 样式,wia app 启动时需要执行,切换app时,不需要
|
|
1458
1464
|
;
|
|
1459
1465
|
|
|
1460
1466
|
_proto.init = function init() {
|
|
1461
1467
|
var app = this;
|
|
1462
1468
|
if (app.initialized) return app;
|
|
1469
|
+
$.App = App;
|
|
1470
|
+
|
|
1471
|
+
if (Device$1.ios && Device$1.webView) {
|
|
1472
|
+
// Strange hack required for iOS 8 webview to work on inputs
|
|
1473
|
+
window.addEventListener('touchstart', function () {});
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1463
1476
|
app.root.addClass('framework7-initializing'); // RTL attr
|
|
1464
1477
|
|
|
1465
1478
|
if (app.rtl) {
|
|
@@ -1487,11 +1500,11 @@
|
|
|
1487
1500
|
|
|
1488
1501
|
$('html').removeClass('ios md aurora').addClass(app.theme); // iOS Translucent
|
|
1489
1502
|
|
|
1490
|
-
if (app.params.iosTranslucentBars && app.theme === 'ios' && Device.ios) {
|
|
1503
|
+
if (app.params.iosTranslucentBars && app.theme === 'ios' && Device$1.ios) {
|
|
1491
1504
|
$('html').addClass('ios-translucent-bars');
|
|
1492
1505
|
}
|
|
1493
1506
|
|
|
1494
|
-
if (app.params.iosTranslucentModals && app.theme === 'ios' && Device.ios) {
|
|
1507
|
+
if (app.params.iosTranslucentModals && app.theme === 'ios' && Device$1.ios) {
|
|
1495
1508
|
$('html').addClass('ios-translucent-modals');
|
|
1496
1509
|
} // Init class
|
|
1497
1510
|
|
|
@@ -1501,7 +1514,8 @@
|
|
|
1501
1514
|
});
|
|
1502
1515
|
initStyle(); // Emit, init other modules
|
|
1503
1516
|
|
|
1504
|
-
app.initialized = true;
|
|
1517
|
+
app.initialized = true; // 发起init 事件,模块 on 里面有 init方法的会被触发
|
|
1518
|
+
|
|
1505
1519
|
app.emit('init');
|
|
1506
1520
|
return app;
|
|
1507
1521
|
} // eslint-disable-next-line
|
|
@@ -1560,53 +1574,56 @@
|
|
|
1560
1574
|
*/
|
|
1561
1575
|
|
|
1562
1576
|
|
|
1577
|
+
App.apps = {};
|
|
1578
|
+
|
|
1563
1579
|
function initStyle() {
|
|
1564
1580
|
var classNames = [];
|
|
1565
1581
|
var html = document.querySelector('html');
|
|
1566
1582
|
var metaStatusbar = document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');
|
|
1567
1583
|
if (!html) return;
|
|
1568
1584
|
|
|
1569
|
-
if (Device.standalone && Device.ios && metaStatusbar && metaStatusbar.content === 'black-translucent') {
|
|
1585
|
+
if (Device$1.standalone && Device$1.ios && metaStatusbar && metaStatusbar.content === 'black-translucent') {
|
|
1570
1586
|
classNames.push('device-full-viewport');
|
|
1571
1587
|
} // Pixel Ratio
|
|
1572
1588
|
|
|
1573
1589
|
|
|
1574
|
-
classNames.push("device-pixel-ratio-" + Math.floor(Device.pixelRatio)); // OS classes
|
|
1590
|
+
classNames.push("device-pixel-ratio-" + Math.floor(Device$1.pixelRatio)); // OS classes
|
|
1575
1591
|
|
|
1576
|
-
if (Device.os && !Device.desktop) {
|
|
1577
|
-
classNames.push("device-" + Device.os);
|
|
1578
|
-
} else if (Device.desktop) {
|
|
1592
|
+
if (Device$1.os && !Device$1.desktop) {
|
|
1593
|
+
classNames.push("device-" + Device$1.os);
|
|
1594
|
+
} else if (Device$1.desktop) {
|
|
1579
1595
|
classNames.push('device-desktop');
|
|
1580
1596
|
|
|
1581
|
-
if (Device.os) {
|
|
1582
|
-
classNames.push("device-" + Device.os);
|
|
1597
|
+
if (Device$1.os) {
|
|
1598
|
+
classNames.push("device-" + Device$1.os);
|
|
1583
1599
|
}
|
|
1584
1600
|
}
|
|
1585
1601
|
|
|
1586
|
-
if (Device.cordova || Device.phonegap) {
|
|
1602
|
+
if (Device$1.cordova || Device$1.phonegap) {
|
|
1587
1603
|
classNames.push('device-cordova');
|
|
1588
1604
|
} // Add html classes
|
|
1589
1605
|
|
|
1590
1606
|
|
|
1591
1607
|
classNames.forEach(function (className) {
|
|
1592
|
-
html.classList.add(className);
|
|
1608
|
+
html.classList.add(className); // console.log({className});
|
|
1593
1609
|
});
|
|
1594
|
-
}
|
|
1610
|
+
} // App 类 静态方法、属性
|
|
1611
|
+
|
|
1595
1612
|
|
|
1596
1613
|
App.ModalMethods = Modals;
|
|
1597
1614
|
App.ConstructorMethods = Constructors; // 动态加载模块(base里面已经内置动态加载,这个方法应该用不上)
|
|
1598
1615
|
|
|
1599
1616
|
App.loadModule = loadModule;
|
|
1600
1617
|
|
|
1601
|
-
App.loadModules = function
|
|
1618
|
+
App.loadModules = function (modules) {
|
|
1602
1619
|
return Promise.all(modules.map(function (module) {
|
|
1603
1620
|
return App.loadModule(module);
|
|
1604
1621
|
}));
|
|
1605
1622
|
}; // app 加载到 app实例的一些扩展模块
|
|
1606
1623
|
|
|
1607
1624
|
|
|
1608
|
-
App.support = Support;
|
|
1609
|
-
App.device = Device;
|
|
1625
|
+
App.support = Support$1;
|
|
1626
|
+
App.device = Device$1;
|
|
1610
1627
|
App.utils = Utils; // 添加应用缺省模块
|
|
1611
1628
|
|
|
1612
1629
|
App.use([Resize, // 控制屏幕大小
|
|
@@ -1666,9 +1683,7 @@
|
|
|
1666
1683
|
*/
|
|
1667
1684
|
|
|
1668
1685
|
|
|
1669
|
-
var Lazy =
|
|
1670
|
-
/*#__PURE__*/
|
|
1671
|
-
function () {
|
|
1686
|
+
var Lazy = /*#__PURE__*/function () {
|
|
1672
1687
|
// 实例属性
|
|
1673
1688
|
function Lazy(opt) {
|
|
1674
1689
|
_opt = $.assign({}, _opts, opt);
|
|
@@ -1827,9 +1842,7 @@
|
|
|
1827
1842
|
return this;
|
|
1828
1843
|
}
|
|
1829
1844
|
|
|
1830
|
-
var Page =
|
|
1831
|
-
/*#__PURE__*/
|
|
1832
|
-
function (_Event) {
|
|
1845
|
+
var Page = /*#__PURE__*/function (_Event) {
|
|
1833
1846
|
_inheritsLoose(Page, _Event);
|
|
1834
1847
|
|
|
1835
1848
|
function Page(app, name, title, style) {
|
|
@@ -1845,7 +1858,11 @@
|
|
|
1845
1858
|
_this.style = style || "./page/" + name + ".css";
|
|
1846
1859
|
_this.path = "" + name; // url 路径,不使用正则,直接查找
|
|
1847
1860
|
|
|
1848
|
-
_this.view = null; // 页面的div
|
|
1861
|
+
_this.view = null; // 页面的div层$Dom对象,router创建实例时赋值
|
|
1862
|
+
|
|
1863
|
+
_this.el = null; // $dom
|
|
1864
|
+
|
|
1865
|
+
_this.$el = null; // $dom
|
|
1849
1866
|
|
|
1850
1867
|
_this.html = ''; // 页面html文本,router创建实例时赋值
|
|
1851
1868
|
|
|
@@ -1885,15 +1902,43 @@
|
|
|
1885
1902
|
// $.assign(this, {page, param, back});
|
|
1886
1903
|
// $.assign(this.data, param);
|
|
1887
1904
|
// 隐藏所有模板
|
|
1905
|
+
this.init();
|
|
1888
1906
|
this.emit('local::ready pageReady', view, param, back);
|
|
1889
|
-
|
|
1907
|
+
}
|
|
1908
|
+
/**
|
|
1909
|
+
* 对页面进行初始化处理,或页面内容动态变更时,对局部页面容器进行初始化
|
|
1910
|
+
* 具备name属性的dom节点直接赋值给页面view
|
|
1911
|
+
* 只挂载一个,多个同名name,最后一个起作用,因此一个页面内,name不要重复
|
|
1912
|
+
* 同节点多次调用不覆盖,同名不同dom节点,覆盖
|
|
1913
|
+
* 覆盖后,原直接节点属性的 bind 会失效,需真的新的$dom重新bind
|
|
1914
|
+
* @param {*} v dom 容器,默认为页面实例的view
|
|
1915
|
+
*/
|
|
1916
|
+
;
|
|
1917
|
+
|
|
1918
|
+
_proto.init = function init(v) {
|
|
1919
|
+
var view = this.view;
|
|
1920
|
+
v = v ? $(v) : view; // 页面上带name属性节点,直接作为page.view的属性,方便页面代码直接调用
|
|
1921
|
+
|
|
1922
|
+
var ns = v.qus('[name]');
|
|
1923
|
+
ns === null || ns === void 0 ? void 0 : ns.forEach(function (n) {
|
|
1924
|
+
var $n = $(n);
|
|
1925
|
+
var name = $n.attr('name');
|
|
1926
|
+
if (!view[name] || view[name].dom !== n) view[name] = $n;
|
|
1927
|
+
}); // 隐藏所有模板
|
|
1928
|
+
|
|
1929
|
+
v.qus('[name$=-tp]').hide(); // 防止空链接,刷新页面
|
|
1930
|
+
|
|
1931
|
+
v.qus('a[href=""]').attr('href', 'javascript:;');
|
|
1890
1932
|
} // 显示已加载的页面
|
|
1891
1933
|
// view:页面Dom层,param:参数
|
|
1892
1934
|
;
|
|
1893
1935
|
|
|
1894
1936
|
_proto.show = function show(view, param) {
|
|
1895
|
-
//
|
|
1896
|
-
view.qus('
|
|
1937
|
+
// 隐藏所有模板
|
|
1938
|
+
view.qus('[name$=-tp]').hide(); // 防止空链接,刷新页面
|
|
1939
|
+
|
|
1940
|
+
view.qus('a[href=""]').attr('href', 'javascript:;'); // this.init();
|
|
1941
|
+
|
|
1897
1942
|
if (this.reset) this.reset();
|
|
1898
1943
|
this.emit('local::show pageShow', view, param);
|
|
1899
1944
|
} // 回退显示已加载的页面
|
|
@@ -1901,7 +1946,9 @@
|
|
|
1901
1946
|
;
|
|
1902
1947
|
|
|
1903
1948
|
_proto.back = function back(view, param) {
|
|
1904
|
-
//
|
|
1949
|
+
// 隐藏所有模板
|
|
1950
|
+
view.qus('[name$=-tp]').hide(); // 防止空链接,刷新页面
|
|
1951
|
+
|
|
1905
1952
|
view.qus('a[href=""]').attr('href', 'javascript:;');
|
|
1906
1953
|
this.emit('local::back pageBack', view, param);
|
|
1907
1954
|
};
|
|
@@ -1922,9 +1969,7 @@
|
|
|
1922
1969
|
dialog.open();
|
|
1923
1970
|
}
|
|
1924
1971
|
|
|
1925
|
-
var Modal =
|
|
1926
|
-
/*#__PURE__*/
|
|
1927
|
-
function (_Event) {
|
|
1972
|
+
var Modal = /*#__PURE__*/function (_Event) {
|
|
1928
1973
|
_inheritsLoose(Modal, _Event);
|
|
1929
1974
|
|
|
1930
1975
|
function Modal(app, params) {
|
|
@@ -2157,15 +2202,49 @@
|
|
|
2157
2202
|
return Modal;
|
|
2158
2203
|
}(Event);
|
|
2159
2204
|
|
|
2205
|
+
// replace react, use by @babel/plugin-transform-react-jsx
|
|
2206
|
+
|
|
2207
|
+
/* eslint-disable prefer-rest-params */
|
|
2208
|
+
function jsx(tag, props) {
|
|
2209
|
+
var attrs = props || {};
|
|
2210
|
+
|
|
2211
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
2212
|
+
args[_key - 2] = arguments[_key];
|
|
2213
|
+
}
|
|
2214
|
+
|
|
2215
|
+
var children = args || [];
|
|
2216
|
+
var attrsString = Object.keys(attrs).map(function (attr) {
|
|
2217
|
+
if (attr[0] === '_') {
|
|
2218
|
+
if (attrs[attr]) return attr.replace('_', '');
|
|
2219
|
+
return '';
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
return attr + "=\"" + attrs[attr] + "\"";
|
|
2223
|
+
}).filter(function (attr) {
|
|
2224
|
+
return !!attr;
|
|
2225
|
+
}).join(' ');
|
|
2226
|
+
|
|
2227
|
+
if (['path', 'img', 'circle', 'polygon', 'line', 'input'].indexOf(tag) >= 0) {
|
|
2228
|
+
return ("<" + tag + " " + attrsString + " />").trim();
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
var childrenContent = children.filter(function (c) {
|
|
2232
|
+
return !!c;
|
|
2233
|
+
}).map(function (c) {
|
|
2234
|
+
return Array.isArray(c) ? c.join('') : c;
|
|
2235
|
+
}).join('');
|
|
2236
|
+
return ("<" + tag + " " + attrsString + ">" + childrenContent + "</" + tag + ">").trim();
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2160
2239
|
// export {default as Device} from './device';
|
|
2161
2240
|
|
|
2162
|
-
var Support
|
|
2163
|
-
var Device
|
|
2241
|
+
var Support = $.support;
|
|
2242
|
+
var Device = $.device;
|
|
2164
2243
|
|
|
2165
2244
|
exports.Ajax = Ajax;
|
|
2166
2245
|
exports.App = App;
|
|
2167
2246
|
exports.Constructors = Constructors;
|
|
2168
|
-
exports.Device = Device
|
|
2247
|
+
exports.Device = Device;
|
|
2169
2248
|
exports.Event = Event;
|
|
2170
2249
|
exports.Lazy = Lazy;
|
|
2171
2250
|
exports.Modal = Modal;
|
|
@@ -2174,8 +2253,9 @@
|
|
|
2174
2253
|
exports.Page = Page;
|
|
2175
2254
|
exports.Resize = Resize;
|
|
2176
2255
|
exports.SW = SW$1;
|
|
2177
|
-
exports.Support = Support
|
|
2256
|
+
exports.Support = Support;
|
|
2178
2257
|
exports.Utils = Utils;
|
|
2258
|
+
exports.jsx = jsx;
|
|
2179
2259
|
exports.loadModule = loadModule;
|
|
2180
2260
|
|
|
2181
2261
|
Object.defineProperty(exports, '__esModule', { value: true });
|