xt-element-ui 1.0.0 → 1.0.1
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/docs/.vuepress/config.js +23 -0
- package/docs/.vuepress/enhanceApp.js +8 -0
- package/docs/README.md +6 -0
- package/docs/components/base/button.md +5 -0
- package/docs/components/base/input.md +22 -0
- package/examples/App.vue +13 -0
- package/examples/favicon.ico +0 -0
- package/examples/index.html +11 -0
- package/examples/main.js +9 -0
- package/lib/fonts/element-icons.f1a45d74.ttf +0 -0
- package/lib/fonts/element-icons.ff18efd1.woff +0 -0
- package/lib/index.common.js +124 -23
- package/lib/index.css +1 -0
- package/lib/index.umd.js +170 -30
- package/lib/index.umd.min.js +1 -1
- package/package.json +4 -2
- package/src/components/button/index.js +2 -0
- package/src/components/button/index.vue +14 -0
- package/src/components/input/index.js +2 -0
- package/src/components/input/index.vue +20 -0
- package/src/index.js +45 -5
- package/vue.config.js +14 -9
- package/src/components/Button.vue +0 -1
- package/src/components/Input.vue +0 -1
package/lib/index.umd.js
CHANGED
|
@@ -1,19 +1,70 @@
|
|
|
1
1
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
2
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
-
module.exports = factory();
|
|
3
|
+
module.exports = factory(require("ElementUI"), require("Vue"));
|
|
4
4
|
else if(typeof define === 'function' && define.amd)
|
|
5
|
-
define("xt-element-ui", [], factory);
|
|
5
|
+
define("xt-element-ui", ["ElementUI", "Vue"], factory);
|
|
6
6
|
else if(typeof exports === 'object')
|
|
7
|
-
exports["xt-element-ui"] = factory();
|
|
7
|
+
exports["xt-element-ui"] = factory(require("ElementUI"), require("Vue"));
|
|
8
8
|
else
|
|
9
|
-
root["xt-element-ui"] = factory();
|
|
10
|
-
})((typeof self !== 'undefined' ? self : this), () => {
|
|
9
|
+
root["xt-element-ui"] = factory(root["ElementUI"], root["Vue"]);
|
|
10
|
+
})((typeof self !== 'undefined' ? self : this), (__WEBPACK_EXTERNAL_MODULE__282__, __WEBPACK_EXTERNAL_MODULE__508__) => {
|
|
11
11
|
return /******/ (() => { // webpackBootstrap
|
|
12
12
|
/******/ "use strict";
|
|
13
|
-
/******/
|
|
14
|
-
|
|
13
|
+
/******/ var __webpack_modules__ = ({
|
|
14
|
+
|
|
15
|
+
/***/ 282
|
|
16
|
+
(module) {
|
|
17
|
+
|
|
18
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__282__;
|
|
19
|
+
|
|
20
|
+
/***/ },
|
|
21
|
+
|
|
22
|
+
/***/ 508
|
|
23
|
+
(module) {
|
|
24
|
+
|
|
25
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__508__;
|
|
26
|
+
|
|
27
|
+
/***/ }
|
|
28
|
+
|
|
29
|
+
/******/ });
|
|
30
|
+
/************************************************************************/
|
|
31
|
+
/******/ // The module cache
|
|
32
|
+
/******/ var __webpack_module_cache__ = {};
|
|
33
|
+
/******/
|
|
34
|
+
/******/ // The require function
|
|
35
|
+
/******/ function __webpack_require__(moduleId) {
|
|
36
|
+
/******/ // Check if module is in cache
|
|
37
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
38
|
+
/******/ if (cachedModule !== undefined) {
|
|
39
|
+
/******/ return cachedModule.exports;
|
|
40
|
+
/******/ }
|
|
41
|
+
/******/ // Create a new module (and put it into the cache)
|
|
42
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
43
|
+
/******/ // no module.id needed
|
|
44
|
+
/******/ // no module.loaded needed
|
|
45
|
+
/******/ exports: {}
|
|
46
|
+
/******/ };
|
|
47
|
+
/******/
|
|
48
|
+
/******/ // Execute the module function
|
|
49
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
50
|
+
/******/
|
|
51
|
+
/******/ // Return the exports of the module
|
|
52
|
+
/******/ return module.exports;
|
|
53
|
+
/******/ }
|
|
15
54
|
/******/
|
|
16
55
|
/************************************************************************/
|
|
56
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
57
|
+
/******/ (() => {
|
|
58
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
59
|
+
/******/ __webpack_require__.n = (module) => {
|
|
60
|
+
/******/ var getter = module && module.__esModule ?
|
|
61
|
+
/******/ () => (module['default']) :
|
|
62
|
+
/******/ () => (module);
|
|
63
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
64
|
+
/******/ return getter;
|
|
65
|
+
/******/ };
|
|
66
|
+
/******/ })();
|
|
67
|
+
/******/
|
|
17
68
|
/******/ /* webpack/runtime/define property getters */
|
|
18
69
|
/******/ (() => {
|
|
19
70
|
/******/ // define getter functions for harmony exports
|
|
@@ -54,7 +105,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
54
105
|
|
|
55
106
|
// EXPORTS
|
|
56
107
|
__webpack_require__.d(__webpack_exports__, {
|
|
57
|
-
|
|
108
|
+
ElementUI: () => (/* reexport */ (external_ElementUI_default())),
|
|
109
|
+
Vue: () => (/* reexport */ (external_Vue_default())),
|
|
110
|
+
"default": () => (/* binding */ entry_lib),
|
|
111
|
+
getSize: () => (/* reexport */ getSize),
|
|
112
|
+
getTheme: () => (/* reexport */ getTheme),
|
|
113
|
+
setSize: () => (/* reexport */ setSize),
|
|
114
|
+
setTheme: () => (/* reexport */ setTheme)
|
|
58
115
|
});
|
|
59
116
|
|
|
60
117
|
;// ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js
|
|
@@ -75,12 +132,32 @@ if (typeof window !== 'undefined') {
|
|
|
75
132
|
// Indicate to webpack that this file can be concatenated
|
|
76
133
|
/* harmony default export */ const setPublicPath = (null);
|
|
77
134
|
|
|
78
|
-
|
|
79
|
-
var
|
|
135
|
+
// EXTERNAL MODULE: external "Vue"
|
|
136
|
+
var external_Vue_ = __webpack_require__(508);
|
|
137
|
+
var external_Vue_default = /*#__PURE__*/__webpack_require__.n(external_Vue_);
|
|
138
|
+
// EXTERNAL MODULE: external "ElementUI"
|
|
139
|
+
var external_ElementUI_ = __webpack_require__(282);
|
|
140
|
+
var external_ElementUI_default = /*#__PURE__*/__webpack_require__.n(external_ElementUI_);
|
|
141
|
+
;// ./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/button/index.vue?vue&type=template&id=55650f2e
|
|
142
|
+
var render = function render(){var _vm=this,_c=_vm._self._c;return _c('el-button',{on:{"click":_vm.handleClick}},[_vm._v(_vm._s(_vm.text))])
|
|
80
143
|
}
|
|
81
144
|
var staticRenderFns = []
|
|
82
145
|
|
|
83
146
|
|
|
147
|
+
;// ./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/button/index.vue?vue&type=script&lang=js
|
|
148
|
+
|
|
149
|
+
/* harmony default export */ const buttonvue_type_script_lang_js = ({
|
|
150
|
+
props:['text'],
|
|
151
|
+
name: 'XtButton',
|
|
152
|
+
methods:{
|
|
153
|
+
handleClick(){
|
|
154
|
+
this.$emit('click')
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
;// ./src/components/button/index.vue?vue&type=script&lang=js
|
|
160
|
+
/* harmony default export */ const components_buttonvue_type_script_lang_js = (buttonvue_type_script_lang_js);
|
|
84
161
|
;// ./node_modules/@vue/vue-loader-v15/lib/runtime/componentNormalizer.js
|
|
85
162
|
/* globals __VUE_SSR_CONTEXT__ */
|
|
86
163
|
|
|
@@ -179,15 +256,16 @@ function normalizeComponent(
|
|
|
179
256
|
}
|
|
180
257
|
}
|
|
181
258
|
|
|
182
|
-
;// ./src/components/
|
|
259
|
+
;// ./src/components/button/index.vue
|
|
260
|
+
|
|
261
|
+
|
|
183
262
|
|
|
184
|
-
var script = {}
|
|
185
263
|
|
|
186
264
|
|
|
187
265
|
/* normalize component */
|
|
188
266
|
;
|
|
189
267
|
var component = normalizeComponent(
|
|
190
|
-
|
|
268
|
+
components_buttonvue_type_script_lang_js,
|
|
191
269
|
render,
|
|
192
270
|
staticRenderFns,
|
|
193
271
|
false,
|
|
@@ -197,24 +275,43 @@ var component = normalizeComponent(
|
|
|
197
275
|
|
|
198
276
|
)
|
|
199
277
|
|
|
200
|
-
/* harmony default export */ const
|
|
201
|
-
;// ./
|
|
202
|
-
|
|
278
|
+
/* harmony default export */ const components_button = (component.exports);
|
|
279
|
+
;// ./src/components/button/index.js
|
|
280
|
+
|
|
281
|
+
/* harmony default export */ const src_components_button = (components_button);
|
|
282
|
+
;// ./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/input/index.vue?vue&type=template&id=fe9146e4
|
|
283
|
+
var inputvue_type_template_id_fe9146e4_render = function render(){var _vm=this,_c=_vm._self._c;return _c('el-input',{attrs:{"value":_vm.value,"placeholder":_vm.placeholder},on:{"input":function($event){return _vm.$emit('input', $event)}}})
|
|
203
284
|
}
|
|
204
|
-
var
|
|
285
|
+
var inputvue_type_template_id_fe9146e4_staticRenderFns = []
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
;// ./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/input/index.vue?vue&type=script&lang=js
|
|
289
|
+
|
|
290
|
+
/* harmony default export */ const inputvue_type_script_lang_js = ({
|
|
291
|
+
name: 'XtInput',
|
|
292
|
+
props: {
|
|
293
|
+
value: [String, Number],
|
|
294
|
+
placeholder: {
|
|
295
|
+
type: String,
|
|
296
|
+
default: '请输入内容'
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
;// ./src/components/input/index.vue?vue&type=script&lang=js
|
|
302
|
+
/* harmony default export */ const components_inputvue_type_script_lang_js = (inputvue_type_script_lang_js);
|
|
303
|
+
;// ./src/components/input/index.vue
|
|
205
304
|
|
|
206
305
|
|
|
207
|
-
;// ./src/components/Input.vue
|
|
208
306
|
|
|
209
|
-
var Input_script = {}
|
|
210
307
|
|
|
211
308
|
|
|
212
309
|
/* normalize component */
|
|
213
310
|
;
|
|
214
|
-
var
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
311
|
+
var input_component = normalizeComponent(
|
|
312
|
+
components_inputvue_type_script_lang_js,
|
|
313
|
+
inputvue_type_template_id_fe9146e4_render,
|
|
314
|
+
inputvue_type_template_id_fe9146e4_staticRenderFns,
|
|
218
315
|
false,
|
|
219
316
|
null,
|
|
220
317
|
null,
|
|
@@ -222,17 +319,28 @@ var Input_component = normalizeComponent(
|
|
|
222
319
|
|
|
223
320
|
)
|
|
224
321
|
|
|
225
|
-
/* harmony default export */ const
|
|
322
|
+
/* harmony default export */ const input = (input_component.exports);
|
|
323
|
+
;// ./src/components/input/index.js
|
|
324
|
+
|
|
325
|
+
/* harmony default export */ const components_input = (input);
|
|
226
326
|
;// ./src/index.js
|
|
327
|
+
// 导入 Vue
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
// 导入 Element UI 并注册
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
227
334
|
// 导入组件
|
|
228
335
|
|
|
229
336
|
|
|
230
|
-
|
|
337
|
+
|
|
338
|
+
|
|
231
339
|
|
|
232
340
|
// 存储组件列表
|
|
233
341
|
const components = [
|
|
234
|
-
|
|
235
|
-
|
|
342
|
+
src_components_button,
|
|
343
|
+
components_input
|
|
236
344
|
]
|
|
237
345
|
|
|
238
346
|
// 定义 install 方法,Vue.use() 会自动调用
|
|
@@ -240,12 +348,16 @@ const install = function (Vue) {
|
|
|
240
348
|
if (install.installed) return
|
|
241
349
|
install.installed = true
|
|
242
350
|
|
|
243
|
-
//
|
|
351
|
+
// 注册 Element UI
|
|
352
|
+
Vue.use((external_ElementUI_default()))
|
|
353
|
+
|
|
354
|
+
// 全局注册所有 xt- 组件
|
|
244
355
|
components.forEach(component => {
|
|
245
356
|
Vue.component(component.name, component)
|
|
246
357
|
})
|
|
247
358
|
}
|
|
248
359
|
|
|
360
|
+
|
|
249
361
|
// 支持全局 script 标签引入
|
|
250
362
|
if (typeof window !== 'undefined' && window.Vue) {
|
|
251
363
|
install(window.Vue)
|
|
@@ -255,9 +367,37 @@ if (typeof window !== 'undefined' && window.Vue) {
|
|
|
255
367
|
/* harmony default export */ const src_0 = ({
|
|
256
368
|
install,
|
|
257
369
|
// 按需导出组件
|
|
258
|
-
Button:
|
|
259
|
-
Input:
|
|
370
|
+
Button: src_components_button,
|
|
371
|
+
Input: components_input,
|
|
372
|
+
// 导出 ElementUI 以便用户按需引入
|
|
373
|
+
ElementUI: (external_ElementUI_default())
|
|
260
374
|
});
|
|
375
|
+
|
|
376
|
+
// 导出 Vue 和 ElementUI 以便用户使用
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
// 导出主题切换工具函数
|
|
380
|
+
const setTheme = function(theme) {
|
|
381
|
+
const validThemes = ['light', 'dark', 'compact']
|
|
382
|
+
if (validThemes.includes(theme)) {
|
|
383
|
+
document.documentElement.setAttribute('data-theme', theme)
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const setSize = function(size) {
|
|
388
|
+
const validSizes = ['small', 'medium', 'large']
|
|
389
|
+
if (validSizes.includes(size)) {
|
|
390
|
+
document.documentElement.setAttribute('data-size', size)
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
const getTheme = function() {
|
|
395
|
+
return document.documentElement.getAttribute('data-theme') || 'light'
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const getSize = function() {
|
|
399
|
+
return document.documentElement.getAttribute('data-size') || 'medium'
|
|
400
|
+
}
|
|
261
401
|
;// ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js
|
|
262
402
|
|
|
263
403
|
|
package/lib/index.umd.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define("xt-element-ui",[],t):"object"===typeof exports?exports["xt-element-ui"]=t():e["xt-element-ui"]=t()})("undefined"!==typeof self?self:this,()=>(()=>{"use strict";var e={};(()=>{e.d
|
|
1
|
+
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("ElementUI"),require("Vue")):"function"===typeof define&&define.amd?define("xt-element-ui",["ElementUI","Vue"],t):"object"===typeof exports?exports["xt-element-ui"]=t(require("ElementUI"),require("Vue")):e["xt-element-ui"]=t(e["ElementUI"],e["Vue"])})("undefined"!==typeof self?self:this,(e,t)=>(()=>{"use strict";var n={282(t){t.exports=e},508(e){e.exports=t}},o={};function r(e){var t=o[e];if(void 0!==t)return t.exports;var i=o[e]={exports:{}};return n[e](i,i.exports,r),i.exports}(()=>{r.n=e=>{var t=e&&e.__esModule?()=>e["default"]:()=>e;return r.d(t,{a:t}),t}})(),(()=>{r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}})(),(()=>{r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{r.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}})(),(()=>{r.p=""})();var i={};if(r.r(i),r.d(i,{ElementUI:()=>c(),Vue:()=>d(),default:()=>R,getSize:()=>k,getTheme:()=>O,setSize:()=>U,setTheme:()=>T}),"undefined"!==typeof window){var u=window.document.currentScript,l=u&&u.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);l&&(r.p=l[1])}var s=r(508),d=r.n(s),a=r(282),c=r.n(a),p=function(){var e=this,t=e._self._c;return t("el-button",{on:{click:e.handleClick}},[e._v(e._s(e.text))])},f=[];const m={props:["text"],name:"XtButton",methods:{handleClick(){this.$emit("click")}}},h=m;function v(e,t,n,o,r,i,u,l){var s,d="function"===typeof e?e.options:e;if(t&&(d.render=t,d.staticRenderFns=n,d._compiled=!0),o&&(d.functional=!0),i&&(d._scopeId="data-v-"+i),u?(s=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"===typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),r&&r.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(u)},d._ssrRegister=s):r&&(s=l?function(){r.call(this,(d.functional?this.parent:this).$root.$options.shadowRoot)}:r),s)if(d.functional){d._injectStyles=s;var a=d.render;d.render=function(e,t){return s.call(t),a(e,t)}}else{var c=d.beforeCreate;d.beforeCreate=c?[].concat(c,s):[s]}return{exports:e,options:d}}var _=v(h,p,f,!1,null,null,null);const x=_.exports,y=x;var b=function(){var e=this,t=e._self._c;return t("el-input",{attrs:{value:e.value,placeholder:e.placeholder},on:{input:function(t){return e.$emit("input",t)}}})},g=[];const E={name:"XtInput",props:{value:[String,Number],placeholder:{type:String,default:"请输入内容"}}},S=E;var w=v(S,b,g,!1,null,null,null);const C=w.exports,j=C,I=[y,j],V=function(e){V.installed||(V.installed=!0,e.use(c()),I.forEach(t=>{e.component(t.name,t)}))};"undefined"!==typeof window&&window.Vue&&V(window.Vue);const $={install:V,Button:y,Input:j,ElementUI:c()},T=function(e){const t=["light","dark","compact"];t.includes(e)&&document.documentElement.setAttribute("data-theme",e)},U=function(e){const t=["small","medium","large"];t.includes(e)&&document.documentElement.setAttribute("data-size",e)},O=function(){return document.documentElement.getAttribute("data-theme")||"light"},k=function(){return document.documentElement.getAttribute("data-size")||"medium"},R=$;return i})());
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xt-element-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "基于 Vue2.7 + ElementUI 的组件库",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"style": "lib/index.css",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"docs:dev": "vuepress dev docs",
|
|
9
9
|
"docs:build": "vuepress build docs",
|
|
10
|
+
"dev": "vue-cli-service serve",
|
|
10
11
|
"lib": "vue-cli-service build --target lib --name index --dest lib src/index.js"
|
|
11
12
|
},
|
|
12
13
|
"keywords": [
|
|
@@ -24,6 +25,7 @@
|
|
|
24
25
|
"devDependencies": {
|
|
25
26
|
"@vue/cli-service": "^5.0.9",
|
|
26
27
|
"sass": "^1.32.13",
|
|
27
|
-
"sass-loader": "^10.5.2"
|
|
28
|
+
"sass-loader": "^10.5.2",
|
|
29
|
+
"vuepress": "^1.9.10"
|
|
28
30
|
}
|
|
29
31
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-input
|
|
3
|
+
:value="value"
|
|
4
|
+
:placeholder="placeholder"
|
|
5
|
+
@input="$emit('input', $event)"
|
|
6
|
+
/>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
export default {
|
|
11
|
+
name: 'XtInput',
|
|
12
|
+
props: {
|
|
13
|
+
value: [String, Number],
|
|
14
|
+
placeholder: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: '请输入内容'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
</script>
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
// 导入 Vue
|
|
2
|
+
import Vue from 'vue'
|
|
3
|
+
|
|
4
|
+
// 导入 Element UI 并注册
|
|
5
|
+
import ElementUI from 'element-ui'
|
|
6
|
+
import 'element-ui/lib/theme-chalk/index.css'
|
|
7
|
+
|
|
1
8
|
// 导入组件
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
import Button from './components/button'
|
|
12
|
+
import Input from './components/input'
|
|
5
13
|
|
|
6
14
|
// 存储组件列表
|
|
7
15
|
const components = [
|
|
@@ -14,12 +22,16 @@ const install = function (Vue) {
|
|
|
14
22
|
if (install.installed) return
|
|
15
23
|
install.installed = true
|
|
16
24
|
|
|
17
|
-
//
|
|
25
|
+
// 注册 Element UI
|
|
26
|
+
Vue.use(ElementUI)
|
|
27
|
+
|
|
28
|
+
// 全局注册所有 xt- 组件
|
|
18
29
|
components.forEach(component => {
|
|
19
30
|
Vue.component(component.name, component)
|
|
20
31
|
})
|
|
21
32
|
}
|
|
22
33
|
|
|
34
|
+
|
|
23
35
|
// 支持全局 script 标签引入
|
|
24
36
|
if (typeof window !== 'undefined' && window.Vue) {
|
|
25
37
|
install(window.Vue)
|
|
@@ -30,5 +42,33 @@ export default {
|
|
|
30
42
|
install,
|
|
31
43
|
// 按需导出组件
|
|
32
44
|
Button,
|
|
33
|
-
Input
|
|
45
|
+
Input,
|
|
46
|
+
// 导出 ElementUI 以便用户按需引入
|
|
47
|
+
ElementUI
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 导出 Vue 和 ElementUI 以便用户使用
|
|
51
|
+
export { Vue, ElementUI }
|
|
52
|
+
|
|
53
|
+
// 导出主题切换工具函数
|
|
54
|
+
export const setTheme = function(theme) {
|
|
55
|
+
const validThemes = ['light', 'dark', 'compact']
|
|
56
|
+
if (validThemes.includes(theme)) {
|
|
57
|
+
document.documentElement.setAttribute('data-theme', theme)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const setSize = function(size) {
|
|
62
|
+
const validSizes = ['small', 'medium', 'large']
|
|
63
|
+
if (validSizes.includes(size)) {
|
|
64
|
+
document.documentElement.setAttribute('data-size', size)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const getTheme = function() {
|
|
69
|
+
return document.documentElement.getAttribute('data-theme') || 'light'
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const getSize = function() {
|
|
73
|
+
return document.documentElement.getAttribute('data-size') || 'medium'
|
|
34
74
|
}
|
package/vue.config.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
// 关闭生产环境 sourcemap
|
|
3
3
|
productionSourceMap: false,
|
|
4
|
-
|
|
4
|
+
// 单页面标准入口配置
|
|
5
|
+
pages: {
|
|
6
|
+
index: {
|
|
7
|
+
entry: './examples/main.js', // 你的项目启动入口
|
|
8
|
+
template: './examples/index.html',
|
|
9
|
+
filename: 'index.html'
|
|
10
|
+
}
|
|
11
|
+
},
|
|
5
12
|
css: {
|
|
6
13
|
// 开启 CSS 提取(打包成独立 css 文件,给 npm 使用)
|
|
7
14
|
extract: true,
|
|
@@ -16,14 +23,6 @@ module.exports = {
|
|
|
16
23
|
}
|
|
17
24
|
},
|
|
18
25
|
|
|
19
|
-
// 配置 Webpack 外部扩展(不打包进组件库)
|
|
20
|
-
configureWebpack: {
|
|
21
|
-
externals: {
|
|
22
|
-
vue: "Vue",
|
|
23
|
-
"element-ui": "ElementUI",
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
|
|
27
26
|
// 组件库打包配置
|
|
28
27
|
chainWebpack: (config) => {
|
|
29
28
|
if (process.env.NODE_ENV === "production") {
|
|
@@ -36,6 +35,12 @@ module.exports = {
|
|
|
36
35
|
.library("xt-element-ui")
|
|
37
36
|
.libraryTarget("umd")
|
|
38
37
|
.umdNamedDefine(true);
|
|
38
|
+
|
|
39
|
+
// 只在生产环境配置 externals(打包组件库时不打包 Vue 和 Element UI)
|
|
40
|
+
config.externals({
|
|
41
|
+
vue: "Vue",
|
|
42
|
+
"element-ui": "ElementUI",
|
|
43
|
+
});
|
|
39
44
|
}
|
|
40
45
|
},
|
|
41
46
|
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<template><el-button>按钮</el-button></template>
|
package/src/components/Input.vue
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<template><el-input></el-input></template>
|