gov-vue-util
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -52,6 +52,21 @@ (function (global, factory) { | ||
// TODO: 后续支持异步组件的加载,配合设计器和运行器 | ||
function withMeta(component, meta) { | ||
let options; | ||
if (typeof component === 'function') { | ||
options = component.options; | ||
} | ||
else { | ||
options = component; | ||
} | ||
Object.keys(meta).forEach((key) => { | ||
options[key] = meta[key]; | ||
}); | ||
return options; | ||
} | ||
/** from common */ | ||
/** from plugin */ | ||
exports.addComponentMeta = addComponentMeta; | ||
exports.withMeta = withMeta; | ||
@@ -58,0 +73,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -1,2 +0,2 @@ | ||
/* gov fronter presented 🐣🐣🐣 */"use strict";function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],!(0<=b.indexOf(c))&&Object.prototype.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}function _typeof(a){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}(function(a,b){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):(a=a||self,b(a.gvUtil={}))})(void 0,function(a){'use strict';var b;(function(a){a.W="wedget",a.C="Component",a.L="layout"})(b||(b={})),a.addComponentMeta=function(a){var b=a.displayName,c=a.group,d=a.type,e=_objectWithoutProperties(a,["displayName","group","type"]);return{beforeCreate:function f(){var a=this;if(!b||!c||!d)throw new Error("no component meta");this.$$govDisplayName=b,this.$$govGroup=c,this.$$govType=d,e&&Object.keys(e).forEach(function(b){var c=b[0].toUpperCase(),d=b.slice(1);a["$$gov".concat(c).concat(d)]=e[b]})}}},Object.defineProperty(a,"__esModule",{value:!0})}); | ||
/* gov fronter presented 🐣🐣🐣 */"use strict";function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],!(0<=b.indexOf(c))&&Object.prototype.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}function _typeof(a){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}(function(a,b){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):(a=a||self,b(a.gvUtil={}))})(void 0,function(a){'use strict';var b;(function(a){a.W="wedget",a.C="Component",a.L="layout"})(b||(b={})),a.addComponentMeta=function(a){var b=a.displayName,c=a.group,d=a.type,e=_objectWithoutProperties(a,["displayName","group","type"]);return{beforeCreate:function f(){var a=this;if(!b||!c||!d)throw new Error("no component meta");this.$$govDisplayName=b,this.$$govGroup=c,this.$$govType=d,e&&Object.keys(e).forEach(function(b){var c=b[0].toUpperCase(),d=b.slice(1);a["$$gov".concat(c).concat(d)]=e[b]})}}},a.withMeta=function(a,b){var c;return c="function"==typeof a?a.options:a,Object.keys(b).forEach(function(a){c[a]=b[a]}),c},Object.defineProperty(a,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=gov-vue-util.min.js.map |
{ | ||
"name": "gov-vue-util", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "政务vue组件util工具集", | ||
@@ -11,3 +11,3 @@ "main": "dist/gov-vue-util.min.js", | ||
"build": "npm run lint:ts && npm run lint:js && npm run test && gulp build", | ||
"prepublish": "npm run build", | ||
"prepublishOnly": "npm run build", | ||
"postpublish": "git push" | ||
@@ -32,2 +32,3 @@ }, | ||
"@types/jest": "^24.0.9", | ||
"@types/node": "^11.13.4", | ||
"@types/rollup": "^0.54.0", | ||
@@ -34,0 +35,0 @@ "babel-eslint": "^10.0.1", |
@@ -23,5 +23,5 @@ # 目的 | ||
```ts | ||
import addComponentMeta from 'gov-vue-util/es/addComponentMeta'; | ||
import withMeta from 'gov-vue-util/es/addComponentMeta'; | ||
// or, 如果支持tree shaking 请用前者 | ||
import addComponentMeta from 'gov-vue-util/lib/addComponentMeta'; | ||
import withMeta from 'gov-vue-util/lib/addComponentMeta'; | ||
``` | ||
@@ -45,3 +45,3 @@ | ||
```ts | ||
import { addComponentMeta } from 'gov-vue-util'; | ||
import { withMeta } from 'gov-vue-util'; | ||
``` | ||
@@ -58,18 +58,21 @@ | ||
### mixins | ||
### hoc | ||
#### 1. addComponentMeta | ||
#### 1. withMeta | ||
详情请看[源代码](./src/mixin/addComponentMeta.ts) | ||
使用方法: | ||
```ts | ||
{ | ||
withMeta({ | ||
name: 'MyComponent', | ||
mixins: [addComponentMeta('组件中文名称', 'gov', 'layout')], | ||
mixins: [], | ||
// ...other options | ||
} | ||
}, { | ||
$$displayName: '组件中文名称', | ||
$$group: 'platform', | ||
$$:type: 'layout', | ||
}) | ||
``` | ||
## TODO | ||
@@ -76,0 +79,0 @@ |
@@ -14,5 +14,2 @@ { | ||
"baseUrl": ".", | ||
"types": [ | ||
"jest" | ||
], | ||
"paths": { | ||
@@ -19,0 +16,0 @@ "@/*": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
284437
82
26
23
414