4cd4fd28
郭伟龙
feat: 初始化项目
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
import Vue from 'vue';
import { mergeData } from 'vue-functional-data-merge'; // --- Constants ---
var COMPONENT_UID_KEY = '_uid';
var isVue3 = Vue.version.startsWith('3');
export var REF_FOR_KEY = isVue3 ? 'ref_for' : 'refInFor';
var ALLOWED_FIELDS_IN_DATA = ['class', 'staticClass', 'style', 'attrs', 'props', 'domProps', 'on', 'nativeOn', 'directives', 'scopedSlots', 'slot', 'key', 'ref', 'refInFor'];
var extend = Vue.extend.bind(Vue);
if (isVue3) {
var originalExtend = Vue.extend;
var KNOWN_COMPONENTS = ['router-link', 'transition', 'transition-group'];
var originalVModelDynamicCreated = Vue.vModelDynamic.created;
var originalVModelDynamicBeforeUpdate = Vue.vModelDynamic.beforeUpdate; // See https://github.com/vuejs/vue-next/pull/4121 for details
Vue.vModelDynamic.created = function (el, binding, vnode) {
originalVModelDynamicCreated.call(this, el, binding, vnode);
if (!el._assign) {
el._assign = function () {};
}
};
Vue.vModelDynamic.beforeUpdate = function (el, binding, vnode) {
originalVModelDynamicBeforeUpdate.call(this, el, binding, vnode);
if (!el._assign) {
el._assign = function () {};
}
};
extend = function patchedBootstrapVueExtend(definition) {
if (_typeof(definition) === 'object' && definition.render && !definition.__alreadyPatched) {
var originalRender = definition.render;
definition.__alreadyPatched = true;
definition.render = function (h) {
var patchedH = function patchedH(tag, dataObjOrChildren, rawSlots) {
var slots = rawSlots === undefined ? [] : [Array.isArray(rawSlots) ? rawSlots.filter(Boolean) : rawSlots];
var isTag = typeof tag === 'string' && !KNOWN_COMPONENTS.includes(tag);
var isSecondArgumentDataObject = dataObjOrChildren && _typeof(dataObjOrChildren) === 'object' && !Array.isArray(dataObjOrChildren);
if (!isSecondArgumentDataObject) {
return h.apply(void 0, [tag, dataObjOrChildren].concat(slots));
}
var attrs = dataObjOrChildren.attrs,
props = dataObjOrChildren.props,
restData = _objectWithoutProperties(dataObjOrChildren, ["attrs", "props"]);
var normalizedData = _objectSpread(_objectSpread({}, restData), {}, {
attrs: attrs,
props: isTag ? {} : props
});
if (tag === 'router-link' && !normalizedData.slots && !normalizedData.scopedSlots) {
// terrible workaround to fix router-link rendering with compat vue-router
normalizedData.scopedSlots = {
$hasNormal: function $hasNormal() {}
};
}
return h.apply(void 0, [tag, normalizedData].concat(slots));
};
if (definition.functional) {
var _ctx$children, _ctx$children$default;
var ctx = arguments[1];
var patchedCtx = _objectSpread({}, ctx);
patchedCtx.data = {
attrs: _objectSpread({}, ctx.data.attrs || {}),
props: _objectSpread({}, ctx.data.props || {})
};
Object.keys(ctx.data || {}).forEach(function (key) {
if (ALLOWED_FIELDS_IN_DATA.includes(key)) {
patchedCtx.data[key] = ctx.data[key];
} else if (key in ctx.props) {
patchedCtx.data.props[key] = ctx.data[key];
} else if (!key.startsWith('on')) {
patchedCtx.data.attrs[key] = ctx.data[key];
}
});
var IGNORED_CHILDREN_KEYS = ['_ctx'];
var children = ((_ctx$children = ctx.children) === null || _ctx$children === void 0 ? void 0 : (_ctx$children$default = _ctx$children.default) === null || _ctx$children$default === void 0 ? void 0 : _ctx$children$default.call(_ctx$children)) || ctx.children;
if (children && Object.keys(patchedCtx.children).filter(function (k) {
return !IGNORED_CHILDREN_KEYS.includes(k);
}).length === 0) {
delete patchedCtx.children;
} else {
patchedCtx.children = children;
}
patchedCtx.data.on = ctx.listeners;
return originalRender.call(this, patchedH, patchedCtx);
}
return originalRender.call(this, patchedH);
};
}
return originalExtend.call(this, definition);
}.bind(Vue);
}
var nextTick = Vue.nextTick;
export { COMPONENT_UID_KEY, Vue, mergeData, isVue3, nextTick, extend };
|