,不支持其它组件或自定义组件,否则会引发在不同平台的渲染差异。');
+ if (this.$slots.default) {
+ this.$slots.default.forEach(function (vnode) {
+ if (vnode.componentOptions && vnode.componentOptions.tag === 'v-uni-movable-view') {
+ items.push(vnode);
}
+ });
+ }
- nodeList.push(vnode);
- }
+ this.items = items;
+ var $listeners = Object.assign({}, this.$listeners);
+ var events = ['touchstart', 'touchmove', 'touchend'];
+ events.forEach(function (event) {
+ var existing = $listeners[event];
+
+ var ours = _this["_".concat(event)];
+
+ $listeners[event] = existing ? [].concat(existing, ours) : ours;
});
- return createElement('uni-text', {
- on: this.$listeners,
- attrs: {
- selectable: !!this.selectable
+ return createElement('uni-movable-area', {
+ on: $listeners
+ }, [createElement('v-uni-resize-sensor', {
+ on: {
+ resize: this._resize
}
- }, [createElement('span', {}, nodeList)]);
+ })].concat(items));
}
});
-// CONCATENATED MODULE: ./src/core/view/components/text/index.vue?vue&type=script&lang=js&
- /* harmony default export */ var components_textvue_type_script_lang_js_ = (textvue_type_script_lang_js_);
-// EXTERNAL MODULE: ./src/core/view/components/text/index.vue?vue&type=style&index=0&lang=css&
-var textvue_type_style_index_0_lang_css_ = __webpack_require__(89);
+// CONCATENATED MODULE: ./src/core/view/components/movable-area/index.vue?vue&type=script&lang=js&
+ /* harmony default export */ var components_movable_areavue_type_script_lang_js_ = (movable_areavue_type_script_lang_js_);
+// EXTERNAL MODULE: ./src/core/view/components/movable-area/index.vue?vue&type=style&index=0&lang=css&
+var movable_areavue_type_style_index_0_lang_css_ = __webpack_require__(76);
// EXTERNAL MODULE: ./node_modules/@vue/cli-service/node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(0);
-// CONCATENATED MODULE: ./src/core/view/components/text/index.vue
+// CONCATENATED MODULE: ./src/core/view/components/movable-area/index.vue
var render, staticRenderFns
@@ -21775,7 +22239,7 @@ var render, staticRenderFns
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
- components_textvue_type_script_lang_js_,
+ components_movable_areavue_type_script_lang_js_,
render,
staticRenderFns,
false,
@@ -21787,11 +22251,11 @@ var component = Object(componentNormalizer["a" /* default */])(
/* hot reload */
if (false) { var api; }
-component.options.__file = "src/core/view/components/text/index.vue"
-/* harmony default export */ var components_text = __webpack_exports__["default"] = (component.exports);
+component.options.__file = "src/core/view/components/movable-area/index.vue"
+/* harmony default export */ var movable_area = __webpack_exports__["default"] = (component.exports);
/***/ }),
-/* 119 */
+/* 122 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
@@ -21869,7 +22333,7 @@ __webpack_require__.r(__webpack_exports__);
// CONCATENATED MODULE: ./src/core/view/components/resize-sensor/index.vue?vue&type=script&lang=js&
/* harmony default export */ var components_resize_sensorvue_type_script_lang_js_ = (resize_sensorvue_type_script_lang_js_);
// EXTERNAL MODULE: ./src/core/view/components/resize-sensor/index.vue?vue&type=style&index=0&lang=css&
-var resize_sensorvue_type_style_index_0_lang_css_ = __webpack_require__(83);
+var resize_sensorvue_type_style_index_0_lang_css_ = __webpack_require__(84);
// EXTERNAL MODULE: ./node_modules/@vue/cli-service/node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(0);
@@ -21900,152 +22364,142 @@ component.options.__file = "src/core/view/components/resize-sensor/index.vue"
/* harmony default export */ var resize_sensor = __webpack_exports__["default"] = (component.exports);
/***/ }),
-/* 120 */
+/* 123 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
-// CONCATENATED MODULE: ./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader/lib??vue-loader-options!./src/core/view/components/picker-view/index.vue?vue&type=script&lang=js&
-function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
-
-function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
-
-function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
+// EXTERNAL MODULE: ./src/core/view/mixins/index.js + 1 modules
+var mixins = __webpack_require__(1);
-function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
+// CONCATENATED MODULE: ./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader/lib??vue-loader-options!./src/core/view/components/button/index.vue?vue&type=script&lang=js&
-/* harmony default export */ var picker_viewvue_type_script_lang_js_ = ({
- name: 'PickerView',
+/* harmony default export */ var buttonvue_type_script_lang_js_ = ({
+ name: 'Button',
+ mixins: [mixins["b" /* hover */], mixins["a" /* emitter */], mixins["c" /* listeners */]],
props: {
- value: {
- type: Array,
- default: function _default() {
- return [];
- },
- validator: function validator(val) {
- return Array.isArray(val) && val.filter(function (val) {
- return typeof val === 'number';
- }).length === val.length;
- }
- },
- indicatorStyle: {
+ hoverClass: {
type: String,
- default: ''
+ default: 'button-hover'
},
- indicatorClass: {
- type: String,
- default: ''
+ disabled: {
+ type: [Boolean, String],
+ default: false
},
- maskStyle: {
+ id: {
type: String,
default: ''
},
- maskClass: {
+ hoverStopPropagation: {
+ type: Boolean,
+ default: false
+ },
+ hoverStartTime: {
+ type: Number,
+ default: 20
+ },
+ hoverStayTime: {
+ type: Number,
+ default: 70
+ },
+ formType: {
type: String,
- default: ''
+ default: '',
+ validator: function validator(value) {
+ // 只有这几个可取值,其它都是非法的。
+ return ~['', 'submit', 'reset'].indexOf(value);
+ }
}
},
data: function data() {
return {
- valueSync: _toConsumableArray(this.value),
- height: 34,
- items: [],
- changeSource: ''
+ clickFunction: null
};
},
- watch: {
- value: function value(val) {
- var _this = this;
+ methods: {
+ _onClick: function _onClick($event, isLabelClick) {
+ if (this.disabled) {
+ return;
+ }
- this.valueSync.length = val.length;
- val.forEach(function (val, index) {
- if (val !== _this.valueSync[index]) {
- _this.$set(_this.valueSync, index, val);
- }
- });
- },
- valueSync: {
- deep: true,
- handler: function handler(val, oldVal) {
- if (this.changeSource === '') {
- this._valueChanged(val);
- } else {
- this.changeSource = ''; // 避免外部直接对此值进行修改
+ if (isLabelClick) {
+ this.$el.click();
+ } // TODO 通知父表单执行相应的行为
- var value = val.map(function (val) {
- return val;
- });
- this.$emit('update:value', value);
- this.$trigger('change', {}, {
- value: value
- });
+
+ if (this.formType) {
+ this.$dispatch('Form', this.formType === 'submit' ? 'uni-form-submit' : 'uni-form-reset', {
+ type: this.formType
+ });
+ }
+ },
+ _bindObjectListeners: function _bindObjectListeners(data, value) {
+ if (value) {
+ for (var key in value) {
+ var existing = data.on[key];
+ var ours = value[key];
+ data.on[key] = existing ? [].concat(existing, ours) : ours;
}
}
+
+ return data;
}
},
- methods: {
- getItemIndex: function getItemIndex(vnode) {
- return this.items.indexOf(vnode);
- },
- getItemValue: function getItemValue(vm) {
- return this.valueSync[this.getItemIndex(vm.$vnode)] || 0;
- },
- setItemValue: function setItemValue(vm, val) {
- var index = this.getItemIndex(vm.$vnode);
- var oldVal = this.valueSync[index];
+ render: function render(createElement) {
+ var _this = this;
- if (oldVal !== val) {
- this.changeSource = 'touch';
- this.$set(this.valueSync, index, val);
- }
- },
- _valueChanged: function _valueChanged(val) {
- this.items.forEach(function (item, index) {
- item.componentInstance.setCurrent(val[index] || 0);
+ var $listeners = Object.create(null);
+
+ if (this.$listeners) {
+ Object.keys(this.$listeners).forEach(function (e) {
+ if (_this.disabled && (e === 'click' || e === 'tap')) {
+ return;
+ }
+
+ $listeners[e] = _this.$listeners[e];
});
- },
- _resize: function _resize(_ref) {
- var height = _ref.height;
- this.height = height;
}
- },
- render: function render(createElement) {
- var items = [];
- if (this.$slots.default) {
- this.$slots.default.forEach(function (vnode) {
- if (vnode.componentOptions && vnode.componentOptions.tag === 'v-uni-picker-view-column') {
- items.push(vnode);
+ if (this.hoverClass && this.hoverClass !== 'none') {
+ return createElement('uni-button', this._bindObjectListeners({
+ class: [this.hovering ? this.hoverClass : ''],
+ attrs: {
+ 'disabled': this.disabled
+ },
+ on: {
+ touchstart: this._hoverTouchStart,
+ touchend: this._hoverTouchEnd,
+ touchcancel: this._hoverTouchCancel,
+ click: this._onClick
}
- });
+ }, $listeners), this.$slots.default);
+ } else {
+ return createElement('uni-button', this._bindObjectListeners({
+ class: [this.hovering ? this.hoverClass : ''],
+ attrs: {
+ 'disabled': this.disabled
+ },
+ on: {
+ click: this._onClick
+ }
+ }, $listeners), this.$slots.default);
}
-
- this.items = items;
- return createElement('uni-picker-view', {
- on: this.$listeners
- }, [createElement('v-uni-resize-sensor', {
- attrs: {
- initial: true
- },
- on: {
- resize: this._resize
- }
- }), createElement('div', {
- ref: 'wrapper',
- 'class': 'uni-picker-view-wrapper'
- }, items)]);
+ },
+ listeners: {
+ 'label-click': '_onClick',
+ '@label-click': '_onClick'
}
});
-// CONCATENATED MODULE: ./src/core/view/components/picker-view/index.vue?vue&type=script&lang=js&
- /* harmony default export */ var components_picker_viewvue_type_script_lang_js_ = (picker_viewvue_type_script_lang_js_);
-// EXTERNAL MODULE: ./src/core/view/components/picker-view/index.vue?vue&type=style&index=0&lang=css&
-var picker_viewvue_type_style_index_0_lang_css_ = __webpack_require__(79);
+// CONCATENATED MODULE: ./src/core/view/components/button/index.vue?vue&type=script&lang=js&
+ /* harmony default export */ var components_buttonvue_type_script_lang_js_ = (buttonvue_type_script_lang_js_);
+// EXTERNAL MODULE: ./src/core/view/components/button/index.vue?vue&type=style&index=0&lang=css&
+var buttonvue_type_style_index_0_lang_css_ = __webpack_require__(69);
// EXTERNAL MODULE: ./node_modules/@vue/cli-service/node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(0);
-// CONCATENATED MODULE: ./src/core/view/components/picker-view/index.vue
+// CONCATENATED MODULE: ./src/core/view/components/button/index.vue
var render, staticRenderFns
@@ -22055,7 +22509,7 @@ var render, staticRenderFns
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
- components_picker_viewvue_type_script_lang_js_,
+ components_buttonvue_type_script_lang_js_,
render,
staticRenderFns,
false,
@@ -22067,11 +22521,11 @@ var component = Object(componentNormalizer["a" /* default */])(
/* hot reload */
if (false) { var api; }
-component.options.__file = "src/core/view/components/picker-view/index.vue"
-/* harmony default export */ var picker_view = __webpack_exports__["default"] = (component.exports);
+component.options.__file = "src/core/view/components/button/index.vue"
+/* harmony default export */ var components_button = __webpack_exports__["default"] = (component.exports);
/***/ }),
-/* 121 */
+/* 124 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
@@ -22082,7 +22536,7 @@ __webpack_require__.r(__webpack_exports__);
if (typeof window !== 'undefined') {
if (true) {
- __webpack_require__(64)
+ __webpack_require__(65)
}
var i
@@ -22095,7 +22549,7 @@ if (typeof window !== 'undefined') {
/* harmony default export */ var setPublicPath = (null);
// EXTERNAL MODULE: ./lib/app-plus/view.js
-var view = __webpack_require__(52);
+var view = __webpack_require__(53);
// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib-no-default.js
/* concated harmony reexport upx2px */__webpack_require__.d(__webpack_exports__, "upx2px", function() { return view["h" /* upx2px */]; });
@@ -22110,6 +22564,314 @@ var view = __webpack_require__(52);
+/***/ }),
+/* 125 */
+/***/ (function(module, exports, __webpack_require__) {
+
+// extracted by mini-css-extract-plugin
+ if(false) { var cssReload; }
+
+
+/***/ }),
+/* 126 */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+/* harmony import */ var _node_modules_vue_cli_service_node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_vue_cli_service_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_cli_service_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_vue_cli_service_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_cli_service_node_modules_vue_loader_lib_index_js_vue_loader_options_index_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(125);
+/* harmony import */ var _node_modules_vue_cli_service_node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_vue_cli_service_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_cli_service_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_vue_cli_service_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_cli_service_node_modules_vue_loader_lib_index_js_vue_loader_options_index_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_vue_cli_service_node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_vue_cli_service_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_cli_service_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_vue_cli_service_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_cli_service_node_modules_vue_loader_lib_index_js_vue_loader_options_index_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0__);
+/* unused harmony reexport * */
+ /* unused harmony default export */ var _unused_webpack_default_export = (_node_modules_vue_cli_service_node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_vue_cli_service_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_cli_service_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_vue_cli_service_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_cli_service_node_modules_vue_loader_lib_index_js_vue_loader_options_index_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0___default.a);
+
+/***/ }),
+/* 127 */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+
+// CONCATENATED MODULE: ./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"26557f38-vue-loader-template"}!./node_modules/@vue/cli-service/node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader/lib??vue-loader-options!./src/platforms/app-plus/view/components/video/index.vue?vue&type=template&id=0ba2468e&
+var render = function() {
+ var _vm = this
+ var _h = _vm.$createElement
+ var _c = _vm._self._c || _h
+ return _c(
+ "uni-video",
+ _vm._g(_vm._b({}, "uni-video", _vm.attrs, false), _vm.$listeners),
+ [
+ _c("div", { ref: "container", staticClass: "uni-video-container" }),
+ _c("div", { staticClass: "uni-video-slot" }, [_vm._t("default")], 2)
+ ]
+ )
+}
+var staticRenderFns = []
+render._withStripped = true
+
+
+// CONCATENATED MODULE: ./src/platforms/app-plus/view/components/video/index.vue?vue&type=template&id=0ba2468e&
+
+// EXTERNAL MODULE: ./src/core/view/mixins/index.js + 1 modules
+var mixins = __webpack_require__(1);
+
+// CONCATENATED MODULE: ./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader/lib??vue-loader-options!./src/platforms/app-plus/view/components/video/index.vue?vue&type=script&lang=js&
+function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+
+var methods = ['play', 'pause', 'seek', 'sendDanmu', 'playbackRate', 'requestFullScreen', 'exitFullScreen'];
+var events = ['play', 'pause', 'ended', 'timeupdate', 'fullscreenchange', 'waiting', 'error'];
+var _attrs = ['src', 'duration', 'controls', 'danmuList', 'danmuBtn', 'enableDanmu', 'autoplay', 'loop', 'muted', 'objectFit', 'poster', 'direction', 'showProgress', 'initialTime', 'showFullscreenBtn', 'pageGesture', 'enableProgressGesture', 'showPlayBtn', 'showCenterPlayBtn'];
+/* harmony default export */ var videovue_type_script_lang_js_ = ({
+ name: 'Video',
+ mixins: [mixins["d" /* subscriber */], mixins["c" /* listeners */]],
+ props: {
+ id: {
+ type: String,
+ default: ''
+ },
+ src: {
+ type: String,
+ default: ''
+ },
+ duration: {
+ type: [Number, String],
+ default: ''
+ },
+ controls: {
+ type: [Boolean, String],
+ default: true
+ },
+ danmuList: {
+ type: Array,
+ default: function _default() {
+ return [];
+ }
+ },
+ danmuBtn: {
+ type: [Boolean, String],
+ default: false
+ },
+ enableDanmu: {
+ type: [Boolean, String],
+ default: false
+ },
+ autoplay: {
+ type: [Boolean, String],
+ default: false
+ },
+ loop: {
+ type: [Boolean, String],
+ default: false
+ },
+ muted: {
+ type: [Boolean, String],
+ default: false
+ },
+ objectFit: {
+ type: String,
+ default: 'contain'
+ },
+ poster: {
+ type: String,
+ default: ''
+ },
+ direction: {
+ type: [String, Number],
+ default: 360
+ },
+ showProgress: {
+ type: Boolean,
+ default: true
+ },
+ initialTime: {
+ type: [String, Number],
+ default: 0
+ },
+ showFullscreenBtn: {
+ type: [Boolean, String],
+ default: true
+ },
+ pageGesture: {
+ type: [Boolean, String],
+ default: false
+ },
+ enableProgressGesture: {
+ type: [Boolean, String],
+ default: true
+ },
+ showPlayBtn: {
+ type: [Boolean, String],
+ default: true
+ },
+ showCenterPlayBtn: {
+ type: [Boolean, String],
+ default: true
+ }
+ },
+ data: function data() {
+ return {
+ style: {
+ top: '0px',
+ left: '0px',
+ width: '0px',
+ height: '0px',
+ position: 'static'
+ },
+ hidden: false
+ };
+ },
+ computed: {
+ attrs: function attrs() {
+ var _this = this;
+
+ var obj = {};
+
+ _attrs.forEach(function (key) {
+ var val = _this.$props[key];
+ val = key === 'src' ? _this.$getRealPath(val) : val;
+ obj[key.replace(/[A-Z]/g, function (str) {
+ return '-' + str.toLowerCase();
+ })] = val;
+ });
+
+ return obj;
+ }
+ },
+ watch: {
+ hidden: function hidden(val) {
+ this.video && this.video[val ? 'hide' : 'show']();
+ }
+ },
+ listeners: {
+ '@view-update': '_requestUpdate'
+ },
+ mounted: function mounted() {
+ var _this2 = this;
+
+ this._updateStyle();
+
+ var video = this.video = plus.video.createVideoPlayer('video' + Date.now(), Object.assign({}, this.attrs, this.style));
+ plus.webview.currentWebview().append(video);
+
+ if (this.hidden) {
+ video.hide();
+ }
+
+ this.$watch('attrs', function () {
+ _this2.video && _this2.video.setStyles(_this2.attrs);
+ }, {
+ deep: true
+ });
+ this.$watch('style', function () {
+ _this2.video && _this2.video.setStyles(_this2.style);
+ }, {
+ deep: true
+ });
+ events.forEach(function (key) {
+ video.addEventListener(key, function () {
+ var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
+
+ _this2.$trigger(key, {}, data);
+ });
+ });
+ },
+ beforeDestroy: function beforeDestroy() {
+ this.video && this.video.close();
+ delete this.video;
+ },
+ methods: {
+ _handleSubscribe: function _handleSubscribe(_ref) {
+ var type = _ref.type,
+ _ref$data = _ref.data,
+ data = _ref$data === void 0 ? {} : _ref$data;
+
+ if (methods.includes(type)) {
+ if (_typeof(data) === 'object') {
+ switch (type) {
+ case 'seek':
+ data = data.position;
+ break;
+
+ case 'playbackRate':
+ data = data.rate;
+ break;
+ }
+ }
+
+ this.video && this.video[type](data);
+ }
+ },
+ _updateStyle: function _updateStyle() {
+ var _this3 = this;
+
+ var rect = this.$refs.container.getBoundingClientRect();
+ this.hidden = getComputedStyle(this.$el).display === 'none';
+ ['top', 'left', 'width', 'height'].forEach(function (key) {
+ var val = rect[key];
+ val = key === 'top' ? val + (document.documentElement.scrollTop || document.body.scrollTop || 0) : val;
+ _this3.style[key] = val + 'px';
+ });
+ },
+ _requestUpdate: function _requestUpdate() {
+ var _this4 = this;
+
+ if (this._animationFrame) {
+ cancelAnimationFrame(this._animationFrame);
+ }
+
+ if (this.video) {
+ this._animationFrame = requestAnimationFrame(function () {
+ delete _this4._animationFrame;
+
+ _this4._updateStyle();
+ });
+ }
+ }
+ }
+});
+// CONCATENATED MODULE: ./src/platforms/app-plus/view/components/video/index.vue?vue&type=script&lang=js&
+ /* harmony default export */ var components_videovue_type_script_lang_js_ = (videovue_type_script_lang_js_);
+// EXTERNAL MODULE: ./src/platforms/app-plus/view/components/video/index.vue?vue&type=style&index=0&lang=css&
+var videovue_type_style_index_0_lang_css_ = __webpack_require__(126);
+
+// EXTERNAL MODULE: ./node_modules/@vue/cli-service/node_modules/vue-loader/lib/runtime/componentNormalizer.js
+var componentNormalizer = __webpack_require__(0);
+
+// CONCATENATED MODULE: ./src/platforms/app-plus/view/components/video/index.vue
+
+
+
+
+
+
+/* normalize component */
+
+var component = Object(componentNormalizer["a" /* default */])(
+ components_videovue_type_script_lang_js_,
+ render,
+ staticRenderFns,
+ false,
+ null,
+ null,
+ null
+
+)
+
+/* hot reload */
+if (false) { var api; }
+component.options.__file = "src/platforms/app-plus/view/components/video/index.vue"
+/* harmony default export */ var video = __webpack_exports__["default"] = (component.exports);
+
/***/ })
/******/ ]);
});
\ No newline at end of file
diff --git a/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js b/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js
index 311e15e9d84dcccf632eae8837daafba02b3f9e0..bffd4b20cd8bb328d02e12771291763735c3b7a1 100644
--- a/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js
@@ -70,6 +70,17 @@ describe('codegen', () => {
'{{ user.firstName }}',
`with(this){return _c('current-user',{attrs:{"_i":0},scopedSlots:_u([{key:"default",fn:function({ user }){return [_v((_$s(0,'t0',_s(user.firstName))))]}}])})}`
)
+ })
+
+ it('generate keep-alive', () => {
+ assertCodegen(
+ ``,
+ `with(this){return _c('keep-alive',{attrs:{"exclude":"componentWithStatus1","_i":0}},[_c("componentWithStatus",{tag:"component",attrs:{"_i":1}})],1)}`
+ )
+ assertCodegen(
+ ``,
+ `with(this){return _c('keep-alive',{attrs:{"exclude":_$s(0,'a-exclude',componentWithStatus1),"_i":0}},[_c(_$s(1,'is','componentWithStatus'+index),{tag:"component",attrs:{"_i":1}})],1)}`
+ )
})
})
/* eslint-enable quotes */
diff --git a/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js b/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js
index f4ed62645b09dabecbd4bce839ea4f3c2a109c9e..2d801a19f5900b1558598e0d1f52def1d3d0d2e9 100644
--- a/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js
@@ -45,6 +45,16 @@ describe('codegen', () => {
'{{ user.firstName }}',
`with(this){return _c('current-user',{attrs:{"_i":0},scopedSlots:_u([{key:"default",fn:function({ user }){return [_v((_$g(0,'t0')))]}}])})}`
)
+ })
+ it('generate keep-alive', () => {
+ assertCodegen(
+ ``,
+ `with(this){return _c('keep-alive',{attrs:{"exclude":"componentWithStatus1","_i":0}},[_c("componentWithStatus",{tag:"component",attrs:{"_i":1}})],1)}`
+ )
+ assertCodegen(
+ ``,
+ `with(this){return _c('keep-alive',{attrs:{"exclude":_$g(0,'a-exclude'),"_i":0}},[_c(_$g(1,'is'),{tag:"component",attrs:{"_i":1}})],1)}`
+ )
})
})
/* eslint-enable quotes */
diff --git a/packages/uni-template-compiler/__tests__/compiler-app-plus.service.spec.js b/packages/uni-template-compiler/__tests__/compiler-app-plus.service.spec.js
index dbbdabc73e2bba2fc5ed61f0e9404ca3335b69a8..00cfbbeab899ffb7f0cd5c8ec478529df5bf57b9 100644
--- a/packages/uni-template-compiler/__tests__/compiler-app-plus.service.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-app-plus.service.spec.js
@@ -576,7 +576,7 @@ describe('codegen', () => {
)
assertCodegen(
'',
- `with(this){return _c(component1,{tag:"div"})}`
+ `with(this){return _c(_$s(0,'is',component1),{tag:"div"})}`
)
// maybe a component and normalize type should be 1
assertCodegen(
diff --git a/packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js b/packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js
index 2aef257befeaedfe3a050a84e659472b169182af..c2fa0c9343203c78aac4fd2fd44e27e3e2d595b0 100644
--- a/packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js
@@ -576,7 +576,7 @@ describe('codegen', () => {
)
assertCodegen(
'',
- `with(this){return _c(component1,{tag:"v-uni-view",attrs:{"_i":0}})}`
+ `with(this){return _c(_$g(0,'is'),{tag:"v-uni-view",attrs:{"_i":0}})}`
)
// maybe a component and normalize type should be 1
assertCodegen(
diff --git a/packages/uni-template-compiler/__tests__/demo.js b/packages/uni-template-compiler/__tests__/demo.js
index 5f9a46fa8cb6ebb3b5d5619715b99be865cfec87..faf09b1777f45b97858b27a6cf28f2239ea478a5 100644
--- a/packages/uni-template-compiler/__tests__/demo.js
+++ b/packages/uni-template-compiler/__tests__/demo.js
@@ -1,7 +1,7 @@
const compiler = require('../lib')
const res = compiler.compile(
`
-A{{ d | e | f }}B{{text}}C
+
`, {
resourcePath: '/User/fxy/Documents/test.wxml',
isReservedTag: function (tag) {
diff --git a/packages/uni-template-compiler/lib/app/optimizer.js b/packages/uni-template-compiler/lib/app/optimizer.js
index 2ced1db00c9ed07d909eb47bda5c5d1649a0728a..50d5d7d0f7b29db394d1f52e4dbc311ea77fa3fd 100644
--- a/packages/uni-template-compiler/lib/app/optimizer.js
+++ b/packages/uni-template-compiler/lib/app/optimizer.js
@@ -14,7 +14,11 @@ function no (a, b, c) {
}
function isBuiltInTag (tag) {
- if (tag === 'slot' || tag === 'component') {
+ if (
+ tag === 'slot' ||
+ tag === 'component' ||
+ tag === 'keep-alive'
+ ) {
return true
}
}
@@ -48,11 +52,11 @@ function markStatic (node) {
}
delete node.attrs
}
- if (node.type === 1) {
+ if (node.type === 1) {
delete node.staticClass
delete node.staticStyle
- if (node.attrs && !isComponent(node.tag)) { // 移除静态属性
+ if (node.attrs && !isComponent(node.tag) && node.tag !== 'keep-alive') { // 移除静态属性
node.attrs = node.attrs.filter(attr => attr.name === ID || isVar(attr.value))
}
diff --git a/packages/uni-template-compiler/lib/app/parser/base-parser.js b/packages/uni-template-compiler/lib/app/parser/base-parser.js
index 426ac5313e16ac50e0ed8267761b28bc7a9b3228..40c79406a0b4143feaf3a3d04d11198ba3b7a414 100644
--- a/packages/uni-template-compiler/lib/app/parser/base-parser.js
+++ b/packages/uni-template-compiler/lib/app/parser/base-parser.js
@@ -1,5 +1,6 @@
const {
ID,
+ C_IS,
V_IF,
V_FOR,
V_ELSE_IF,
@@ -8,6 +9,15 @@ const {
const parseTextExpr = require('./text-parser')
+function parseIs (el, genVar) {
+ if (!el.component) {
+ return
+ }
+ if (isVar(el.component)) {
+ el.component = genVar(C_IS, el.component)
+ }
+}
+
function parseIf (el, createGenVar) {
if (!el.if) {
return
@@ -60,6 +70,7 @@ function parseText (el, parent, state) {
}
module.exports = {
+ parseIs,
parseIf,
parseFor,
parseText,
diff --git a/packages/uni-template-compiler/lib/app/parser/component-parser.js b/packages/uni-template-compiler/lib/app/parser/component-parser.js
index c558bd6bf5856220ffd4ce6b3ac1f210efd977d1..446569ee5cff350d95ec69b90d2ff78d7958e201 100644
--- a/packages/uni-template-compiler/lib/app/parser/component-parser.js
+++ b/packages/uni-template-compiler/lib/app/parser/component-parser.js
@@ -1,14 +1,15 @@
const {
- ID,
- hasOwn
+ ID
} = require('../util')
-const tags = require('../../../../uni-cli-shared/lib/tags')
+const {
+ isComponent
+} = require('../../util')
// 仅限 view 层
module.exports = function parseComponent (el) {
// 需要把自定义组件的 attrs, props 全干掉
- if (el.tag && !hasOwn(tags, el.tag.replace('v-uni-', ''))) {
+ if (el.tag && isComponent(el.tag)) {
// 仅保留 ID
el.attrs && (el.attrs = el.attrs.filter(attr => attr.name === ID))
}
diff --git a/packages/uni-template-compiler/lib/app/service.js b/packages/uni-template-compiler/lib/app/service.js
index 28adee2ece35a0d762cf1eb1e978f764780e16ff..2883d648bbf5f8d9168272d618375c8f7a6bd980 100644
--- a/packages/uni-template-compiler/lib/app/service.js
+++ b/packages/uni-template-compiler/lib/app/service.js
@@ -14,6 +14,7 @@ const {
} = require('../util')
const {
+ parseIs,
parseIf,
parseFor,
parseText,
@@ -82,6 +83,7 @@ function transformNode (el, parent, state) {
const genVar = createGenVar(el.attrsMap[ID])
+ parseIs(el, genVar)
parseFor(el, createGenVar)
parseKey(el)
diff --git a/packages/uni-template-compiler/lib/app/util.js b/packages/uni-template-compiler/lib/app/util.js
index 51bf36b668bca8781502dad31fed65f9e5013afe..2924c9b6102951a183822800c124e29cebce71f9 100644
--- a/packages/uni-template-compiler/lib/app/util.js
+++ b/packages/uni-template-compiler/lib/app/util.js
@@ -9,6 +9,8 @@ const ITERATOR2 = '$2'
const ITERATOR3 = '$3'
const SET_DATA = '_$s'
const GET_DATA = '_$g'
+
+const C_IS = 'is'
const V_FOR = 'f'
const V_IF = 'i'
@@ -190,7 +192,8 @@ function addHandler (el, name, value, important) {
el.plain = false
}
-module.exports = {
+module.exports = {
+ C_IS,
V_FOR,
V_IF,
V_ELSE_IF,
diff --git a/packages/uni-template-compiler/lib/app/view.js b/packages/uni-template-compiler/lib/app/view.js
index e22130f37e0a7e0f7053e1f0f5e6f65f7a1a9737..077a8fac147c2a4a3fc97b37a5c92e9c46f62710 100644
--- a/packages/uni-template-compiler/lib/app/view.js
+++ b/packages/uni-template-compiler/lib/app/view.js
@@ -8,7 +8,8 @@ const {
traverseNode
} = require('./util')
-const {
+const {
+ parseIs,
parseIf,
parseFor,
parseText,
@@ -74,6 +75,8 @@ function transformNode (el, parent, state) {
const genVar = createGenVar(el.attrsMap[ID])
+ parseIs(el, genVar)
+
if (parseFor(el, createGenVar)) {
if (el.alias[0] === '{') { //
el.alias = '$item'
diff --git a/packages/uni-template-compiler/lib/util.js b/packages/uni-template-compiler/lib/util.js
index 5a4fd8d77d1eeeb9f27dfcfe62725e67ae1d4c26..bf119e07ee1ef92b62e11529ac089737c60b316f 100644
--- a/packages/uni-template-compiler/lib/util.js
+++ b/packages/uni-template-compiler/lib/util.js
@@ -183,9 +183,13 @@ const {
} = require('./h5')
function isComponent (tagName) {
- if (tagName === 'block' || tagName === 'template') {
+ if (
+ tagName === 'block' ||
+ tagName === 'template' ||
+ tagName === 'keep-alive'
+ ) {
return false
- }
+ }
return !hasOwn(tags, getTagName(tagName.replace('v-uni-', '')))
}
diff --git a/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/main.js b/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/main.js
index 0d42f19479d431a8365168278d9fadfbae7da30d..d5d3875bed80e3def91c55ec6ac3f4a84b44a5b3 100644
--- a/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/main.js
+++ b/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/main.js
@@ -17,7 +17,9 @@ const {
parseComponents
} = require('./util')
-function getDefineComponents(components) {
+function getDefineComponents({
+ components
+}) {
return components.map(({
name,
source
@@ -93,7 +95,7 @@ module.exports = function(source, map) {
return `
import 'uni-pages'
function initView(){
- ${getStylesCode(this)}
+ ${getStylesCode(this)}
injectStyles()
${getDefineComponents(parseComponents(source, traverse)).join('\n')}
UniViewJSBridge.publishHandler('webviewReady')
diff --git a/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/script.js b/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/script.js
index 9036d20edd840e05c71fc92ba16f15e6884e6cfb..77f1395a647e7f8e67370fb70aa61c916485120e 100644
--- a/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/script.js
+++ b/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/script.js
@@ -10,7 +10,7 @@ const {
parseComponents
} = require('./util')
-function genComponentCode (components) {
+function genComponentCode(components) {
const importCode = []
const componentsCode = []
components.forEach(({
@@ -24,12 +24,20 @@ function genComponentCode (components) {
return [importCode.join('\n'), componentsCode.join(',\n')]
}
-function genCode (components, css = []) {
+function genCode({
+ components,
+ options
+}, css = []) {
+ const optionsCode = []
+ Object.keys(options).forEach(name => {
+ options[name] !== null && optionsCode.push(`${name}:${options[name]}`)
+ })
const [importComponentCode, componentsCode] = genComponentCode(components)
// TODO js 内引用 css
return `
${importComponentCode}
export default {
+ ${optionsCode.length?(optionsCode.join(',')+','):''}
data(){
return {}
},
@@ -40,7 +48,7 @@ export default {
`
}
-module.exports = function (content, map) {
+module.exports = function(content, map) {
this.cacheable && this.cacheable()
content = preprocessor.preprocess(content, jsPreprocessOptions.context, {
diff --git a/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/util.js b/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/util.js
index 1e4edac659a1ab0f00fe6d9027678d6886ea29c8..26f293577c63484dfbff3ef86e266ba043a5a1f4 100644
--- a/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/util.js
+++ b/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/util.js
@@ -1,8 +1,9 @@
const parser = require('@babel/parser')
-function parseComponents (content, traverse) {
+function parseComponents(content, traverse) {
const {
state: {
+ options,
components
}
} = traverse(parser.parse(content, {
@@ -15,9 +16,16 @@ function parseComponents (content, traverse) {
'classProperties'
]
}), {
- components: []
+ components: [],
+ options: {
+ name: null,
+ inheritAttrs: null
+ }
})
- return components
+ return {
+ components,
+ options
+ }
}
module.exports = {
diff --git a/packages/webpack-uni-mp-loader/lib/babel/scoped-component-traverse.js b/packages/webpack-uni-mp-loader/lib/babel/scoped-component-traverse.js
index f29dabe45e5bdeb1fc3992e1719b6a461f7d420d..f17ff36bc9e481fc27a2c69289824199158268c1 100644
--- a/packages/webpack-uni-mp-loader/lib/babel/scoped-component-traverse.js
+++ b/packages/webpack-uni-mp-loader/lib/babel/scoped-component-traverse.js
@@ -6,10 +6,27 @@ const {
} = require('./util')
function handleObjectExpression (declaration, path, state) {
+ if (state.options) { // name,inheritAttrs
+ Object.keys(state.options).forEach(name => {
+ const optionProperty = declaration.properties.filter(prop => {
+ return t.isObjectProperty(prop) &&
+ t.isIdentifier(prop.key) &&
+ prop.key.name === name
+ })[0]
+ if (optionProperty) {
+ if (t.isStringLiteral(optionProperty.value)) {
+ state.options[name] = JSON.stringify(optionProperty.value.value)
+ } else {
+ state.options[name] = optionProperty.value.value
+ }
+ }
+ })
+ }
+
const componentsProperty = declaration.properties.filter(prop => {
return t.isObjectProperty(prop) &&
- t.isIdentifier(prop.key) &&
- prop.key.name === 'components'
+ t.isIdentifier(prop.key) &&
+ prop.key.name === 'components'
})[0]
if (componentsProperty && t.isObjectExpression(componentsProperty.value)) {
@@ -27,7 +44,8 @@ function handleObjectExpression (declaration, path, state) {
module.exports = function (ast, state = {
type: 'Component',
- components: []
+ components: [],
+ options: {}
}) {
babelTraverse(ast, {
ExportDefaultDeclaration (path) {
@@ -35,15 +53,15 @@ module.exports = function (ast, state = {
if (t.isObjectExpression(declaration)) { // export default {components:{}}
handleObjectExpression(declaration, path, state)
} else if (t.isCallExpression(declaration) &&
- t.isMemberExpression(declaration.callee) &&
- declaration.arguments.length === 1) { // export default Vue.extend({components:{}})
+ t.isMemberExpression(declaration.callee) &&
+ declaration.arguments.length === 1) { // export default Vue.extend({components:{}})
if (declaration.callee.object.name === 'Vue' && declaration.callee.property.name ===
- 'extend') {
+ 'extend') {
handleObjectExpression(declaration.arguments[0], path, state)
}
} else if (t.isClassDeclaration(declaration) &&
- declaration.decorators &&
- declaration.decorators.length) { // export default @Component({components:{}}) class MyComponent extend Vue
+ declaration.decorators &&
+ declaration.decorators.length) { // export default @Component({components:{}}) class MyComponent extend Vue
const componentDecorator = declaration.decorators[0]
if (t.isCallExpression(componentDecorator.expression)) {
const args = componentDecorator.expression.arguments